diff options
author | Tomeu Vizoso <tomeu@sugarlabs.org> | 2010-04-22 19:53:06 +0200 |
---|---|---|
committer | Tomeu Vizoso <tomeu@sugarlabs.org> | 2010-04-22 19:53:58 +0200 |
commit | 391640b30ede50af3667b1019edb72bd79f2c68c (patch) | |
tree | df2942d85e02fac29ca1b256b318b3e573bccd00 /gi/pygi-argument.c | |
parent | 89704f60ddae0c81f1383d86491ef2785590a353 (diff) | |
download | pygobject-391640b30ede50af3667b1019edb72bd79f2c68c.tar.gz |
Add support for enums without GType
https://bugzilla.gnome.org/show_bug.cgi?id=616520
Diffstat (limited to 'gi/pygi-argument.c')
-rw-r--r-- | gi/pygi-argument.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/gi/pygi-argument.c b/gi/pygi-argument.c index 4bedc825..8244659a 100644 --- a/gi/pygi-argument.c +++ b/gi/pygi-argument.c @@ -1510,7 +1510,27 @@ _pygi_argument_to_object (GArgument *arg, type = g_registered_type_info_get_g_type((GIRegisteredTypeInfo *)info); - if (info_type == GI_INFO_TYPE_ENUM) { + if (type == G_TYPE_NONE) { + /* An enum with a GType of None is an enum without GType */ + PyObject *py_type = _pygi_type_import_by_gi_info(info); + PyObject *py_args = NULL; + + if (!py_type) + return NULL; + + py_args = PyTuple_New(1); + if (PyTuple_SetItem(py_args, 0, PyLong_FromLong(arg->v_long)) != 0) { + Py_DECREF(py_args); + Py_DECREF(py_type); + return NULL; + } + + object = PyObject_CallFunction(py_type, "l", arg->v_long); + + Py_DECREF(py_args); + Py_DECREF(py_type); + + } else if (info_type == GI_INFO_TYPE_ENUM) { object = pyg_enum_from_gtype(type, arg->v_long); } else { object = pyg_flags_from_gtype(type, arg->v_long); |