[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]
Re: Color in GtkText
- From: Nigel Gamble <nigel nrg org>
- To: gtk-app-devel-list redhat com
- cc: sml13 cornell edu
- Subject: Re: Color in GtkText
- Date: Wed, 25 Nov 1998 09:31:21 -0800 (PST)
On Tue, 24 Nov 1998 sml13@cornell.edu wrote:
> I tried what you recommended, Nigel. And (like the last time) the only
> thing that it set right was the Font. Nothing else. The text background
> is still white and the numbers are still black. Do I have to get at the
> GtkTextWidget WITHIN the GtkEntry to set this stuff? That seems kind of
> ugly, but I suppose it's possible. Then I have to know about GtkEntry
> internals just to set a few properties of it! This can't be a Good Thing
> (tm). Any further advice would be greatly appreciated. Here is the
> relevant portion of the code that I am using verbatim:
It looks like, in a GtkEntry, the text color is style->fg (not
style->text) and the background is style->base (not style->bg).
This worked for me (I actually tried it this time):
GdkColor c;
GtkStyle *style;
GtkWidget *time;
time = gtk_entry_new();
c.red = 0;
c.green = 0xffff;
c.blue = 0;
gdk_color_alloc (gtk_widget_get_colormap (time), &c);
style = gtk_style_copy (gtk_widget_get_style (time));
style->text[GTK_STATE_NORMAL] = c;
style->fg[GTK_STATE_NORMAL] = c;
gdk_font_unref (style->font);
style->font = gdk_font_load
("-adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-iso8859-1");
c.red = 0;
c.green = 0;
c.blue = 0;
gdk_color_alloc (gtk_widget_get_colormap (time), &c);
style->bg[GTK_STATE_NORMAL] = c;
style->base[GTK_STATE_NORMAL] = c;
gtk_widget_set_style(time, style);
gtk_entry_set_text(GTK_ENTRY (time), "[0] 00:00.00");
Nigel Gamble nigel@nrg.org
Mountain View, CA, USA. http://www.nrg.org/
[Date Prev][Date Next] [Thread Prev][Thread Next]
[Thread Index]
[Date Index]
[Author Index]