diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-09-09 15:10:28 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2009-09-09 15:10:28 +0400 |
commit | 8878c30b9b032f1a630c13c5ebb260cb9029ce3c (patch) | |
tree | cc0378b444e5b7069eb5c094f31b375a038437c7 /source | |
parent | b9f1117336e17438cab1db6174f7cf66eebc6b3e (diff) |
2.5: WM_menu_invoke now uses the first enum property it can find,
if no enum property named "type" is available.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index c7011777dbf..ca2fbe23c3e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -448,13 +448,24 @@ void WM_operator_properties_free(PointerRNA *ptr) /* ************ default op callbacks, exported *********** */ /* invoke callback, uses enum property named "type" */ -/* only weak thing is the fixed property name... */ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) { - PropertyRNA *prop= RNA_struct_find_property(op->ptr, "type"); + PropertyRNA *prop; uiPopupMenu *pup; uiLayout *layout; + prop= RNA_struct_find_property(op->ptr, "type"); + + if(!prop) { + RNA_STRUCT_BEGIN(op->ptr, findprop) { + if(RNA_property_type(findprop) == PROP_ENUM) { + prop= findprop; + break; + } + } + RNA_STRUCT_END; + } + if(prop==NULL) { printf("WM_menu_invoke: %s has no \"type\" enum property\n", op->type->idname); } @@ -464,7 +475,7 @@ int WM_menu_invoke(bContext *C, wmOperator *op, wmEvent *event) else { pup= uiPupMenuBegin(C, op->type->name, 0); layout= uiPupMenuLayout(pup); - uiItemsEnumO(layout, op->type->idname, "type"); + uiItemsEnumO(layout, op->type->idname, (char*)RNA_property_identifier(prop)); uiPupMenuEnd(C, pup); } |