From 302856f4b16896d19e2adf6bd42823a88684fd4a Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Tue, 4 Dec 2012 18:22:41 +0000 Subject: [PATCH] operator spacebar search menu wasn't ignoring internal operators, turns out there were copy-pasted functions for operator search popups which were identical except that one skipped internal ops. de-duplicate so both work the same now. --- source/blender/editors/include/UI_interface.h | 1 + .../editors/interface/interface_templates.c | 10 ++++- .../windowmanager/intern/wm_operators.c | 45 +------------------ 3 files changed, 11 insertions(+), 45 deletions(-) diff --git a/source/blender/editors/include/UI_interface.h b/source/blender/editors/include/UI_interface.h index 12db9b93772..2dc552d0fce 100644 --- a/source/blender/editors/include/UI_interface.h +++ b/source/blender/editors/include/UI_interface.h @@ -817,6 +817,7 @@ void uiTemplateImage(uiLayout *layout, struct bContext *C, struct PointerRNA *pt void uiTemplateImageSettings(uiLayout *layout, struct PointerRNA *imfptr, int color_management); void uiTemplateImageLayers(uiLayout *layout, struct bContext *C, struct Image *ima, struct ImageUser *iuser); void uiTemplateRunningJobs(uiLayout *layout, struct bContext *C); +void uiOperatorSearch_But(uiBut *but); void uiTemplateOperatorSearch(uiLayout *layout); void uiTemplateHeader3D(uiLayout *layout, struct bContext *C); void uiTemplateEditModeSelection(uiLayout *layout, struct bContext *C); diff --git a/source/blender/editors/interface/interface_templates.c b/source/blender/editors/interface/interface_templates.c index 19d4de8bce4..f7a53c6bab2 100644 --- a/source/blender/editors/interface/interface_templates.c +++ b/source/blender/editors/interface/interface_templates.c @@ -2785,6 +2785,9 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { wmOperatorType *ot = BLI_ghashIterator_getValue(iter); + if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) + continue; + if (BLI_strcasestr(ot->name, str)) { if (WM_operator_poll((bContext *)C, ot)) { char name[256]; @@ -2810,6 +2813,11 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char BLI_ghashIterator_free(iter); } +void uiOperatorSearch_But(uiBut *but) +{ + uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL); +} + void uiTemplateOperatorSearch(uiLayout *layout) { uiBlock *block; @@ -2820,7 +2828,7 @@ void uiTemplateOperatorSearch(uiLayout *layout) uiBlockSetCurLayout(block, layout); but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 0, 0, UI_UNIT_X * 6, UI_UNIT_Y, 0, 0, ""); - uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL); + uiOperatorSearch_But(but); } /************************* Running Jobs Template **************************/ diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 80ceb5700e5..c555f771a48 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -1523,49 +1523,6 @@ static void WM_OT_splash(wmOperatorType *ot) /* ***************** Search menu ************************* */ -static void operator_call_cb(struct bContext *C, void *UNUSED(arg1), void *arg2) -{ - wmOperatorType *ot = arg2; - - if (ot) - WM_operator_name_call(C, ot->idname, WM_OP_INVOKE_DEFAULT, NULL); -} - -static void operator_search_cb(const struct bContext *C, void *UNUSED(arg), const char *str, uiSearchItems *items) -{ - GHashIterator *iter = WM_operatortype_iter(); - - for (; !BLI_ghashIterator_isDone(iter); BLI_ghashIterator_step(iter)) { - wmOperatorType *ot = BLI_ghashIterator_getValue(iter); - - if ((ot->flag & OPTYPE_INTERNAL) && (G.debug & G_DEBUG_WM) == 0) - continue; - - if (BLI_strcasestr(ot->name, str)) { - if (WM_operator_poll((bContext *)C, ot)) { - char name[256]; - int len = strlen(ot->name); - - /* display name for menu, can hold hotkey */ - BLI_strncpy(name, ot->name, sizeof(name)); - - /* check for hotkey */ - if (len < sizeof(name) - 6) { - if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, - &name[len + 1], sizeof(name) - len - 1)) - { - name[len] = '|'; - } - } - - if (0 == uiSearchItemAdd(items, name, ot, 0)) - break; - } - } - } - BLI_ghashIterator_free(iter); -} - static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_op)) { static char search[256] = ""; @@ -1578,7 +1535,7 @@ static uiBlock *wm_block_search_menu(bContext *C, ARegion *ar, void *UNUSED(arg_ uiBlockSetFlag(block, UI_BLOCK_LOOP | UI_BLOCK_MOVEMOUSE_QUIT | UI_BLOCK_SEARCH_MENU); but = uiDefSearchBut(block, search, 0, ICON_VIEWZOOM, sizeof(search), 10, 10, 9 * UI_UNIT_X, UI_UNIT_Y, 0, 0, ""); - uiButSetSearchFunc(but, operator_search_cb, NULL, operator_call_cb, NULL); + uiOperatorSearch_But(but); /* fake button, it holds space for search items */ uiDefBut(block, LABEL, 0, "", 10, 10 - uiSearchBoxHeight(), uiSearchBoxWidth(), uiSearchBoxHeight(), NULL, 0, 0, 0, 0, NULL);