From 5c867406aa66a1d89260c233a6bbc1a2a7912dbe Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 8 Oct 2009 19:06:32 +0000 Subject: menus are now global (like operators), so for eg, the info add menu and the 3D add menu can be shared. --- source/blender/windowmanager/intern/wm.c | 46 ++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) (limited to 'source/blender/windowmanager/intern/wm.c') diff --git a/source/blender/windowmanager/intern/wm.c b/source/blender/windowmanager/intern/wm.c index a068f84ae29..dbb8fc400c0 100644 --- a/source/blender/windowmanager/intern/wm.c +++ b/source/blender/windowmanager/intern/wm.c @@ -26,6 +26,8 @@ * ***** END GPL LICENSE BLOCK ***** */ +#include "string.h" + #include "DNA_windowmanager_types.h" #include "MEM_guardedalloc.h" @@ -39,6 +41,7 @@ #include "BKE_idprop.h" #include "BKE_library.h" #include "BKE_main.h" +#include "BKE_screen.h" #include "BKE_report.h" #include "WM_api.h" @@ -128,6 +131,49 @@ void WM_operator_stack_clear(bContext *C) /* ****************************************** */ +static ListBase menutypes = {NULL, NULL}; /* global menutype list */ + +MenuType *WM_menutype_find(const char *idname, int quiet) +{ + MenuType* mt; + + if (idname[0]) { + for(mt=menutypes.first; mt; mt=mt->next) + if(strcmp(idname, mt->idname)==0) + return mt; + } + + if(!quiet) + printf("search for unknown menutype %s\n", idname); + + return NULL; +} + +int WM_menutype_add(MenuType* mt) +{ + BLI_addtail(&menutypes, mt); + return 1; +} + +void WM_menutype_freelink(MenuType* mt) +{ + BLI_freelinkN(&menutypes, mt); +} + +void WM_menutype_free(void) +{ + MenuType* mt; + + for(mt= menutypes.first; mt; mt= mt->next) { + if(mt->ext.free) { + mt->ext.free(mt->ext.data); + } + WM_menutype_freelink(mt); + } +} + +/* ****************************************** */ + void WM_keymap_init(bContext *C) { wmWindowManager *wm= CTX_wm_manager(C); -- cgit v1.2.3