diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-11-26 01:59:14 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-11-26 02:00:24 +0400 |
commit | 02f90c000115d5d2ab330005e20d02419defe35a (patch) | |
tree | 932763725edb3642e3e3da0905e02676f42a54e8 /source/blender/windowmanager | |
parent | 07bde9e797c73a0cdbeef315755874ff711a6414 (diff) |
User Interface: don't show macro args in tooltips
was often making much too big strings to show in a tip.
Diffstat (limited to 'source/blender/windowmanager')
-rw-r--r-- | source/blender/windowmanager/WM_api.h | 6 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_event_system.c | 8 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 16 |
3 files changed, 19 insertions, 11 deletions
diff --git a/source/blender/windowmanager/WM_api.h b/source/blender/windowmanager/WM_api.h index 507202b9116..0e202fda9ab 100644 --- a/source/blender/windowmanager/WM_api.h +++ b/source/blender/windowmanager/WM_api.h @@ -272,9 +272,11 @@ bool WM_operator_last_properties_store(struct wmOperator *op); /* operator as a python command (resultuing string must be freed) */ -char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, const bool all_args, +char *WM_operator_pystring_ex(struct bContext *C, struct wmOperator *op, + const bool all_args, const bool macro_args, struct wmOperatorType *ot, struct PointerRNA *opptr); -char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, const bool all_args); +char *WM_operator_pystring(struct bContext *C, struct wmOperator *op, + const bool all_args, const bool macro_args); char *WM_prop_pystring_assign(struct bContext *C, struct PointerRNA *ptr, struct PropertyRNA *prop, int index); void WM_operator_bl_idname(char *to, const char *from); void WM_operator_py_idname(char *to, const char *from); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index 2f959c926e0..ef1f6c7a34a 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -491,8 +491,8 @@ int WM_operator_poll_context(bContext *C, wmOperatorType *ot, short context) static void wm_operator_print(bContext *C, wmOperator *op) { /* context is needed for enum function */ - char *buf = WM_operator_pystring(C, op, false); - printf("%s\n", buf); + char *buf = WM_operator_pystring(C, op, false, true); + puts(buf); MEM_freeN(buf); } @@ -626,7 +626,7 @@ static void wm_operator_reports(bContext *C, wmOperator *op, int retval, int cal if (op->type->flag & OPTYPE_REGISTER) { if (G.background == 0) { /* ends up printing these in the terminal, gets annoying */ /* Report the python string representation of the operator */ - char *buf = WM_operator_pystring(C, op, false); + char *buf = WM_operator_pystring(C, op, false, true); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); MEM_freeN(buf); } @@ -660,7 +660,7 @@ static void wm_operator_finished(bContext *C, wmOperator *op, int repeat) if (repeat == 0) { if (G.debug & G_DEBUG_WM) { - char *buf = WM_operator_pystring(C, op, false); + char *buf = WM_operator_pystring(C, op, false, true); BKE_report(CTX_wm_reports(C), RPT_OPERATOR, buf); MEM_freeN(buf); } diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index 33b1a98b710..a9c7610bf8a 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -528,7 +528,8 @@ void WM_operator_bl_idname(char *to, const char *from) * * Note: both op and opptr may be NULL (op is only used for macro operators). */ -char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, wmOperatorType *ot, PointerRNA *opptr) +char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, const bool macro_args, + wmOperatorType *ot, PointerRNA *opptr) { char idname_py[OP_MAX_TYPENAME]; @@ -547,7 +548,10 @@ char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, /* Special handling for macros, else we only get default values in this case... */ wmOperator *opm; bool first_op = true; - for (opm = op->macro.first; opm; opm = opm->next) { + + opm = macro_args ? op->macro.first : NULL; + + for (; opm; opm = opm->next) { PointerRNA *opmptr = opm->ptr; PointerRNA opmptr_default; if (opmptr == NULL) { @@ -573,13 +577,14 @@ char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, else { /* only to get the orginal props for comparisons */ PointerRNA opptr_default; + const bool macro_args_test = ot->macro.first ? macro_args : true; if (opptr == NULL) { WM_operator_properties_create_ptr(&opptr_default, ot); opptr = &opptr_default; } - cstring_args = RNA_pointer_as_string_keywords(C, opptr, false, all_args, max_prop_length); + cstring_args = RNA_pointer_as_string_keywords(C, opptr, false, all_args, macro_args_test, max_prop_length); BLI_dynstr_append(dynstr, cstring_args); MEM_freeN(cstring_args); @@ -595,9 +600,10 @@ char *WM_operator_pystring_ex(bContext *C, wmOperator *op, const bool all_args, return cstring; } -char *WM_operator_pystring(bContext *C, wmOperator *op, const bool all_args) +char *WM_operator_pystring(bContext *C, wmOperator *op, + const bool all_args, const bool macro_args) { - return WM_operator_pystring_ex(C, op, all_args, op->type, op->ptr); + return WM_operator_pystring_ex(C, op, all_args, macro_args, op->type, op->ptr); } /* return NULL if no match is found */ |