Fix g_irepository_find_by_gtype() for GDK_TYPE_RECTANGLE

Complement fix for g-ir-scanner which converts every GdkRectangle
gtype to CairoRectangleInt.  Make sure that C-side API is also aware
of this workaround.

Use case requiring this patch:

When binding implementation wants to get/set property, it can use either
GI-based approach (g_property_info_xxx() funcs), or just GLib facilities.
Although former is probably preferred, there are cases when latter is still
needed (e.g. gstreamer uses dynamic properties, which are not present in the
gir).  In this case, binding implementation queries the type of the propertyb
(using g_object_class_find_property()), it gets GDK_TYPE_RECTANGLE,
and without the patch it cannot map it to any known type.

https://bugzilla.gnome.org/show_bug.cgi?id=655423
This commit is contained in:
Pavel Holejsovsky 2011-08-19 21:20:10 +02:00
parent 13069a377f
commit b8010062b5

View File

@ -208,6 +208,17 @@ g_typelib_get_dir_entry_by_gtype (GITypelib *typelib,
guint i;
const char *c_prefix;
/* There is a corner case regarding GdkRectangle. GdkRectangle is a
boxed type, but it is just an alias to boxed struct
CairoRectangleInt. Scanner automatically converts all references
to GdkRectangle to CairoRectangleInt, so GdkRectangle does not
appear in the typelibs at all, although user code might query it.
So if we get such query, we also change it to lookup of
CairoRectangleInt.
https://bugzilla.gnome.org/show_bug.cgi?id=655423 */
if (!fastpass && !strcmp (gtype_name, "GdkRectangle"))
gtype_name = "CairoRectangleInt";
/* Inside each typelib, we include the "C prefix" which acts as
* a namespace mechanism. For GtkTreeView, the C prefix is Gtk.
* Given the assumption that GTypes for a library also use the