diff options
author | Campbell Barton <ideasman42@gmail.com> | 2011-10-23 08:13:56 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2011-10-23 08:13:56 +0400 |
commit | 8e2bc6cdbcb47c5f2e4714241fde0ac970f6f58e (patch) | |
tree | 6c588cd22b7c40e31d3715eecc96a699d7343334 /source/blender/editors/interface/interface_handlers.c | |
parent | 29417887d7e78f31cbefc5d86c156237484e837a (diff) |
Context menu 'Edit Source' operator no longer needs to be enabled as a build option, improved this so the python file:line lookups are only done when the operator runs (previously this was done for every button, every draw when the build option was enabled).
Perhaps this should be hidden when not running with --debug, easy to change.
Diffstat (limited to 'source/blender/editors/interface/interface_handlers.c')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 32c4ec21e13..79080eb5f3b 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4443,16 +4443,8 @@ static int ui_but_menu(bContext *C, uiBut *but) } } -#ifdef WITH_PYTHON_UI_INFO - if (but->py_dbg_ln != -1) { - PointerRNA ptr_props; - - WM_operator_properties_create(&ptr_props, "WM_OT_text_edit"); - RNA_string_set(&ptr_props, "filepath", but->py_dbg_fn); - RNA_int_set(&ptr_props, "line", but->py_dbg_ln); - uiItemFullO(layout, "WM_OT_text_edit", "Edit Source", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); - } -#endif /* WITH_PYTHON_UI_INFO */ + /* perhaps we should move this into (G.f & G_DEBUG) - campbell */ + uiItemFullO(layout, "UI_OT_editsource", "Edit Source", ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0); uiPupMenuEnd(C, pup); @@ -5146,9 +5138,10 @@ void ui_button_active_free(const bContext *C, uiBut *but) } } -static uiBut *ui_context_rna_button_active(const bContext *C) +/* returns the active button with an optional checking function */ +static uiBut *ui_context_button_active(const bContext *C, int (*but_check_cb)(uiBut *)) { - uiBut *rnabut= NULL; + uiBut *but_found= NULL; ARegion *ar= CTX_wm_region(C); @@ -5166,26 +5159,40 @@ static uiBut *ui_context_rna_button_active(const bContext *C) } } - if(activebut && activebut->rnapoin.data) { + if(activebut && (but_check_cb == NULL || but_check_cb(activebut))) { uiHandleButtonData *data= activebut->active; - rnabut= activebut; + but_found= activebut; /* recurse into opened menu, like colorpicker case */ if(data && data->menu && (ar != data->menu->region)) { ar = data->menu->region; } else { - return rnabut; + return but_found; } } else { /* no active button */ - return rnabut; + return but_found; } } - return rnabut; + return but_found; +} + +static int ui_context_rna_button_active_test(uiBut *but) +{ + return (but->rnapoin.data != NULL); +} +static uiBut *ui_context_rna_button_active(const bContext *C) +{ + return ui_context_button_active(C, ui_context_rna_button_active_test); +} + +uiBut *uiContextActiveButton(const struct bContext *C) +{ + return ui_context_button_active(C, NULL); } /* helper function for insert keyframe, reset to default, etc operators */ |