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".
This commit is contained in:
Brecht Van Lommel 2012-05-09 15:54:25 +00:00
parent 686fe23c9d
commit 369f5b79ea
2 changed files with 26 additions and 6 deletions

View File

@ -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");

View File

@ -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;