On 08/29/2012 05:17 PM, Carlos Pereira wrote:
> Quite often widget colors are just a question of style but sometimes
> this is not the case. I can think of medical applications, for example,
> where colors can be critical.
> 
> In my case, I have a chemical periodic table made with GTK buttons, each
> one representing a chemical element, with its default color. Users can
> change these chemical element default colors directly from the interface
> or from XML config files:
> 
> http://www.gamgi.org/screenshots/screenshot13_5.html
> 
> Rewritting an entire CSS file and downloading it everytime users change
> the default color of a chemical element looks really depressing... I am
> sure button colors can be changed directly from the code in GTK 3??

you can modify bits of the CSS from your code like this (taken from
Bluefish code bftextview.c):

GString *str = g_string_new("");
GtkStyleContext *stc;
GtkCssProvider *cssp = gtk_css_provider_new();
str = g_string_append_printf(str, "GtkTextView.view {background-color:
%s;}", colors);
gtk_css_provider_load_from_data(cssp, str->str, -1, NULL);
stc = gtk_widget_get_style_context(GTK_WIDGET(mywidget));
gtk_style_context_add_provider(stc, GTK_STYLE_PROVIDER(cssp),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);


regards,
        Olivier

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list

Reply via email to