Re: Setting a widget theme?



On Thu, 2003-02-27 at 15:47, Andy Robertson wrote:
I like color coding in my applications.  I have done
this with GTK before, but the reaction received by
anyone mentioning changing colors of widgets on this
list is typically 'Don't change the colors, leave that
to themes'.

mostly people say that because we're all disgusted with the typical Xlib
or Tcl/Tk app whose rainbow of garish colors hurts the eye and is
impossible to change.  allowing the themes to do the heavy lifting takes
the work away from the programmer, allowing the user to decide what he
likes.

i don't think anybody has a problem with you changing a widget color
when it's a necessary thing.

from your description i presume you want to have the foo-related stuff
be green, and the bar-related stuff be blue, and the baz utilities
maroon, etc.  perhaps if you limited this to a decorative border (a la
the druid widget) you might hit the best of color-coding and smooth
environment integration.


OK, fine.  But, how do I select a theme for an
individual widget?  Sort of like what the gnome theme
selector lets you do in it's theme preview.

Anyone know how to do this?  Setting a theme for a
container and all sub widgets would be my ideal.

it's probably very easy to break, so i wouldn't suggest it.

changes to colors and fonts and the like are best done through the
GtkStyle mechanism.

you can mangle things in a gtkrc file that your app loads.  this is how
the gimp sets the ruler font to be smaller than the font for the rest of
the application.  i know very little about this, so i will leave that to
you to figure out.  this would be very nice because you could have the
colors written in a user editable config file and not have it hard-coded
into your app.


if you are hell-bent on changing it programmatically, check out the docs
for GtkStyle.  basically, styles get inherited, but you can create a
copy of a style, mangle it how you see fit, and attach it to a widget.

if my understanding is correct, you should be able to change the
background and foreground color in the style already attached to the
toplevel widget, and that should propagate to all the children, or at
least to every widget which refers to that style object.

remember that there are several GdkGCs in each style --- one for each
widget state.  (e.g., normal, insensitive, highlight, etc)


-- 
muppet <scott asofyet org>




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