In Gtk3, GtkStackSwitcher inherits GtkBox which has a
homogeneous property. In Gtk4, GtkStackSwitcher inherits GtkWidget directly and lose this property. Evince use this property to implement its sidebar. And the general question is how do I set properties (such like hexpand halign) for GtkButton managed by GtkStackSwitcher.
how do I set properties (such like hexpand halign) for GtkButton managed by GtkStackSwitcher.
You can’t. Even in GTK3 those buttons were an implementation detail and not a part of the API - in other words if the internal layout changes and your app breaks, it’s your fault.
You can still get them via
gtk_widget_get_first_child() etc, but don’t.
Evince use this property to implement its sidebar.
What are you trying to achieve? If you’re trying to get a switcher to expand, I think it would make sense to do that unconditionally in
GtkStackSwitcher itself, so that
halign=fill actually works.
I’m trying to port Evince to GTK4. And Evince use the
homogeneous property to make the buttons in sidebar look like this:
But even with halign set to fill, GtkStackSwitcher still look like this with GTK4:
The horizontal space is filled by GtkStackSwitcher already according to GTK inspector.
Right, hence as I said it needs to be fixed in GTK. No need for new API or peeking into inner widgets.
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.