GNOME Bugzilla – Bug 734676
GtkBuider can't add a GtkMenuButton as a GtkHeaderBar's title
Last modified: 2018-04-14 23:58:15 UTC
Created attachment 283220 [details] 'menu_button' isn't added to the GtkHeaderBar Basically, this didn't work: <child type="title"> <object class="GtkMenuButton" id="menu_button"> <property name="visible">True</property> <property name="valign">center</property> <property name="menu-model">selection-menu</property> <child> <object class="GtkGrid" id="selection_menu_button_grid"> … </object> </child> <style> <class name="selection-menu"/> </style> </object> </child>
It kinda works here: https://git.gnome.org/browse/gtk+/tree/tests/selectionmode.ui Although it is not quite the same - its not a template, and there's an extra stack involved. A complete testcase would be helpful. What happens instead, the headerbar stays empty ? or shows the title ?
The titlebar stays empty, you can test Boxes's master branch to see what happen by reverting 25c9a14a8e6602f30c64c94d69f4ddbdcf72ec93 as it applies a workaround.
The problem is that custom-title is a construct property. What is happening is that your header bar subclass instance_init calls init_template, which in turn constructs the child of type "title". And then later, the constructor chain is run which gets passed the default value of NULL for the custom-title property, and wipes out the value set earlier.
We're moving to gitlab! As part of this move, we are moving bugs to NEEDINFO if they haven't seen activity in more than a year. If this issue is still important to you and still relevant with GTK+ 3.22 or master, please reopen it and we will migrate it to gitlab.
As announced a while ago, we are migrating to gitlab, and bugs that haven't seen activity in the last year or so will be not be migrated, but closed out in bugzilla. If this bug is still relevant to you, you can open a new issue describing the symptoms and how to reproduce it with gtk 3.22.x or master in gitlab: https://gitlab.gnome.org/GNOME/gtk/issues/new