diff options
author | Philipp Oeser <info@graphics-engineer.com> | 2018-12-28 16:57:34 +0300 |
---|---|---|
committer | Philipp Oeser <info@graphics-engineer.com> | 2019-01-08 16:47:05 +0300 |
commit | 22474062b1afb11634a1579ab5c5ce92a5beea85 (patch) | |
tree | 56e2f62aadc3e727c4bc45d06bacb952676428a0 /source/blender/editors/interface | |
parent | 24a84c4742576ab1ade54933ae95c1cb983a5f92 (diff) |
Fix T58479: Quick Favorites Lets you add multiple of the same item
Reviewers: brecht
Maniphest Tasks: T58479
Differential Revision: https://developer.blender.org/D4135
Diffstat (limited to 'source/blender/editors/interface')
-rw-r--r-- | source/blender/editors/interface/interface_context_menu.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/source/blender/editors/interface/interface_context_menu.c b/source/blender/editors/interface/interface_context_menu.c index fc7d3293333..5ac45580b18 100644 --- a/source/blender/editors/interface/interface_context_menu.c +++ b/source/blender/editors/interface/interface_context_menu.c @@ -691,13 +691,7 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) uiBlock *block = uiLayoutGetBlock(layout); const int w = uiLayoutGetWidth(layout); uiBut *but2; - - but2 = uiDefIconTextBut( - block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL, - CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Quick Favorites"), - 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, - "Add to a user defined context menu (stored in the user preferences)"); - UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, NULL); + bool item_found = false; uint um_array_len; bUserMenu **um_array = ED_screen_user_menus_find(C, &um_array_len); @@ -709,14 +703,24 @@ bool ui_popup_context_menu_for_button(bContext *C, uiBut *but) bUserMenuItem *umi = ui_but_user_menu_find(C, but, um); if (umi != NULL) { but2 = uiDefIconTextBut( - block, UI_BTYPE_BUT, 0, ICON_BLANK1, + block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Remove from Quick Favorites"), 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, ""); UI_but_func_set(but2, popup_user_menu_remove_func, um, umi); + item_found = true; } } MEM_freeN(um_array); + if (!item_found) { + but2 = uiDefIconTextBut( + block, UI_BTYPE_BUT, 0, ICON_MENU_PANEL, + CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Add to Quick Favorites"), + 0, 0, w, UI_UNIT_Y, NULL, 0, 0, 0, 0, + "Add to a user defined context menu (stored in the user preferences)"); + UI_but_func_set(but2, popup_user_menu_add_or_replace_func, but, NULL); + } + uiItemS(layout); } |