GNOME Bugzilla – Bug 652941
Problem with Gtk.Container.child_get_property
Last modified: 2012-11-08 01:44:07 UTC
Steps to reproduce: import gi gi.require_version('Gtk', '3.0') from gi.repository import Gtk hBox = Gtk.HBox() button = Gtk.RadioButton() hBox.pack_start(button, False, False, 0) hBox.child_get_property(button, "expand") Traceback (most recent call last):
+ Trace 227521
return info.invoke(*args)
OS: Arch Linux 64-bit Component versions: - python2: 2.7.2 - gtk3: 3.0.11 - gobject-introspection: 0.10.8 - pygobject: 2.28.4
The value argument needs to be annotated (out caller-allocates) in Gtk but still that doesn't work. Seems like we have an issue with GValue out values. I'll have to debug that. Is button.get_property("expand") different?
(In reply to comment #1) > The value argument needs to be annotated (out caller-allocates) in Gtk but > still that doesn't work. Seems like we have an issue with GValue out values. > I'll have to debug that. Is button.get_property("expand") different? - hBox.child_get_property(button, "expand") + button.get_property("expand") This doesn't cause any errors.
What I meant is do they give you the same values or is the parent's "expand" property for a child different from the child's "expand" property?
(In reply to comment #3) > What I meant is do they give you the same values or is the parent's "expand" > property for a child different from the child's "expand" property? Oh, sorry, I misunderstood that question. Well, button.get_property("expand") returns False for me, but I can't tell for hBox.child_get_property(button, "expand") as that one crashes as described. Is there a way for me to tell you without using this function?
write it in C but that doesn't prove anything even if they return the same values since it could just be coincidence. I posed the question to #gtk+ in irc last night but no one was on who could answer it. Can you see if you can get someone to describe the difference between the two methods.
Well, I can try to ask there, but I'm typically not hanging out on IRC every day, so it may take me a while. Plus, I also found that channel to be very badly frequented, so maybe some -devel channel might be a good idea to try, too. But why exactly do you need to know what makes those functions different? We're talking about those two here, right? g_object_get_property http://git.gnome.org/browse/glib/tree/gobject/gobject.c#n1935 gtk_container_child_get_property http://git.gnome.org/browse/gtk+/tree/gtk/gtkcontainer.c#n946 I'm not experienced at reading C code, but they definitely do similar, yet different stuff. If I'm not completely mistaken here, the problem is a broken language binding, not the glib/gtk+ function they're binding to.
This bug also/still exists in 3.0.1.
This still applies to pygobject 3.2.1 and current GTK 3.4.2. This is not easily fixable, I'm afraid. The GValue* argument is not strictly "out", as it needs to be initialized and set to the correct type before calling the function. But you cannot initialize a GValue from Python (or any other scripting language), so by and large gtk_container_child_get_property() is not introspectable as it is. Setting to "minor" as this has an obvious workaround (calling child.get_property()). As we likely don't want to change the ABI/behaviour of gtk_container_child_get_property(), I suggest to just mark this method as (skip)? If it is useful for some cases, there could perhaps be a similar function which does the GValue initialization by itself, so that it can become a real (out) value?
Marking as dup of bug 685076 (because that one has patches) *** This bug has been marked as a duplicate of bug 685076 ***