Re: Button background colors

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

 



On Wed, Jun 14, 2006 at 03:30:29PM -0500, Michael Kahn wrote:
> I am using Gtk 2.8.18.
> 
> I would like to know how to set the background color in a GtkButton.
> 
> I cannot set the background in a style, theme, or resource file because I am
> programming to requirements that specify different background colors for
> different buttons.
> 
> I have tried using gtk_widget_modify_bg the button, using all combinations
> of creating the button with and without a label.

I use gtk_widget_modify_bg() without trouble.  piece of a function:


struct somethingorother pagestate_colors = { blah, blah, blah };

static void
update_examples_from_state( GtkWidget * toggle )
{
    GdkColor color = pagestate_colors.scheme_bg_normal;
    gtk_widget_modify_bg( toggle, GTK_STATE_NORMAL,      &color);
    gtk_widget_modify_bg( toggle, GTK_STATE_ACTIVE,      &color);
    gtk_widget_modify_bg( toggle, GTK_STATE_PRELIGHT,    &color);
    gtk_widget_modify_bg( toggle, GTK_STATE_SELECTED,    &color);
    gtk_widget_modify_bg( toggle, GTK_STATE_INSENSITIVE, &color);
}

after running that you have to let the main event processing loop run a
little to let your changes take effect.  I am using using 2.6.8-1 but I
can't imagine this functionality would have changed.

- Anna

_______________________________________________

gtk-list@xxxxxxxxx
http://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux