2009/2/26 <r.richardparker@xxxxxxxxxxx>: > 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: > Here's a derived GtkEntry (in Perl) that can use Pango markup: http://cpansearch.perl.org/src/POTYL/Gtk2-Ex-Entry-Pango-0.04/lib/Gtk2/Ex/Entry/Pango.pm If you download the bundle you will see some sample code how I use it. The code should be straight easily portable to any language. > > > > 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. > If you are using glade you will need to either create the entry fields that will use Pango as custom widgets or simply merge the code yourself. I have an application where the GUI is made through Glade and I found it easier to use a generic GtkEntry created by Glade and to simply add the proper callbacks to the widget. > > > Any suggestions? Using Pango in a GtkEntry is tricky. This is because the GtkEntry uses the MVC pattern. The text in the field is handled by Model but the text displayed is handled by the view. GtkEntry makes a distinction between both. If you change the data displayed through Pango it will not be permanent. The next redraw will erase your changes because the widget will simply perform the redraw based on the data stored. This problem can be easily be addressed by adding our own callback that will ensure that the widget is always drawn using Pango when needed. -- Emmanuel Rodriguez _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list