Search code examples
cgtk3

c gtk3 style - button's background doesn't change


I wrote program using GTK3 with css styling and it works perfect on my KDE. But problem is that on ubuntu and windows 10 styling only works partially. I have css file like this:

window {
    background-color: white;
}
button {
    border: none;
    color: white;
    padding: 15px 32px;
    text-decoration: none;
    font-size: 16px;
    background-color: #555555;
}

Everything works except changing background of buttons. It's how I load css:

GtkCssProvider *provider = gtk_css_provider_new ();
gtk_css_provider_load_from_path (provider, "styles.css", NULL);

gtk_style_context_add_provider_for_screen(gdk_screen_get_default(),
                        GTK_STYLE_PROVIDER(provider),
                        GTK_STYLE_PROVIDER_PRIORITY_USER);

How can I make it work?


Solution

  • I found solution:

    window {
        background-color: white;
    }
    button {
        border: none;
        padding: 0px;
        text-decoration: none;
        font-size: 16px;
    }
    button > label{
        padding: 15px 32px;
        background-color: #555555;
        color: white;
    }