GNOME Bugzilla – Bug 118036
Label accelerators set in libglade are lost if widgets are reparented.
Last modified: 2004-12-22 21:47:04 UTC
All label accelerators set in libglade are lost when the relevant widgets are reparented. The testcase is simple: t = glade.GladeXML('foo.glade') # where foo an accel label (underscored) w = t.get_widget("window") w.show_all() At this point the accelerator works fine. w2 = gtk.GtkWindow() w.children()[0].reparent(w2) Here, all accelerators stop working. I'm not entirely sure how this should be fixed; a quick glance at the libglade code didn't give me any late-night insights. I know this version is old and not maintained, but: - Does this bug happen in CVS HEAD libglade too? - Any hints as to how I could work around this problem? C extension hacking is an acceptable compromise at this point :-/
Just as a data point, Kiwi uses reparenting extensively in its "slave" system, which are really groups of widgets that are embedded in other windows (they have a temporary toplevel window only for reparenting purposes).
Keyboard shortcuts are handled by GtkAccelGroups, which are attached to top level windows. When you reparent all the widgets into a new toplevel, the new toplevel doesn't have the accel group attached to it, so the keyboard shortcuts won't work. (however, they should still function if you press them in the original toplevel, assuming it is visible :) For GTK 2, mnemonics (alt+letter shortcuts) are handled specially and don't suffer from this problem.
There's a workaround which is grabbing the accelerators from the original window and attaching them to the new window, which works as expected (though the hard part is figuring out how to organize accelerators correctly, particularly for GtkNotebook which is handled specially inside libglade). I'm closing this since it's only an issue in GTK+ 1.2 with an acceptable workaround.