[Glade-users] Want to set colors of widgets...

Damon Chaplin damon@helixcode.com
Sun, 10 Sep 2000 12:42:11 +0100


Friedrich Steven E CONT CNIN wrote:
> 
> Ok, I'm new to GTK, Gnome, and Glade, so please don't flame me.
> 
> We're developing a system that will include a maintenance application that
> will allow a tech to exercise the system, etc.  We're attempting to use
> Glade, Gnome, and GTK.  We want to be able to set the background color of
> the main window (a gnome_app widget) to black.  I looked thru many tutorials
> and various docs, and I can't find out how.  I saw a section about GTK rc
> files, and attempted to use that, but it didn't work for me.
> 
> We specifically are NOT interested in creating an application with a
> "universal" look and feel, though I understand the desire when making an app
> for general distribution.  Our app is intended for a very small audience.

rc files do work, and are probably the best way to customize colors.

The other way is to call gtk_widget_modify_style(), something like this:

GtkRcStyle *rc_style = gtk_rc_style_new();

/* This tells it which attributes you are modifying. */
rc_style->color_flags[GTK_STATE_NORMAL] |= GTK_RC_BG;

rc_style->bg[GTK_STATE_NORMAL].red = 0xffff;
rc_style->bg[GTK_STATE_NORMAL].green = 0;
rc_style->bg[GTK_STATE_NORMAL].blue = 0;

gtk_widget_modify_style (widget, rc_style);


Damon