Search code examples
c++cssuser-interfacecomboboxgtkmm

How do I change css styles of a gtkmm combobox?


Whenever a widget changes it's state, it is supposed to change its style. I have successfully implemented the signalizing, but I can't figure out how to change a combobox' style really.

The function that changes a widget's style:

{
    static Glib::RefPtr<Gtk::CssProvider> css{nullptr};
    if(!css) {
        css = Gtk::CssProvider::create();
        css->load_from_data(
            "button {background-color: #fff9ed;}\
         button:hover {background-color: #fff9ed;}\
         button:active {background-color: #fff9ed;}\
         //changing background-color: to color: does not make any difference
         combobox {color: @fg_color;background-color: #fff9ed;}\ 
         .entry {color: #fff9ed;}\
         checkbutton {background-color: #fff9ed;}\
         checkbutton:checked {background-color: #fff9ed;}");
    }
    return css;
} 

This results in making a really tiny frame over the combobox. Here is the output:

Before: enter image description here

After: enter image description here

One can clearly see, that the background changes (see the arrowed, orange tips on the corners). But that's not useful, as the actual box covers 99% of the background. I haven't figured out how to change styles of the atual combobox button, which would solve my problem as well.


Solution

  • I found a solution for my problem. I assume 'padding' for comboboxes were at 0px, so i added 'padding: 2px;' in the css string.