Migrating to gtkmm3 (css, statusbar)


One more question about transfering a program in gtkmm3 . Now I start packing all widgets together and start learning about CSS styles, themes etc.

At the moment structure of the application is very simple (see pictures below). I have a VBox with a HPaned and a Statusbar (It is just a simple testing layout where I can see the problem)). I want to have all control elements to be as small as possible, so as a first step I put in the CSS “* {margin: 0px; padding: 0px}” and then add margins where they are needed. Background colors of the main VBox and the Statusbar is set to light blue and light red to see where they are.

The problem is with the Statusbar packing: it always have ~5px margin. Setting margin:0px; padding:0px; min-width:0px; min-height; to everything does not help. Vbox is configured with set_spacing(0). Packing is done with padding=0. If I replace Statusbar with a Label, or with a Label inside HBox, there is no problem, spaces are controlled by CSS properly, no extra margin appear.

It could be that it is some hack in the current GTK theme, Adwaita, But I did not find anything about Statusbar in its source: https://github.com/GNOME/gtk/blob/master/gtk/theme/Adwaita/
The question is how they managed to add such non-removable margins to Statusbar?


GtkStatusBar uses a template .ui file: https://gitlab.gnome.org/GNOME/gtk/blob/gtk-3-24/gtk/ui/gtkstatusbar.ui

you can try with:
g_object_set(status_bar, "margin", (gint)0, NULL);

1 Like

Thank you, it really works! In gtkmm it is
status_bar->set_property(“margin”, 0);

I did not know that Glib::Object property is not same as CSS property…

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.