GNOME Bugzilla – Bug 708866
Gtk::HeaderBar usage example
Last modified: 2013-10-06 08:58:34 UTC
Created attachment 255869 [details] [review] Gtk::HeaderBar example Here's a small demo of Gtk::HeaderBar.
It looks fine. Could you try patching examples/Makefile.am too, please?
Created attachment 255974 [details] [review] Gtk::HeaderBar example Sorry; damn, I didn't manage to get a hole in one yet.
Thanks. I have pushed that, with a slight change to add some column and row spacing to the Gtk::Grid, and to actually mention the source files in the examples/Makefile.am file. I also corrected your Author email address in the commit. However, this example shows that there is a problem during destruction, when using set_titlebar(): (example:4666): Gtk-CRITICAL **: gtk_bin_remove: assertion 'priv->child == child' failed gdb has this backtrace at that use of g_log(): Breakpoint 1, g_log (log_domain=0xb72a9586 "Gtk", log_level=G_LOG_LEVEL_CRITICAL, format=0xb6cd0c38 "%s: assertion '%s' failed") at gmessages.c:1024 1024 va_start (args, format); (gdb) bt
+ Trace 232552
I put a g_warning in gtkbin.c and discovered that, for that call, the container (bin) is the Gtk::Window and the child is the Gtk::HeaderBar. So, something is making the GtkWindow try to remove the GtkHeaderBar as if it is the GtkWindow's only child, though that is actually the GtkGrid. gtk_bin_remove() is subsequently called correctly with child = to the GtkGrid. I wonder why this (presumably) doesn't happen with the GTK+ C API. Maybe we need to make our Widget_Class::dispose_vfunc_callback() cleverer to avoid calling remove() on a header bar (not just a GtkHeaderBar) that has the widget as its parent. Maybe we could check if the widget is a GtkWindow and if the child == get_titlebar(). Unforunately there is not gtk_window_get_titlebar() yet. And I'd prefer something more generic anyway. Maybe a special case for GtkBin that checks if it's really the child. Of course, if we don't remove it, we might need to do something else to make it (a widget being destroyed) no longer used by GTK+. If remove() can't do that then we'd need to unset the window's titlebar somehow. But gtk_window_set_titlebar() cannot yet take NULL to unset.
I would have to check again, but I think the same problem is present in py-gobject.
Created attachment 256038 [details] [review] debug_titlebar_dispose.patch This little hacky patch shows that it's not this part of the code that's leading to this warning. I had assumed that gdb (or compiler optimization) was just hiding it in the backtrace. Maybe we need to try to reproduce it in C somehow.
I have added an attachment with a patch to the gtk+ bug 709049. I've got a question concerning Gtk::HeaderBar itself: Why is get_show_close_button() not const?
I guess no reason, that's my fault. I'm not sure if this is the right place, but I'll attach a patch here.
Created attachment 256416 [details] [review] Gtk::HeaderBar::get_show_close_button constness
I have pushed your patch. I suppose this ABI breaking fix can be applied now, since HeaderBar is not yet included in a stable release. Both my question and your patch fit better in bug 708194, but never mind.
Gtk+ bug 709049 has been fixed. With that fix, the HeaderBar example works as expected. Closing this bug.