How to find CSS style syntax changes between Gtk 3.12 and Gtk 3.22
- From: Richard Shann <richard rshann plus com>
- To: gtk-app-devel-list gnome org
- Subject: How to find CSS style syntax changes between Gtk 3.12 and Gtk 3.22
- Date: Sun, 07 May 2017 16:52:29 +0100
I have a test program that pops up a label with a customized background
and foreground color. This works in 3.12 using the syntax
"GtkLabel {background-color: #FFFF00;}"
and
"GtkLabel {color: #FF00FF;}"
but fails in 3.22
How can I track changes needed to CSS syntax from one version to another
in the documentation (mostly I struggle to find the correct syntax :( )
Any help appreciated: test code follows.
8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
//gcc -Wall TestStyleChange.c -o TestStyleChange `pkg-config --cflags --libs gtk+-3.0`
#include<gtk/gtk.h>
void set_background_color(GtkWidget *w, gchar *color)
{
GtkCssProvider *gcp;
GtkStyleContext *gsc;
gsc = gtk_widget_get_style_context(w);
const gchar *type = g_type_name (G_TYPE_FROM_INSTANCE (w));
gchar *str = g_strdup_printf ("%s {background-color: %s;}", type, color); g_print("%s", str);
gcp= gtk_css_provider_new();
gtk_css_provider_load_from_data(gcp, str, -1, 0);
g_free (str);
gtk_style_context_add_provider(gsc, GTK_STYLE_PROVIDER(gcp),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
void set_foreground_color(GtkWidget *w, gchar *color)
{
GtkCssProvider *gcp;
GtkStyleContext *gsc;
gsc = gtk_widget_get_style_context(w);
const gchar *type = g_type_name (G_TYPE_FROM_INSTANCE (w));
gchar *str = g_strdup_printf ("%s {color: %s;}", type, color); g_print("%s", str);
gcp= gtk_css_provider_new();
gtk_css_provider_load_from_data(gcp, str, -1, 0);
g_free (str);
gtk_style_context_add_provider(gsc, GTK_STYLE_PROVIDER(gcp),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);
}
int main(int argc, char **argv)
{
gtk_init(&argc, &argv);
GtkWidget *top_window=gtk_window_new(GTK_WINDOW_TOPLEVEL);
g_signal_connect (top_window, "destroy", G_CALLBACK(gtk_main_quit), NULL);
GtkWidget *eventbox = gtk_event_box_new ();
GtkWidget *label=gtk_label_new("Label");
set_background_color (label, "#FFFF00");
set_foreground_color (label, "#FF00FF");
gtk_widget_set_size_request(label, 400, 400);
gtk_container_add (GTK_CONTAINER (eventbox), label);
gtk_container_add (GTK_CONTAINER(top_window), eventbox);
gtk_widget_show_all (top_window);
gtk_main();
return 0;
}
8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><
Richard Shann
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]