Ok, i recently started programming with GTK+ in C.
I have a GdkToggleButton in my code and i want to add styling to it with css.
I've read almost all of GTK3+ documentation here https://developer.gnome.org/gtk3/stable but found nothing that fits my case.
Actually there is a part of the documentation about CSS but i couldn't find the part to actually parse the css file.
All I want to do is to change color of a GdkToggleButton either with CSS or any other method.
I want to know where to put the css file and how to parse it and add it to a Widget.
I actually could get GdkRGBA (color) of a button but changes have no effect.
Here's how i change GdkRGBA of button.
GdkRGBA *color ;
color = gdk_rgba_copy (color); // I don't know to initialize GdkRGBA :(
context = gtk_widget_get_style_context(button);
button = gtk_toggle_button_new_with_label ("Hello World");
GTK_STYLE_PROVIDER_PRIORITY_USER); // I had used wrong priority on first try
You can load custom CSS embedded in your program with
gtk_css_provider_load_from_data(). GtkCssProvider is how to load CSS in general.
Then you get the GtkWidget's style context and call
add_provider() on it. Use the
APPLICATION priority; that's what you're adding anyway (application-specific CSS).
save() call is not necessary.