Been wrapping my head around this for the last week and I don’t seem to get anywhere. I understand Gnome is quite a strict environment but I hope there’s freedom to do things a bit differently too, and without having to reinvent the wheel. This is a header bar I have created so far, in XML.
<object class="GtkHeaderBar" id="header_bar">
<child type="start">
<object class="GtkButton" id="profile_button">
<property name="sensitive">true</property>
<property name="icon-name">user-info-symbolic</property>
</object>
</child>
<child type="title">
<object class="GtkStackSwitcher" id="stack_switcher">
<property name="stack">toplevel_stack</property>
<property name="css-name">toplevel_stack</property>
</object>
</child>
<child type="end">
<object class="GtkMenuButton" id="gears_button">
<property name="valign">center</property>
<property name="focus-on-click">false</property>
<property name="direction">none</property>
</object>
</child>
<child type="end">
<object class="GtkToggleButton" id="search_button">
<property name="sensitive">0</property>
<property name="icon-name">edit-find-symbolic</property>
</object>
</child>
</object>
The stack starts like this
<object class="GtkStack" id="toplevel_stack">
<property name="transition-duration">250</property>
<property name="transition-type">1</property>
<property name="hhomogeneous">true</property>
<child>
<object class="GtkStackPage">
<property name="name">page_start</property>
<property name="title" translatable="1">Start</property>
<property name="icon-name">emoji-nature-symbolic</property>
<property name="use-underline">1</property>
<property name="child">
<object class="GtkBox" id="page_start">
What I am trying to achieve is simple, a GtkStackSwitcher
with buttons that have both an icon and label and if possible, with a height that fills the title bar / header.
I am looking at what the people developing Foliate have done, except they use some JS for that portion, which I would like to avoid.
Other people have tried using GtkToggleButton
and some dirty tricks to achieve it but I would like to know if there’s any standard way of doing this, either in C or inside the UI file (something like accessing or extending the GtkStackSwitcher
and changing the child buttons).
I have also read somewhere that this also depends on the user’s preferences and there might be a setting somewhere that maybe can be activated to show both icons and labels in GtkButton
. Would it be true?
In the end, I would even change to a different switcher, something like GtkStackSidebar
or GtkNotebook
, but only if I don’t find myself in the same situation and I can add icons to the labels, like in the Settings window of Ubuntu, for example. What would you recommend?