diff options
author | Johan Dahlin <johan@src.gnome.org> | 2005-08-26 18:12:20 +0000 |
---|---|---|
committer | Johan Dahlin <johan@src.gnome.org> | 2005-08-26 18:12:20 +0000 |
commit | e99b5c5aeff2b34bb681b8953134c49f71162f10 (patch) | |
tree | f90d1d4a0b64a857f6dac906d0ca8be2ce5bdc86 /gobject | |
parent | bb3fd87e80190212fc0ae4d629d286015a5d2de6 (diff) | |
download | pygobject-e99b5c5aeff2b34bb681b8953134c49f71162f10.tar.gz |
Refactor to allow us to list signals on interfaces.
* gobject/gobjectmodule.c (pyg_signal_list_ids): Refactor to
allow us to list signals on interfaces.
* tests/test_signal.py (TestList): Two new tests.
Diffstat (limited to 'gobject')
-rw-r--r-- | gobject/gobjectmodule.c | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index c4b5e9ce..078201c8 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -1315,12 +1315,12 @@ pyg_signal_list_names (PyObject *self, PyObject *args, PyObject *kwargs) { static char *kwlist[] = { "type", NULL }; PyObject *py_itype, *list; - GObjectClass *class; + GObjectClass *class = NULL; GType itype; guint n; guint *ids; guint i; - + if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:gobject.signal_list_names", kwlist, &py_itype)) @@ -1328,31 +1328,31 @@ pyg_signal_list_names (PyObject *self, PyObject *args, PyObject *kwargs) if ((itype = pyg_type_from_object(py_itype)) == 0) return NULL; - if (!G_TYPE_IS_INSTANTIATABLE(itype) && !G_TYPE_IS_INTERFACE(itype)) { + if (G_TYPE_IS_INSTANTIATABLE(itype)) { + class = g_type_class_ref(itype); + if (!class) { + PyErr_SetString(PyExc_RuntimeError, + "could not get a reference to type class"); + return NULL; + } + } else if (!G_TYPE_IS_INTERFACE(itype)) { PyErr_SetString(PyExc_TypeError, "type must be instantiable or an interface"); return NULL; } - - class = g_type_class_ref(itype); - if (!class) { - PyErr_SetString(PyExc_RuntimeError, - "could not get a reference to type class"); - return NULL; - } + ids = g_signal_list_ids(itype, &n); list = PyTuple_New((gint)n); - if (list == NULL) { - g_free(ids); - g_type_class_unref(class); - return NULL; + if (list != NULL) { + for (i = 0; i < n; i++) + PyTuple_SetItem(list, i, + PyString_FromString(g_signal_name(ids[i]))); } - - for (i = 0; i < n; i++) - PyTuple_SetItem(list, i, PyString_FromString(g_signal_name(ids[i]))); + g_free(ids); - g_type_class_unref(class); + if (class) + g_type_class_unref(class); return list; } |