I want to load a glade-file and change the color of all toggle-buttons ( class "GtkToggleButton" , I want to change the "pressed" color) The toggle-button is one of many sub-sub-element in the glade-file. Here the C-code-snipped I use to load the .css and the .glade:
void on_minute_pressed(GtkWidget *button)
{
GtkCssProvider *cssProvider = gtk_css_provider_new ();
gtk_css_provider_load_from_path(cssProvider,"./test.css",NULL);
GtkBuilder *builder = gtk_builder_new();
gtk_builder_add_from_file (builder, "minute_dialog.glade", NULL);
GtkWidget *window= GTK_WIDGET(gtk_builder_get_object(builder, "MinuteWizard"));
gtk_window_set_transient_for (window,main_window);
gtk_style_context_add_provider(gtk_widget_get_style_context(window),cssProvider,GTK_STYLE_PROVIDER_PRIORITY_USER);
gtk_builder_connect_signals(builder, NULL);
gtk_widget_show(window);
g_object_unref(builder);
}
And here the .css I currently use:
.button {
padding: 30;
background-color: shade (@bg_color, 55);
}
togglebutton entry {
color: 900185;
}
button:active {
background-color: #0274d9;
}
What currently happens: The new window load's fine, but it seems like it does not matter what I write into the .css, it does not change the look of the window-elements. I can see that the .css is loaded, because I get warnings like:
Gtk-WARNING **: Theme parsing error: test.css:2:13: Not using units is deprecated. Assuming 'px'.
What is wrong ? Do I need to apply the .css to each sub-widged separately?
Not using units is deprecatedcomes from old CSS files, where some size are just specified by a number, such asborder=1. Present gtk versions require those to be specified as1px. Mind, if your theme is so old, you will probably run into problems with gtk newer than 3.20! It should not influence your main problem though.