[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [52709] trunk/blender/source/blender: There was no way of knowing what ID type a property comes from by the tooltip , (since copying the Data-Path doesn't include the ID the user had to guess ).
Campbell Barton
ideasman42 at gmail.com
Sun Dec 2 08:13:21 CET 2012
Revision: 52709
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=52709
Author: campbellbarton
Date: 2012-12-02 07:13:19 +0000 (Sun, 02 Dec 2012)
Log Message:
-----------
There was no way of knowing what ID type a property comes from by the tooltip, (since copying the Data-Path doesn't include the ID the user had to guess).
Now include the full python path to the property in the tool-tip.
Modified Paths:
--------------
trunk/blender/source/blender/editors/interface/interface_regions.c
trunk/blender/source/blender/editors/space_console/space_console.c
trunk/blender/source/blender/makesrna/RNA_access.h
trunk/blender/source/blender/makesrna/intern/rna_access.c
Modified: trunk/blender/source/blender/editors/interface/interface_regions.c
===================================================================
--- trunk/blender/source/blender/editors/interface/interface_regions.c 2012-12-02 05:27:03 UTC (rev 52708)
+++ trunk/blender/source/blender/editors/interface/interface_regions.c 2012-12-02 07:13:19 UTC (rev 52709)
@@ -46,6 +46,7 @@
#include "BKE_context.h"
#include "BKE_screen.h"
+#include "BKE_idcode.h"
#include "BKE_global.h"
#include "WM_api.h"
@@ -618,7 +619,8 @@
if (rna_prop.strinfo) {
/* Struct and prop */
BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]),
- TIP_("Python: %s.%s"), rna_struct.strinfo, rna_prop.strinfo);
+ TIP_("Python: %s.%s"),
+ rna_struct.strinfo, rna_prop.strinfo);
}
else {
/* Only struct (e.g. menus) */
@@ -627,6 +629,43 @@
}
data->color_id[data->totline] = UI_TIP_LC_PYTHON;
data->totline++;
+
+ if (but->rnapoin.id.data) {
+ /* this could get its own 'BUT_GET_...' type */
+ PointerRNA *ptr = &but->rnapoin;
+ PropertyRNA *prop = but->rnaprop;
+ ID *id = ptr->id.data;
+
+ char name_escape[(sizeof(id->name) - 2) * 2];
+ char *id_path;
+ char *data_path = NULL;
+
+ BLI_strescape(name_escape, id->name + 2, sizeof(name_escape));
+
+ /* never fails */
+ id_path = RNA_path_from_ID_python(id);
+
+ if (ptr->id.data && ptr->data && prop) {
+ data_path = RNA_path_from_ID_to_property(ptr, prop);
+ }
+
+ if (data_path) {
+ BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]),
+ "%s.%s", /* no need to translate */
+ id_path, data_path);
+ MEM_freeN(data_path);
+ }
+ else if (prop) {
+ /* can't find the path. be explicit in our ignorance "..." */
+ BLI_snprintf(data->lines[data->totline], sizeof(data->lines[0]),
+ "%s ... %s", /* no need to translate */
+ id_path, rna_prop.strinfo ? rna_prop.strinfo : RNA_property_identifier(prop));
+ }
+ MEM_freeN(id_path);
+
+ data->color_id[data->totline] = UI_TIP_LC_PYTHON;
+ data->totline++;
+ }
}
#endif
Modified: trunk/blender/source/blender/editors/space_console/space_console.c
===================================================================
--- trunk/blender/source/blender/editors/space_console/space_console.c 2012-12-02 05:27:03 UTC (rev 52708)
+++ trunk/blender/source/blender/editors/space_console/space_console.c 2012-12-02 07:13:19 UTC (rev 52709)
@@ -170,16 +170,13 @@
static void id_drop_copy(wmDrag *drag, wmDropBox *drop)
{
- char text[64];
+ char *text;
ID *id = drag->poin;
- char id_esc[(sizeof(id->name) - 2) * 2];
- BLI_strescape(id_esc, id->name + 2, sizeof(id_esc));
-
- BLI_snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc);
-
/* copy drag path to properties */
+ text = RNA_path_from_ID_python(id);
RNA_string_set(drop->ptr, "text", text);
+ MEM_freeN(text);
}
static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(event))
Modified: trunk/blender/source/blender/makesrna/RNA_access.h
===================================================================
--- trunk/blender/source/blender/makesrna/RNA_access.h 2012-12-02 05:27:03 UTC (rev 52708)
+++ trunk/blender/source/blender/makesrna/RNA_access.h 2012-12-02 07:13:19 UTC (rev 52709)
@@ -862,6 +862,7 @@
char *RNA_path_from_ID_to_struct(PointerRNA *ptr);
char *RNA_path_from_ID_to_property(PointerRNA *ptr, PropertyRNA *prop);
+char *RNA_path_from_ID_python(struct ID *id);
/* Quick name based property access
*
Modified: trunk/blender/source/blender/makesrna/intern/rna_access.c
===================================================================
--- trunk/blender/source/blender/makesrna/intern/rna_access.c 2012-12-02 05:27:03 UTC (rev 52708)
+++ trunk/blender/source/blender/makesrna/intern/rna_access.c 2012-12-02 07:13:19 UTC (rev 52709)
@@ -4163,6 +4163,19 @@
return path;
}
+/**
+ * Get the ID as a python representation, eg:
+ * bpy.data.foo["bar"]
+ */
+char *RNA_path_from_ID_python(ID *id)
+{
+ char id_esc[(sizeof(id->name) - 2) * 2];
+
+ BLI_strescape(id_esc, id->name + 2, sizeof(id_esc));
+
+ return BLI_sprintfN("bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc);
+}
+
/* Quick name based property access */
int RNA_boolean_get(PointerRNA *ptr, const char *name)
More information about the Bf-blender-cvs
mailing list