After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 735693 - Use introspection annotations for type hints to GObject.Object.emit()
Use introspection annotations for type hints to GObject.Object.emit()
Status: RESOLVED OBSOLETE
Product: pygobject
Classification: Bindings
Component: introspection
unspecified
Other Linux
: Normal normal
: ---
Assigned To: Nobody's working on this now (help wanted and appreciated)
Python bindings maintainers
Depends on:
Blocks:
 
 
Reported: 2014-08-29 20:26 UTC by Simon Feltman
Modified: 2018-01-10 20:45 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Simon Feltman 2014-08-29 20:26:26 UTC
Signal emission doesn't make use of introspection which can cause problems for aliased types. For example Gtk.Overlay:get-child-position annotates the allocation argument as CairoRectangleInt, but the signals meta-data says it is a GdkRectangle. These are GdkRectangle is a typedef of CairoRectangleInt but has a unique GType, see bug 683463.

The problem is we cannot construct a Gdk.Rectangle() and pass it as an argument to emit() without getting a type conversion error:

>>> from gi.repository import GObject, Gtk, Gdk
>>> overlay = Gtk.Overlay()
>>> allocation = Gdk.Rectangle()
>>> overlay.emit('get-child-position', None, allocation)
TypeError: could not convert type RectangleInt to GdkRectangle required for parameter 1


Note that Gdk.Rectangle is just really a cairo rectangle:

>>> Gdk.Rectangle
gi.repository.cairo.RectangleInt


A hacky workaround is to sub-class Gdk.Rectangle and set the gtype explicitly:

class MyRect(Gdk.Rectangle):
    __gtype__ = GObject.type_from_name('GdkRectangle')
Comment 1 Simon Feltman 2014-08-29 20:57:10 UTC
We also need to take into account output arguments which should be returned from emit(). See also bug 644927.
Comment 2 Dan Yeaw 2017-07-07 19:16:30 UTC
Is there a plan create a more permanent solution for this? This is a huge issue still when porting from pygtk. I spent hours trying to resolve this issue prior to finding the hacky workaround shown above.
Comment 3 Dan Yeaw 2017-07-16 00:45:34 UTC
So after looking at this further, I don't think this is still an issue. I recommend closing.
Comment 4 GNOME Infrastructure Team 2018-01-10 20:45:48 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to GNOME's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.gnome.org/GNOME/pygobject/issues/82.