diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-05-09 19:54:25 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2012-05-09 19:54:25 +0400 |
commit | 369f5b79eada9b119d191a730301e977612048c0 (patch) | |
tree | 7eac4d69a31da879ae13401da66863a617138742 /source/blender/editors | |
parent | 686fe23c9dfa11e978f21419fb0ea255b8b9054f (diff) |
Fix #31371: copy data path should be disabled in places where it doesn't work,
like the user preferences.
Also renamed "View Docs" menu entry to "Python Documentation".
Diffstat (limited to 'source/blender/editors')
-rw-r--r-- | source/blender/editors/interface/interface_handlers.c | 4 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_ops.c | 28 |
2 files changed, 26 insertions, 6 deletions
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c index 4cc478aa7c4..94ebdb7c0b9 100644 --- a/source/blender/editors/interface/interface_handlers.c +++ b/source/blender/editors/interface/interface_handlers.c @@ -4557,7 +4557,7 @@ static int ui_but_menu(bContext *C, uiBut *but) WM_operator_properties_create(&ptr_props, "WM_OT_doc_view"); RNA_string_set(&ptr_props, "doc_id", buf); - uiItemFullO(layout, "WM_OT_doc_view", "View Docs", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); + uiItemFullO(layout, "WM_OT_doc_view", "Python Documentation", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); /* XXX inactive option, not for public! */ #if 0 @@ -4573,7 +4573,7 @@ static int ui_but_menu(bContext *C, uiBut *but) WM_operator_properties_create(&ptr_props, "WM_OT_doc_view"); RNA_string_set(&ptr_props, "doc_id", buf); - uiItemFullO(layout, "WM_OT_doc_view", "View Docs", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); + uiItemFullO(layout, "WM_OT_doc_view", "Python Documentation", ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0); WM_operator_properties_create(&ptr_props, "WM_OT_doc_edit"); diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c index aaca5181531..6d2ac388374 100644 --- a/source/blender/editors/interface/interface_ops.c +++ b/source/blender/editors/interface/interface_ops.c @@ -234,12 +234,32 @@ static void UI_OT_reset_default_theme(wmOperatorType *ot) /* Copy Data Path Operator ------------------------ */ +static int copy_data_path_button_poll(bContext *C) +{ + PointerRNA ptr; + PropertyRNA *prop; + char *path; + int index; + + uiContextActiveProperty(C, &ptr, &prop, &index); + + if (ptr.id.data && ptr.data && prop) { + path = RNA_path_from_ID_to_property(&ptr, prop); + + if (path) { + MEM_freeN(path); + return 1; + } + } + + return 0; +} + static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op)) { PointerRNA ptr; PropertyRNA *prop; char *path; - int success = 0; int index; /* try to create driver using property retrieved from UI */ @@ -251,11 +271,11 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op)) if (path) { WM_clipboard_text_set(path, FALSE); MEM_freeN(path); + return OPERATOR_FINISHED; } } - /* since we're just copying, we don't really need to do anything else...*/ - return (success) ? OPERATOR_FINISHED : OPERATOR_CANCELLED; + return OPERATOR_CANCELLED; } static void UI_OT_copy_data_path_button(wmOperatorType *ot) @@ -267,7 +287,7 @@ static void UI_OT_copy_data_path_button(wmOperatorType *ot) /* callbacks */ ot->exec = copy_data_path_button_exec; - //op->poll= ??? // TODO: need to have some valid property before this can be done + ot->poll = copy_data_path_button_poll; /* flags */ ot->flag = OPTYPE_REGISTER; |