how to programmatically set colors of a GtkTextView
- From: "Boncek, John" <jboncek Hunter COM>
- To: <gtk-app-devel-list gnome org>
- Subject: how to programmatically set colors of a GtkTextView
- Date: Thu, 10 Feb 2005 11:36:56 -0600
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.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]