GNOME Bugzilla – Bug 601425
Change GtkIconSize to int in params/return values
Last modified: 2015-02-07 16:55:32 UTC
GtkIconSize is an enum type, but it's explicitly extensible; you can register new icon sizes with gtk_icon_size_register(), and then methods that take a GtkIconSize will accept that value and methods that return a GtkIconSize may return it. (In particular, gtk_icon_size_register() will never return an actual GtkIconSize value.) This patches changes Gtk-2.0.gir to use "int" instead of "GtkIconSize" everywhere (or at least, everywhere that we can change via annotations that I know of; there's one place noted with a FIXME where an annotation ought to be picked up but is not). An alternative would be to explicitly tag GtkIconSize as being "non-strict" and then let bindings DTRT thing with it. That would also solve the GdkModifierType problem (bug 597292).
Created attachment 147393 [details] [review] [Gtk] Change GtkIconSize to int in params/return values GtkIconSize is an extensible enumeration (via gtk_icon_size_register()), so methods that claim to take/return a GtkIconSize need to actually use "int" to work correctly with bindings that are strict about enum values. Also fix up some "(out)" and "(transfer none)" in the gtk_image_get_* methods while we're there.
Same should be done with GtkResponse or whatever the enum is called that GtkDialog uses for responses.
Review of attachment 147393 [details] [review]: We need to add the annotations into GTK+ too now, but this looks fine for g-i.
So actually, this would be another good use for the meta-annotations in bug 604658... Attachment 147393 [details] pushed as 659b2b2 - [Gtk] Change GtkIconSize to int in params/return values
For the record: this kind of change would badly break bindings that treat enums specially. For example, the current non-gobject-introspection Perl bindings convert enum values to and from strings. For extensible enum types like GtkIconSize we use custom handlers that use functionality like gtk_icon_size_get_name() and gtk_icon_size_from_name() to also convert newly registered icon sizes to and from strings. All this magic can only work if GtkIconSize parameters have the correct type tag. (The Perl bindings don't use gobject-introspection yet, so this is not an urgent problem.)
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]