I'm wrapping a custom GtkTreeModel written in C for use in Python. I'm using
SWIG with typemaps. My approach has been to implement a gtk.GenericTreeModel
in python which calls the various C functions. I'm running into trouble with
the on_get_column_type() method. The GenericTreeModel appears to want me to
return a python type (string, long, etc) while the C routine returns a
GType. I thought I could compare the GType returned from C with the Python
GTypes (gobject.TYPE_UINT for example). I first tried treating the C GType
as an int. I get 28 for G_TYPE_UINT in python, but can't for the life of me
figure out how to test that 28 == gobject.TYPE_UINT (I can't figure out how
to get 28 out of the python gobject.TYPE_UINT - but I know it's there since
printing it displays "<GType guint (28)>". I started looking at how to use
pygobject to properly convert a C GType into a python GType. I am now trying
to use pyg_type_wrapper_new(). It segfaults when passed G_TYPE_UINT. The
generated code looks like this:
printf("converting gtype (G_TYPE_UINT): %d to python object\n",
G_TYPE_UINT);
resultobj = pyg_type_wrapper_new(G_TYPE_UINT);
printf("python object @ %p\n", resultobj);
The above example hardcodes the C GType. I did this after the returned GType
from the C get_column_type() function caused pyg_type_wrapper_new() to
segfault. It still segfaults with just G_TYPE_UINT passed to it with the
following output:
converting gtype (G_TYPE_UINT): 28 to python object
Segmentation fault (core dumped)
So I clearly don't understand GTypes and how to properly pass them back and
forth between Python and C. Can someone please explain to me what I'm doing
wrong?
Thanks,
--
Darren Hart
_______________________________________________
pygtk mailing list [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/