label color (RcStyle vs. style)
- From: MC_Vai <estoy ver megared net mx>
- To: gtk-app-devel-list gnome org
- Subject: label color (RcStyle vs. style)
- Date: Fri, 27 Jul 2001 14:51:56 +0000
Suppose I have an 'F' function that changes the color of
a GtkLabel according to an 'X' flag.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void F( GtkWidget label, int X_flag ) {
GtkRcStyle *rcs;
rcs = gtk_rc_style_new();
rcs->fg[GTK_STATE_NORMAL] = X_flag? one_color: other_color;
rcs->color_flags[GTK_STATE_NORMAL] |= GTK_RC_FG;
gtk_widget_modify_style( widget, rcs );
gtk_rc_style_unref( rcs );
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The function is working just fine, but the problem
is when I pass a label previously modified (its font
and parent's background) by this function below:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void
G( GtkWidget *bgwidget, GtkWidget *label) {
GtkStyle *label_style;
[...]
label_style = gtk_style_new();
fnt = gdk_font_load(
"-adobe-helvetica-medium-r-normal-*-*-240-*-*-p-*-iso8859-1" );
gdk_font_unref( label_style->font );
label_style->font = fnt;
gtk_widget_set_style( label, label_style );
gtk_style_unref( label_style );
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I don't know why the label (previuosly passed to the
'G' function) doesn't change it's font color when I
pass it to the 'F' function (other labels does).
The only solution I came out was to change the 'F'
function to something like this:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void F( GtkWidget label, int X_flag ) {
GtkStyle *style;
style = gtk_style_new();
style->fg[GTK_STATE_NORMAL] = X_flag? one_color: other_color;
gtk_widget_set_style( widget, style );
gtk_style_unref( style );
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
But the font type is overwritten and I want to retain
the previously modified font type.
Any suggestions?
Thanks a lot in advance.
Regards,
- Eduardo.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]