RE: how to programmatically set colors of a GtkTextView -- resolved



The resolution seems too obvious now that I've stumbled over it, but you
use the functions gtk_widget_modify_text instead of gtk_widget_modify_fg,
and gtk_widget_modify_base instead of gtk_widget_modify_bg with
GtkTextView.

Forgive me for suggesting that perhaps there are a few too many functions,
graphics contexts, properties, styles, etc., involved in color control.

-----Original Message-----
From: gtk-app-devel-list-bounces gnome org
[mailto:gtk-app-devel-list-bounces gnome org]On Behalf Of Boncek, John
Sent: Thursday, February 10, 2005 11:37 AM
To: gtk-app-devel-list gnome org
Subject: how to programmatically set colors of a GtkTextView


I'm trying to set the text color and background color of a GtkTextView.
I've read Havoc Pennington's mini-FAQ.  He gives the following example of
how to set a color in GTK 2.0:

  GdkColor color;

  gdk_color_parse ("red", &color);

  gtk_widget_modify_fg (widget, GTK_STATE_NORMAL, &color);

But this doesn't seem to work in this case, using GTK 2.2.4.  Here's the
code used, with silly colors just to make it obvious as to whether it's
working.

        // create the TextView
        m_pTextView = gtk_text_view_new();
        
        GdkColor color;

        gdk_color_parse ("red", &color);

        gtk_widget_modify_fg (m_pTextView, GTK_STATE_NORMAL, &color);

        gdk_color_parse ("blue", &color);

        gtk_widget_modify_bg (m_pTextView, GTK_STATE_NORMAL, &color);

The text view does display and accepts keyboard input but the colors
displayed are black-on-white.  The mini-FAQ also says that some widgets
use the "text" color instead of the foreground color but doesn't say how
to set that.



_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list



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