Re: Setting the background color of a GtkEntry
- From: Andreas Stricker <andreas stricker fela ch>
- To: gtk-app-devel-list gnome org
- Subject: Re: Setting the background color of a GtkEntry
- Date: Fri, 25 Nov 2005 09:28:41 +0100
Michal Kepien schrieb:
The white part of a text-accepting widget uses the "base" color, not
the "bg" color. The only way I know to set that is with a style:
style "myEntry"
{
base[NORMAL] = "#ff0000" # or whatever
}
class "GtkEntry" style "myEntry"
You can load this setting by placing that text in a file called "foo"
and then calling gtk_rc_parse("foo"), or you can put it in a string
called "bar" and call gtk_rc_parse_string(bar).
This is some progress... However, what I want to achieve is to dynamically
change the background color without reopening the window (what I want to use the
color change for is validating input - if something's wrong then the entry goes
red, if the entry gets corrected it should be white again). Is it possible to
force a refresh and instantly change the background color of the GtkEntry? When
I use gtk_rc_parse_string() in the callback, it works, but the entry's color is
changed after i TAB a few entries forward.
You can change the style direct over the style interface. The
function gtk_widget_modify_style() should do the trick:
http://www.gtk.org/api/2.6/gtk/GtkWidget.html#gtk-widget-modify-style
http://www.gtk.org/api/2.6/gtk/gtk-Resource-Files.html
http://www.gtk.org/api/2.6/gtk/GtkStyle.html
The style change should apply immediately AFAIK.
Cheers,
Andy
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]