Re: [gtk-list] Re: style usage
- From: Eric Harlow <linuxgeek yahoo com>
- To: gtk-list redhat com
- Subject: Re: [gtk-list] Re: style usage
- Date: Thu, 29 Oct 1998 04:43:38 -0800 (PST)
Your code did the following:
1) Copy a style
2) Modify the style colors
3) Set the widget style
4) Modify the style further.
5) Set the widget style again.
Step 4 modified the style color of a style that was assigned to a
widget. I believe this is bad practice, but I haven't sifted through
the code to figure out why this causes a problem. (Somewhere in
deallocation.)
When I said "set the colors", I meant the allocation of the colors
that you do before you set the widget style.
I believe it's bad practice to directly modify anything given to GTK
to manage - in this case, you've given the style to GTK to assign to a
widget - and you can assign it to other widgets - but don't modify the
style while it is assigned. Instead, create a new style and use that.
In your case, you set two different colors up (a background and a
foreground) for a style, but inbetween you call gtk_widget_set_style.
gtk_widget_set_style (button, style);
// --- Whoa! Style's been set! What are you doing?
style->fg[GTK_STATE_NORMAL] = color;
You don't need to call gtk_widget_restore_default_style in your code.
You can fix your code by doing
/* --- Setup the colors first. --- */
style->bg[GTK_STATE_NORMAL] = color;
style->fg[GTK_STATE_NORMAL] = color;
/* --- Then set the style --- */
gtk_widget_set_style (button, style);
-Eric
---Robert Roebling <roebling@sun2.ruf.uni-freiburg.de> wrote:
>
> Eric Harlow wrote:
>
> > I don't think that directly modifying the style of a widget is good
> > practice. You really should set the colors first, and then call
> > gtk_widget_set_style.
>
> I don't understand. This is what I'm doing or what does "set the
> colors first" mean?
>
> > Also, the second gtk_widget_set_style is trying to set the style of
> > the widget to the style it already has - and is ignored. (See
> > gtkwidget.c, gtk_widget_set_style_internal ())
>
> Maybe I'd have to set gtk_widget_restore_default_style (or some-
> thing like that) before assigning a new style?
>
> Robert
>
> --
> ------------------------------------------------------------------
> Robert Roebling "Write once, compile, run everywhere"
>
> wxWindows/GTK http://wesley.informatik.uni-freiburg.de/~wxxt
>
> --
> To unsubscribe: mail -s unsubscribe gtk-list-request@redhat.com <
/dev/null
>
>
_________________________________________________________
DO YOU YAHOO!?
Get your free @yahoo.com address at http://mail.yahoo.com
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]