Re: Changing the background color of a Label



>
> Hi,
>
> This sort of question should not go to gtk-devel-list, only gtk-list.

oops sorry I wanted to send it to gtk-app-devel-list, I've typed it too
fast...

>
> http://pobox.com/~hp/gtk-colors.html has the answer in there.
>
> Havoc

Yep but my problem was that when I'm applying this code the background color
of the label didn't changed.
As Skip pointed me, the GtkLabel take the background color form its parent
(or some similar stuff) and in fact it is documented for that part in the
FAQ.
Anyway, I'm using the GtkStyle instead of the GtkRcStyle 'cause I didn't
manage to get it working on my example (modifying background color, writing
color and font) Only the writing color (using FG) did work. Here is the
GtkRcStyle code I've tryed, if somebody can tell me what's wrong?
(I have the code working properly using GtkStyle but I've read that it is
not the clean way...)



 /** Modify background color Version label **/
 /* After filling in your GdkColor, create a GtkRcStyle */
 rc_style = gtk_rc_style_new();
 /* Set background (bg) color in normal state to CouleurTitreFond */
 rc_style->bg[GTK_STATE_NORMAL]  = CouleurTitreFond;
 /* Indicate which colors the GtkRcStyle will affect;
  * unflagged colors will follow the theme
  */
 rc_style->color_flags[GTK_STATE_NORMAL]   |= GTK_RC_BG;

 gtk_widget_modify_style(gtkLabelContainer, rc_style);
 gtk_rc_style_unref(rc_style);


 /** Modify writing color and Font Version label **/
 rc_style = gtk_rc_style_new();

 rc_style->fg[GTK_STATE_NORMAL] = CouleurTitrePolice;
 rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;

 rc_style->font_name = g_strdup("%s",
"-*-arial-medium-i-*-*-*-200-*-*-P-*-iso8859-1");
/* rc_style->font_name = "Arial"; */

 gtk_widget_modify_style(ABOUT_lblNameVersion, rc_style);
 gtk_rc_style_unref(rc_style);







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