GNOME Bugzilla – Bug 627545
Cannot access Gdk.EventExpose.area field
Last modified: 2010-11-29 20:00:57 UTC
When trying to access the 'area' field of a Gdk.EventExpose, I get the following error: TypeError: Couldn't find conversion for foreign struct 'cairo.RectangleInt'
Should be relatively straightforward to add support for cairo.RectangleInt in http://git.gnome.org/browse/pygobject/tree/gi/pygi-foreign-cairo.c
I was going to try to provide a patch for this, but I can't really find anything on cairo.RectangleInt, does it even exist?
(In reply to comment #2) > I was going to try to provide a patch for this, but I can't really find > anything on cairo.RectangleInt, does it even exist? I guess it needs to be added to py2cairo first :/
So, what does it need to get this in? We want to move forward with porting gedit.
(In reply to comment #4) > So, what does it need to get this in? We want to move forward with porting > gedit. Someone needs to implement a wrapper for cairo_rectangle_int_t in py2cairo.
Do you know why actually GdkRectangle is mapped to cairo_rectangle_int_t? Also, who is maintaining py2cairo?
Created attachment 173231 [details] [review] add a foreign type for cairo_rectangle_int_t * this is needed because Gdk and Gtk switched from returning a GdkRectangle to a CairoRectangleInt structure * the patch in https://bugs.freedesktop.org/show_bug.cgi?id=31111 is required for pycairo (however there is currently no patch for python 2) * for some reason while this works in pycairo, pygobject is still returning its boxed type. This is most likely due to some annotations in either gobject-introspection or Gtk/Gdk itself. We should most likely fix this by giving precedence to foreign types (as well as removing it from the libraries)
I want to get this working before I create a patch for py2cairo though that should be trivial. Most of this work should apply w/ the exception of what is in py3cairo.h. Also some of the Python 3 isms need to be fixed (e.g. PyLong_FromLong -> PyInt_FromLong)
(In reply to comment #7) > * for some reason while this works in pycairo, pygobject is still > returning its boxed type. This is most likely due to some annotations > in either gobject-introspection or Gtk/Gdk itself. We should most likely > fix this by giving precedence to foreign types (as well as removing it > from the libraries) Can you extend on this? Is it that cairo_rectangle_int_t isn't marked as foreign in the .gir? or that the typedefs are confusing g-i?
Turns out we just don't support GI signal parameters. Still I'm getting a memory error if I do this: from gi.respoitory import cairo cairo.RectangleInt() works fine from the actual cairo module. Must be something wrong with PycairoRectangleIntFromRectangleInt
Created attachment 173281 [details] [review] add a foreign type for cairo_rectangle_int_t and allow it to be caller-allocated * this is needed because Gdk and Gtk switched from returning a GdkRectangle to a CairoRectangleInt structure * the patch in https://bugs.freedesktop.org/show_bug.cgi?id=31111 is required for pycairo (however there is currently no patch for python 2) * added fix for foreign types to allow them to be caller allocated * in order for a type to be caller allocated it must be able to take a NULL and create an empty struct in foreign_struct_from_arg and it must be able to handle GI_TRANFER_EVERYTHING in foreign_struct_to_arg.
I committed this with conditionals. So if you don't have the patch in https://bugs.freedesktop.org/show_bug.cgi?id=31111 this still won't work. I'll close this when the patch in pycairo goes upstream but the maintainer has been slow at responding.
ok, so the pycairo maintainer rejected my patch. I'm going to fix this up to use 4 item sequences instead of a rectangle python object.