Setting Widget Attributes (Half Solution)




Ok, Yesterday I asked setting widget attributes, specifically foreground 
color, background color, and font.  Someone gave me a snipped on how to 
set the fonts, but no one said anything about colors.  

I managed to use GtkStyle to change the foreground color, but it doesn't 
work for the background color.  I'm working with a GtkLabel for, so I'm 
wondering if a GtkLabel is perhaps transparent, so that it's letting the 
background of the container show through.

--------------------------------------------------------
GtkWidget *label = NULL;
GtkStyle *LabelStyle = NULL;
GdkColor *fg = NULL;
GdkColor *bg = NULL;

label = gtk_label_new("Text");
LabelStyle = gtk_style_copy(gtk_widget_get_style(label);
gtk_widget_set_style(label,LabelStyle);

fg = (GdkColor *) malloc(sizeof(GdkColor));
bg = (GdkColor *) malloc(sizeof(GdkColor));

foreGroundColor->red = 0;
foreGroundColor->green = 200 * (65535/255);
foreGroundColor->blue = 0;

backGroundColor->red = 0;
backGroundColor->green = 0;
backGroundColor->blue = 0;

LabelStyle->fg[0] = *foreGroundColor;
LabelStyle->bg[0] = *backGroundColor;
----------------------------------------------------------

This succeeds in setting the foreground color (the text in the label)
to a dark green, but the background stays at the standard gray color.

Any ideas?

Thanks,
Ben Boule




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