summaryrefslogtreecommitdiff
path: root/gi/gimodule.c
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-11-22 17:25:04 +0100
committerTomeu Vizoso <tomeu@sugarlabs.org>2009-11-22 17:25:25 +0100
commit1dc62a998dd8d2a0a397f8309011a8d79cb56034 (patch)
tree328c816eb66a834327d8f83ce6aac5d3223d3617 /gi/gimodule.c
parent6ccf58afcf58e118903ced0135f0fe69b00e09ad (diff)
downloadpygobject-1dc62a998dd8d2a0a397f8309011a8d79cb56034.tar.gz
Register interfaces
https://bugzilla.gnome.org/show_bug.cgi?id=601181
Diffstat (limited to 'gi/gimodule.c')
-rw-r--r--gi/gimodule.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/gi/gimodule.c b/gi/gimodule.c
index d9ee17bd..bc5f9cae 100644
--- a/gi/gimodule.c
+++ b/gi/gimodule.c
@@ -97,12 +97,45 @@ _wrap_pyg_set_object_has_new_constructor (PyObject *self,
Py_RETURN_NONE;
}
+static void
+initialize_interface (GTypeInterface *iface, PyTypeObject *pytype)
+{
+ // pygobject prints a warning if interface_init is NULL
+}
+
+static PyObject *
+_wrap_pyg_register_interface_info(PyObject *self, PyObject *args)
+{
+ PyObject *py_g_type;
+ GType g_type;
+ GInterfaceInfo *info;
+
+ if (!PyArg_ParseTuple(args, "O!:register_interface_info",
+ &PyGTypeWrapper_Type, &py_g_type)) {
+ return NULL;
+ }
+
+ g_type = pyg_type_from_object(py_g_type);
+ if (!g_type_is_a(g_type, G_TYPE_INTERFACE)) {
+ PyErr_SetString(PyExc_TypeError, "must be an interface");
+ return NULL;
+ }
+
+ info = g_new0(GInterfaceInfo, 1);
+ info->interface_init = (GInterfaceInitFunc) initialize_interface;
+
+ pyg_register_interface_info(g_type, info);
+
+ Py_RETURN_NONE;
+}
+
static PyMethodDef _pygi_functions[] = {
{ "enum_add", (PyCFunction)_wrap_pyg_enum_add, METH_VARARGS | METH_KEYWORDS },
{ "flags_add", (PyCFunction)_wrap_pyg_flags_add, METH_VARARGS | METH_KEYWORDS },
{ "set_object_has_new_constructor", (PyCFunction)_wrap_pyg_set_object_has_new_constructor, METH_VARARGS | METH_KEYWORDS },
+ { "register_interface_info", (PyCFunction)_wrap_pyg_register_interface_info, METH_VARARGS },
{ NULL, NULL, 0 }
};