Re: Color in GtkText
- From: sml13 cornell edu
- To: gtk-app-devel-list redhat com, gtk-list redhat com
- Subject: Re: Color in GtkText
- Date: Tue, 24 Nov 1998 18:56:51 -0500 (EST)
I had a similar problem that I posted to GTK-list a while back, and
no-one really gave me a satisfactory response other than "you should use
themes to do this." Well, no, I want it to be a static property of
the app so themes aren't an option. What I wanted to do is set
the color of the text and background of a gtk_entry by doing (I thought):
time = gtk_entry_new ();
style = gtk_style_new ();
style->font = gdk_font_load
("-adobe-helvetica-bold-r-normal-*-*-240-*-*-p-*-iso8859-1");
style->text[GTK_STATE_NORMAL].red = 0;
style->text[GTK_STATE_NORMAL].green = 1;
style->text[GTK_STATE_NORMAL].blue = 0;
style->bg[GTK_STATE_NORMAL] = style->black;
gtk_widget_set_style (time, style);
You see, I want my time display to have alien green digits (this is for a
CD Player) on a black background...but this doesn't work! I DO NOT want
this to vary with the themes, so theming to this isn't an option. I want
to know how to do this (and, generallly, set the attributs of any widget
like this) PROGRAMMATICALLY. Any ideas?
shane
On Tue, 24 Nov 1998, Gert Scholten wrote:
> Hi,
>
> I've got a problem and I /really/ can't find it ...
> I've created a kinda parser to parse escape codes in a GtkText. Until recently
> I didn't know how styles worked, so I was stuck with the standard (white)
> GtkText BG. When I figured out I only had to set the
> ->style->base[GTK_STATE_NORMAL] and the
> ->style->text[GTK_STATE_NORMAL] for the standard FG and BG colors to be
> switched. So this worked. The next thing was to let the user configure the
> values of the colors. I created a list GdkColor *fgcolor[8] for the bg a
> similar one.
>
> The problem suddenly appears here. A "\e[0m" sets both FGcolor and BGcolor that
> are passed to gtk_text_insert to NULL, so the default value will be used. The
> wierdness comes with the BG colors. If I only have a BG color set, and the
> FGcolor is set to NULL I get there errors:
> ---
> Gdk-CRITICAL **: file gdkcolor.c: line 1115 (gdk_color_equal): assertion
> `colorb != NULL' failed.
> ---
> One for evry gtk_text_insert call. However, if I insert text with a FG color
> /before/ any text with a BG color, the BG colors won't display anymore.
> The arrors dissapear along with the BG color.
>
> Then if I use a BG color simultaniously with a FG color it works fine ...
>
> (all colors are properly allocated)
>
> I'm really in the dark now ...
>
> Anyone a idea ???
>
> Gert ...
>
>
> --
> To unsubscribe: mail gtk-app-devel-list-request@redhat.com with
> "unsubscribe" as the Subject.
>
> Mailing list concerns should be mailed to <listmaster@redhat.com>
>
>
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]