summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Henstridge <james@daa.com.au>2000-06-24 11:24:51 +0000
committerJames Henstridge <jamesh@src.gnome.org>2000-06-24 11:24:51 +0000
commit5a220e9fd5a4287497356ce2275806b22b10349b (patch)
tree99409728cbecdb63e5366b621f45fff694684473
parentff3ec329a32c72e45209f5bb15c8eff003fdba89 (diff)
downloadpygtk-extension-class-branch.tar.gz
moved this bit of code here, so it can be used in other functions in thisextension-class-branch
2000-06-24 James Henstridge <james@daa.com.au> * gtk/gtkobject-support.c (pygtk_lookup_class): moved this bit of code here, so it can be used in other functions in this file. (pygtk_arg_from_pyobject): perform stricter type checking here. (pygtk_ret_from_pyobject): and here. * gtk/pygtk.h (pygtk_register_{class,wrapper}): add define here. Without it, addon modules were using symbols from _gtkmodule's namespace.
-rw-r--r--ChangeLog11
-rw-r--r--gtk/gtkobject-support.c23
-rw-r--r--gtk/pygtk.h2
3 files changed, 30 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 3ad56600..99f84f35 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2000-06-24 James Henstridge <james@daa.com.au>
+
+ * gtk/gtkobject-support.c (pygtk_lookup_class): moved this bit of
+ code here, so it can be used in other functions in this file.
+ (pygtk_arg_from_pyobject): perform stricter type checking here.
+ (pygtk_ret_from_pyobject): and here.
+
+ * gtk/pygtk.h (pygtk_register_{class,wrapper}): add define here.
+ Without it, addon modules were using symbols from _gtkmodule's
+ namespace.
+
2000-06-23 James Henstridge <james@daa.com.au>
* gtk/gtkgl.defs (use_gdk_font): fix up a few extra function names.
diff --git a/gtk/gtkobject-support.c b/gtk/gtkobject-support.c
index 408cb95e..092094a1 100644
--- a/gtk/gtkobject-support.c
+++ b/gtk/gtkobject-support.c
@@ -136,6 +136,19 @@ pygtk_no_constructor(PyObject *self, PyObject *args)
return NULL;
}
+static PyExtensionClass *
+pygtk_lookup_class(GtkType type)
+{
+ PyExtensionClass *ec;
+
+ /* find the python type for this object. If not found, use parent. */
+ while ((ec = g_hash_table_lookup(class_hash, gtk_type_name(type))) == NULL
+ && type != 0)
+ type = gtk_type_parent(type);
+ g_assert(ec != NULL);
+ return ec;
+}
+
PyObject *
PyGtk_New(GtkObject *obj)
{
@@ -160,10 +173,7 @@ PyGtk_New(GtkObject *obj)
return (PyObject *)self;
}
- type = GTK_OBJECT_TYPE(obj);
- /* find the python type for this object. If not found, use parent. */
- while ((tp = g_hash_table_lookup(class_hash, gtk_type_name(type))) == NULL)
- type = gtk_type_parent(type);
+ tp = (PyTypeObject *)pygtk_lookup_class(GTK_OBJECT_TYPE(obj));
/* can't use PyObject_NEW, as we want to create a slightly larger struct */
self = malloc(sizeof(PyGtk_Object));
@@ -287,6 +297,7 @@ int
pygtk_arg_from_pyobject(GtkArg *arg, PyObject *obj)
{
PyObject *tmp;
+
switch (GTK_FUNDAMENTAL_TYPE(arg->type)) {
case GTK_TYPE_NONE:
case GTK_TYPE_INVALID:
@@ -383,7 +394,7 @@ pygtk_arg_from_pyobject(GtkArg *arg, PyObject *obj)
Py_DECREF(tmp);
break;
case GTK_TYPE_OBJECT:
- if (PyGtk_Check(obj, &PyGtkObject_Type))
+ if (PyGtk_Check(obj, pygtk_lookup_class(arg->type)))
GTK_VALUE_OBJECT(*arg) = PyGtk_Get(obj);
else
return -1;
@@ -704,7 +715,7 @@ pygtk_ret_from_pyobject(GtkArg *ret, PyObject *py_ret)
}
break;
case GTK_TYPE_OBJECT:
- if (PyGtk_Check(py_ret, &PyGtkObject_Type))
+ if (PyGtk_Check(py_ret, pygtk_lookup_class(ret->type)))
*GTK_RETLOC_OBJECT(*ret) = PyGtk_Get(py_ret);
else
*GTK_RETLOC_OBJECT(*ret) = NULL;
diff --git a/gtk/pygtk.h b/gtk/pygtk.h
index a8407b39..28545cfa 100644
--- a/gtk/pygtk.h
+++ b/gtk/pygtk.h
@@ -257,6 +257,8 @@ struct _PyGtk_FunctionStruct *_PyGtk_API;
#define pygtk_register_boxed (_PyGtk_API->register_boxed)
#define pygtk_enum_get_value (_PyGtk_API->enum_get_value)
#define pygtk_flag_get_value (_PyGtk_API->flag_get_value)
+#define pygtk_register_class (_PyGtk_API->register_class)
+#define pygtk_register_wrapper (_PyGtk_API->register_wrapper)
#define pygtk_no_constructor (_PyGtk_API->no_constructor)
/* some variables */