Re: GtkButton bg color



On 04/30/2012 11:36 PM, Steve wrote:

If this doesn't work, you must be using a GTK theme that is overriding
the coloring of widgets.

Just confirmed that it is in fact the them preventing me from changing
the bg color of the button.

I vaguely recall that when i read the GtkRcStyle and wrote it back
(without changing anything) The theme was no longer applied to the
button, but once again i could not find anything in the documentation
that could explain it.

So, what options do i have to color a button when a theme is preventing
such an action?  Changing themes is NOT an option.

on gtk3 you can load a specific stylesheet that has 'application
priority'. that will overrule the theme.

something like this (copied from bluefish sourcecode):

GtkCssProvider *cssp = gtk_css_provider_new();
gtk_css_provider_load_from_data(cssp, my_css_string, -1, NULL);
stc = gtk_widget_get_style_context(GTK_WIDGET(btv));
gtk_style_context_add_provider(stc, GTK_STYLE_PROVIDER(cssp),
GTK_STYLE_PROVIDER_PRIORITY_APPLICATION);

Olivier



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]