Use introspection annotations for type hints to GObject.Object.emit()
Submitted by Simon Feltman
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:
A hacky workaround is to sub-class Gdk.Rectangle and set the gtype explicitly:
class MyRect(Gdk.Rectangle): gtype = GObject.type_from_name('GdkRectangle')