Fix g_irepository_find_by_gtype() for GDK_TYPE_RECTANGLE
authorPavel Holejsovsky <pholejs@src.gnome.org>
Fri, 19 Aug 2011 19:20:10 +0000 (21:20 +0200)
committerPavel Holejsovsky <pholejs@src.gnome.org>
Thu, 25 Aug 2011 19:22:25 +0000 (21:22 +0200)
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

girepository/gitypelib.c

index 2e5b0e1..dcc2651 100644 (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