From e886c978845ddffff0e39ca1cf33b31c467aab2c Mon Sep 17 00:00:00 2001 From: Johan Dahlin Date: Sat, 10 Apr 2004 22:03:46 +0000 Subject: New function. (pygobject_lookup_class): Modify so we're not traversing * pygobject.c (pygobject_new_with_interfaces): New function. (pygobject_lookup_class): Modify so we're not traversing parents for unknown types but instead creating new types when they're not registered. We're also using pygobject_new_with_interfaces so interfaces gets attached correctly. Partial fix for bug 129032 * gobjectmodule.c: Add quark and attach the PyTypeObject for GInterfaces. * pygobject-private.h: Make PyGInterface_Type and pyginterface_type_key public --- gobject/gobjectmodule.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'gobject/gobjectmodule.c') diff --git a/gobject/gobjectmodule.c b/gobject/gobjectmodule.c index bea061e..5bf7242 100644 --- a/gobject/gobjectmodule.c +++ b/gobject/gobjectmodule.c @@ -27,6 +27,8 @@ #include "pygobject-private.h" static PyObject *gerror_exc = NULL; +static const gchar *pyginterface_type_id = "PyGInterface::type"; +GQuark pyginterface_type_key = 0; static void pyg_flags_add_constants(PyObject *module, GType flags_type, const gchar *strip_prefix); @@ -234,7 +236,7 @@ pyg_interface_init(PyObject *self, PyObject *args, PyObject *kwargs) return -1; } -static PyTypeObject PyGInterface_Type = { +PyTypeObject PyGInterface_Type = { PyObject_HEAD_INIT(NULL) 0, /* ob_size */ "gobject.GInterface", /* tp_name */ @@ -300,6 +302,9 @@ pyg_register_interface(PyObject *dict, const gchar *class_name, type->ob_type = &PyType_Type; type->tp_base = &PyGInterface_Type; + if (!pyginterface_type_key) + pyginterface_type_key = g_quark_from_static_string(pyginterface_type_id); + if (PyType_Ready(type) < 0) { g_warning("could not ready `%s'", type->tp_name); return; @@ -311,7 +316,10 @@ pyg_register_interface(PyObject *dict, const gchar *class_name, Py_DECREF(o); } + g_type_set_qdata(gtype, pyginterface_type_key, type); + PyDict_SetItemString(dict, (char *)class_name, (PyObject *)type); + } /* -------------- GMainContext objects ---------------------------- */ -- cgit