Here is a non-pango way: GdkColor color; color.red = 65535; color.green = 0; color.blue = 0; gtk_widget_modify_text(entry, GTK_STATE_NORMAL, &color); See http://library.gnome.org/devel/gtk/stable/gtk-question-index.html -Anthony From: gtk-list-bounces gnome org
[mailto:gtk-list-bounces gnome org] On Behalf Of r richardparker comcast net I have several
top-level windows which contain fill-in forms designed with GLADE 3 that
contain GtkTextEntry Widgets for data to be stored in a PostgreSQL database.
I'm validating the entries and when I find one that's invalid, I'd like to
change its text color to "red" and then post a message box indicating
that there were errors on the form. How do I change the text color in these
GTK_ENTRY widgets? These are not
labels, but single-line text entry fields. I'm guessing that Pango would be
involved, but how? As it is, a section of my validation code is as follows: gboolean
ValidateAll(EntryInfo entries[]) {
GtkWidget *entry;
gchar *text;
for (int i=0; entries[i].datafield != 0; i++)
{
entry = GTK_WIDGET(gtk_builder_get_object(builder, entries[i].textfield));
text = gtk_entry_get_text(GTK_ENTRY(entry));
if (!entries[i].validatefunc(text))
{
// this is where I want to change the color of the "textfield"'s text
to Red
// and then put it back into the form's entry and post a message box
...
...
} } I'd like to
process all of the entries before posting the message box, and then let the
user change the entries and attempt to post them to the database once again,
where they will once again validated, etc. Everything is
working except for my attempt to change the text color to highlight the
erroneous data. Help would be appreciated in how to use Pango (or something
else) to color the text. All the code is in
C, using Gtk+. The forms (windows) were designed with GLADE 3, but GLADE
doesn't offer a way to "markup" GtkEntry widgets, so I don't think I
can just store markup code into the erroneous entries. Any suggestions? |