GNOME Bugzilla – Bug 620577
Unable to retrieve the value of a field that is a fixed-size array
Last modified: 2011-10-21 18:23:25 UTC
The fg/bg and other GtkStyleHelper attributes seem to be empty at all times. Old code: >>> import gtk >>> print gtk.Style().fg <gtk.GtkStyleHelper object at 0xb77eb818> New code: >>> from gi.repository import Gtk >>> print Gtk.Style().fg None
GtkStyleHelper is a PyGTK artifact. With dynamic bindings, you should expect a list of Gdk.Color. As of today, Gtk.Style().fg returns an empty list. Is it correct?
I dug into _wrap_g_field_info_get_value and discovered that g_field_info_get_field ( (GIFieldInfo *) self->info, pointer, &value) sets value->v_pointer to 0, while it should not (the fg field should be a pointer, and is recognized as such by g_type_info_is_pointer). In g_field_info_get_field, at line 196, G_STRUCT_MEMBER (gpointer, mem, offset) returns 0 while mem is 0x826e198 and offset is 12.
Actually, it's normal. I was wrong, the fg field should not be considered as a pointer since it is a fixed-size array.
Filed a bug in gobject-introspection. Depending on the solution, we might need to adapt _wrap_g_field_info_get_value too.
The Gtk.Style structure is broken for GI although Gtk.Style().fg used to work. In any case the structure should be gsealed and we should use accessors to get and set those values. GI just can not support all the complexities of structs. It especially doesn't know the difference between fixed structs and a pointer to an array. The fix here is to provide a patch to gtk which allow access to each of the struct values.