Gtk+ 3.0 Client Side Theme
How to override user’s theme or I want my app with green buttons.
#include
static gboolean
delete_event (GtkWidget *widget, GdkEvent *event, gpointer data)
{
gtk_main_quit();
}
int
main (int argc, char* argv[])
{
gtk_init(&argc, &argv);
GtkCssProvider *provider = gtk_css_provider_new ();
gtk_css_provider_load_from_data (
provider,
"GtkButton {font: Monospace 10; background-color: rgba(0%, 76%, 0%, 0.6);}",
-1, NULL);
GdkDisplay *display = gdk_display_get_default ();
GdkScreen *screen = gdk_display_get_default_screen (display);
gtk_style_context_add_provider_for_screen (
screen, GTK_STYLE_PROVIDER (provider),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
g_object_unref (provider);
GtkWidget *window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_container_set_border_width (GTK_CONTAINER (window), 10);
g_signal_connect (G_OBJECT (window), "delete_event", G_CALLBACK (delete_event), NULL);
GtkWidget *button = gtk_button_new_with_label("GtkCssProvider load from data");
gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (button));
gtk_widget_show_all (GTK_WIDGET (window));
gtk_main ();
return 0;
}
Categories: Gtk+

Saving post man
You should publish it somewhere accessible to the newcomers to Gtk development.
Nice tutorial !
How can you put a image on the background of just the main window using css?
You’ve declared the return type of the function delete_event as a static gboolean but haven’t provided one in the function. Also the include is incomplete. It should be: #include
Other than that well done. I’d like to see more advanced use of css.