Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2010-02-27 18:28:34 +0300
committerCampbell Barton <ideasman42@gmail.com>2010-02-27 18:28:34 +0300
commitc76b6fcb06c45f0e018a6c8a892f380099a2371a (patch)
tree5dd51522c47dcdfeede000fe1d7a9c95844bdbca /source/blender/python/intern/bpy_rna_callback.c
parent3dd3e7321eee426112859bfc2427749c2f6113e6 (diff)
utility function pyrna_enum_value_from_id for getting the enum from a string and raising an error if its invalid.
Diffstat (limited to 'source/blender/python/intern/bpy_rna_callback.c')
-rw-r--r--source/blender/python/intern/bpy_rna_callback.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/source/blender/python/intern/bpy_rna_callback.c b/source/blender/python/intern/bpy_rna_callback.c
index dda3671ebeb..ee0c5cb143b 100644
--- a/source/blender/python/intern/bpy_rna_callback.c
+++ b/source/blender/python/intern/bpy_rna_callback.c
@@ -66,19 +66,18 @@ PyObject *pyrna_callback_add(BPy_StructRNA *self, PyObject *args)
void *handle;
PyObject *cb_func, *cb_args;
- char *cb_type= NULL;
- int cb_type_enum;
+ char *cb_event_str= NULL;
+ int cb_event;
- if (!PyArg_ParseTuple(args, "OO|s:callback_add", &cb_func, &cb_args, &cb_type))
+ if (!PyArg_ParseTuple(args, "OO|s:bpy_struct.callback_add", &cb_func, &cb_args, &cb_event_str))
return NULL;
if(RNA_struct_is_a(self->ptr.type, &RNA_Region)) {
- if(RNA_enum_value_from_id(region_draw_mode_items, cb_type, &cb_type_enum)==0) {
- PyErr_SetString(PyExc_ValueError, "callbcak_add(): enum invalid type");
+
+ if(pyrna_enum_value_from_id(region_draw_mode_items, cb_event_str, &cb_event, "bpy_struct.callback_add()") < 0)
return NULL;
- }
- handle= ED_region_draw_cb_activate(((ARegion *)self->ptr.data)->type, cb_region_draw, (void *)args, cb_type_enum);
+ handle= ED_region_draw_cb_activate(((ARegion *)self->ptr.data)->type, cb_region_draw, (void *)args, cb_event);
Py_INCREF(args);
}
else {