Page MenuHome
Paste P301

D763 alternative patch
ActivePublic

Authored by Campbell Barton (campbellbarton) on Dec 18 2015, 7:05 AM.
diff --git a/source/blender/editors/interface/interface_handlers.c b/source/blender/editors/interface/interface_handlers.c
index 9a85f5b..bc58a71 100644
--- a/source/blender/editors/interface/interface_handlers.c
+++ b/source/blender/editors/interface/interface_handlers.c
@@ -6554,6 +6554,33 @@ void ui_panel_menu(bContext *C, ARegion *ar, Panel *pa)
UI_popup_menu_end(C, pup);
}
+static void ui_menu_scripting(bContext *UNUSED(C), uiLayout *layout, void *arg)
+{
+ uiBut *but = arg;
+
+ if (!ui_block_is_menu(but->block)) {
+ uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
+ }
+
+ uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"),
+ ICON_NONE, "UI_OT_copy_data_path_button", "full", 0);
+ uiItemBooleanO(layout, CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Full Data Path"),
+ ICON_NONE, "UI_OT_copy_data_path_button", "full", 1);
+
+ if (but->rnapoin.data && but->rnaprop) {
+ PointerRNA ptr_props;
+ char buf[512];
+
+ BLI_snprintf(buf, sizeof(buf), "%s.%s",
+ RNA_struct_identifier(but->rnapoin.type), RNA_property_identifier(but->rnaprop));
+
+ WM_operator_properties_create(&ptr_props, "WM_OT_doc_view");
+ RNA_string_set(&ptr_props, "doc_id", buf);
+ uiItemFullO(layout, "WM_OT_doc_view", CTX_IFACE_(BLF_I18NCONTEXT_OPERATOR_DEFAULT, "Online Python Reference"),
+ ICON_NONE, ptr_props.data, WM_OP_EXEC_DEFAULT, 0);
+ }
+}
+
static bool ui_but_menu(bContext *C, uiBut *but)
{
uiPopupMenu *pup;
@@ -6739,14 +6766,16 @@ static bool ui_but_menu(bContext *C, uiBut *but)
ICON_NONE, "UI_OT_unset_property_button");
}
- uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy Data Path"),
- ICON_NONE, "UI_OT_copy_data_path_button");
uiItemO(layout, CTX_IFACE_(BLT_I18NCONTEXT_OPERATOR_DEFAULT, "Copy To Selected"),
ICON_NONE, "UI_OT_copy_to_selected_button");
uiItemS(layout);
}
+ /* Scripting submenu */
+ uiItemMenuF(layout, IFACE_("Scripting"), ICON_NONE, ui_menu_scripting, but);
+ uiItemS(layout);
+
/* Operator buttons */
if (but->optype) {
uiBlock *block = uiLayoutGetBlock(layout);
@@ -6827,10 +6856,6 @@ static bool ui_but_menu(bContext *C, uiBut *but)
}
}
- /* perhaps we should move this into (G.debug & G_DEBUG) - campbell */
- if (ui_block_is_menu(but->block) == false) {
- uiItemFullO(layout, "UI_OT_editsource", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
- }
uiItemFullO(layout, "UI_OT_edittranslation_init", NULL, ICON_NONE, NULL, WM_OP_INVOKE_DEFAULT, 0);
UI_popup_menu_end(C, pup);
diff --git a/source/blender/editors/interface/interface_ops.c b/source/blender/editors/interface/interface_ops.c
index 6ac657f..da3bc83 100644
--- a/source/blender/editors/interface/interface_ops.c
+++ b/source/blender/editors/interface/interface_ops.c
@@ -113,7 +113,7 @@ static int copy_data_path_button_poll(bContext *C)
return 0;
}
-static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op))
+static int copy_data_path_button_exec(bContext *C, wmOperator *op)
{
PointerRNA ptr;
PropertyRNA *prop;
@@ -124,7 +124,13 @@ static int copy_data_path_button_exec(bContext *C, wmOperator *UNUSED(op))
UI_context_active_but_prop_get(C, &ptr, &prop, &index);
if (ptr.id.data && ptr.data && prop) {
- path = RNA_path_from_ID_to_property(&ptr, prop);
+ const bool full = RNA_boolean_get(op->ptr, "full");
+ if (full) {
+ path = RNA_path_full_property_py(&ptr, prop, index);
+ }
+ else {
+ path = RNA_path_from_ID_to_property(&ptr, prop);
+ }
if (path) {
WM_clipboard_text_set(path, false);
@@ -149,6 +155,9 @@ static void UI_OT_copy_data_path_button(wmOperatorType *ot)
/* flags */
ot->flag = OPTYPE_REGISTER;
+
+ /* properties */
+ RNA_def_boolean(ot->srna, "full", 0, "Full", "Copy the full RNA data path for this property to the clipboard");
}
/* Reset to Default Values Button Operator ------------------------ */

Event Timeline

Campbell Barton (campbellbarton) changed the title of this paste from untitled to D763 alternative patch.
Campbell Barton (campbellbarton) updated the paste's language from autodetect to autodetect.