Changing Text Color for GTK_ENTRY Widgets



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?



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