Bug 560139 – GtkEntry doesn't paint with the right state

2008-11-12  Christian Dywan  <christian@imendio.com>

	Bug 560139 – GtkEntry doesn't paint with the right state

	* gtk/gtkentry.c (gtk_entry_class_init), (gtk_entry_draw_frame),
	(gtk_entry_expose): Reflect the right state if state-hint is set

svn path=/trunk/; revision=21787
This commit is contained in:
Christian Dywan 2008-11-12 16:11:30 +00:00 committed by Christian Dywan
parent ba9c358b53
commit 207f3f8685
2 changed files with 43 additions and 3 deletions

View File

@ -1,3 +1,10 @@
2008-11-12 Christian Dywan <christian@imendio.com>
Bug 560139 GtkEntry doesn't paint with the right state
* gtk/gtkentry.c (gtk_entry_class_init), (gtk_entry_draw_frame),
(gtk_entry_expose): Reflect the right state if state-hint is set
2008-11-12 Christian Dywan <christian@imendio.com> 2008-11-12 Christian Dywan <christian@imendio.com>
Bug 559619 invisible-char default cannot be tested Bug 559619 invisible-char default cannot be tested

View File

@ -987,6 +987,21 @@ gtk_entry_class_init (GtkEntryClass *class)
GTK_TYPE_BORDER, GTK_TYPE_BORDER,
GTK_PARAM_READABLE)); GTK_PARAM_READABLE));
/**
* GtkEntry:state-hint:
*
* Indicates whether to pass a proper widget state when
* drawing the shadow and the widget background.
*
* Since: 2.16
*/
gtk_widget_class_install_style_property (widget_class,
g_param_spec_boolean ("state-hint",
P_("State Hint"),
P_("Whether to pass a proper state when drawing shadow or background"),
FALSE,
GTK_PARAM_READABLE));
gtk_settings_install_property (g_param_spec_boolean ("gtk-entry-select-on-focus", gtk_settings_install_property (g_param_spec_boolean ("gtk-entry-select-on-focus",
P_("Select on focus"), P_("Select on focus"),
P_("Whether to select the contents of an entry when it is focused"), P_("Whether to select the contents of an entry when it is focused"),
@ -1719,6 +1734,8 @@ gtk_entry_draw_frame (GtkWidget *widget,
{ {
GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget); GtkEntryPrivate *priv = GTK_ENTRY_GET_PRIVATE (widget);
gint x = 0, y = 0, width, height; gint x = 0, y = 0, width, height;
gboolean state_hint;
GtkStateType state;
gdk_drawable_get_size (widget->window, &width, &height); gdk_drawable_get_size (widget->window, &width, &height);
@ -1743,9 +1760,16 @@ gtk_entry_draw_frame (GtkWidget *widget,
height -= 2 * priv->focus_width; height -= 2 * priv->focus_width;
} }
gtk_widget_style_get (widget, "state-hint", &state_hint, NULL);
if (state_hint)
state = GTK_WIDGET_HAS_FOCUS (widget) ?
GTK_STATE_ACTIVE : GTK_WIDGET_STATE (widget);
else
state = GTK_STATE_NORMAL;
gtk_paint_shadow (widget->style, widget->window, gtk_paint_shadow (widget->style, widget->window,
GTK_STATE_NORMAL, priv->shadow_type, state, priv->shadow_type,
area, widget, "entry", x, y, width, height); area, widget, "entry", x, y, width, height);
if (GTK_WIDGET_HAS_FOCUS (widget) && !priv->interior_focus) if (GTK_WIDGET_HAS_FOCUS (widget) && !priv->interior_focus)
{ {
@ -1765,6 +1789,8 @@ gtk_entry_expose (GtkWidget *widget,
GdkEventExpose *event) GdkEventExpose *event)
{ {
GtkEntry *entry = GTK_ENTRY (widget); GtkEntry *entry = GTK_ENTRY (widget);
gboolean state_hint;
GtkStateType state;
if (widget->window == event->window) if (widget->window == event->window)
gtk_entry_draw_frame (widget, &event->area); gtk_entry_draw_frame (widget, &event->area);
@ -1773,8 +1799,15 @@ gtk_entry_expose (GtkWidget *widget,
gint area_width, area_height; gint area_width, area_height;
gdk_drawable_get_size (entry->text_area, &area_width, &area_height); gdk_drawable_get_size (entry->text_area, &area_width, &area_height);
gtk_widget_style_get (widget, "state-hint", &state_hint, NULL);
if (state_hint)
state = GTK_WIDGET_HAS_FOCUS (widget) ?
GTK_STATE_ACTIVE : GTK_WIDGET_STATE (widget);
else
state = GTK_WIDGET_STATE(widget);
gtk_paint_flat_box (widget->style, entry->text_area, gtk_paint_flat_box (widget->style, entry->text_area,
GTK_WIDGET_STATE(widget), GTK_SHADOW_NONE, state, GTK_SHADOW_NONE,
&event->area, widget, "entry_bg", &event->area, widget, "entry_bg",
0, 0, area_width, area_height); 0, 0, area_width, area_height);