Skip to content

Instantly share code, notes, and snippets.

@andreldm andreldm/sample.c
Created Feb 27, 2019

Embed
What would you like to do?
GTK CSS issue reproducer
/*
* gcc $(pkg-config --cflags gtk+-3.0) sample.c -o sample $(pkg-config --libs gtk+-3.0)
*/
#include <gtk/gtk.h>
int main (int argc, char *argv[])
{
GtkWidget *window;
GtkWidget *box;
GdkRGBA color;
GtkCssProvider *provider;
gtk_init (&argc, &argv);
provider = gtk_css_provider_new();
gtk_css_provider_load_from_data(provider,
"#xfwm-tabwin { "
"border-radius: 100px;"
"box-shadow: 10px 10px 5px 0px rgba(0,0,0,0.75);"
"}", -1, NULL);
gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),
GTK_STYLE_PROVIDER(provider),
GTK_STYLE_PROVIDER_PRIORITY_FALLBACK);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
gtk_window_set_position (GTK_WINDOW (window), GTK_WIN_POS_CENTER);
gtk_container_set_border_width (GTK_CONTAINER (window), 5);
gtk_window_set_default_size (GTK_WINDOW (window), 640, 480);
gdk_rgba_parse (&color, "#173F5F");
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_widget_override_background_color (window, GTK_STATE_FLAG_NORMAL, &color);
G_GNUC_END_IGNORE_DEPRECATIONS
box = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
gtk_widget_set_valign (box, GTK_ALIGN_CENTER);
gtk_widget_set_halign (box, GTK_ALIGN_CENTER);
gtk_widget_set_size_request (box, 200, 200);
gdk_rgba_parse (&color, "#3CAEA3");
G_GNUC_BEGIN_IGNORE_DEPRECATIONS
gtk_widget_override_background_color (box, GTK_STATE_FLAG_NORMAL, &color);
G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_set_name (GTK_WIDGET (box), "xfwm-tabwin");
gtk_container_add (GTK_CONTAINER (window), box);
g_signal_connect (G_OBJECT (window), "destroy", G_CALLBACK (gtk_main_quit), NULL);
gtk_widget_show_all (window);
gtk_main ();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.