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

Re: Set style of button, using custom color sets



>But the button doesn't appear in the color set I want.
>Also in general I was wondering how to use my own colors to
>display all kinds of widgets. Does anyone know an example 
>program in which this is done?

Is this what you want?
Carlos

-------set button color (background) -------
GtkWidget *button;
GdkColor color;
GtkStyle *style;

color.pixel = 0;
color.red = 65535;
color.green = 65535;
color.blue = 0;
style = gtk_style_copy (gtk_widget_get_style (button));
style->bg[GTK_STATE_NORMAL] = color;
style->bg[GTK_STATE_ACTIVE] = color;
style->bg[GTK_STATE_PRELIGHT] = color;
style->bg[GTK_STATE_SELECTED] = color;
style->bg[GTK_STATE_INSENSITIVE] = color;
gtk_widget_set_style (button, style);

gtk_style_unref (style);
------------------------

-------set label color (foreground) -------
GtkWidget *button;
GtkWidget *label;
GdkColor  color;
GtkStyle  *style;

label = GTK_BIN (button)->child;
gdk_color_parse ("red", &color);
style = gtk_style_copy (gtk_widget_get_style (label));
style->fg[GTK_STATE_NORMAL] = color;
style->fg[GTK_STATE_ACTIVE] = color;
style->fg[GTK_STATE_PRELIGHT] = color;
style->fg[GTK_STATE_SELECTED] = color;
style->fg[GTK_STATE_INSENSITIVE] = color;
gtk_widget_set_style (label, style);

gtk_style_unref (style);
------------------------




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