From 207f3f8685f21bbade8ae0a6551a0e92d6baad89 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Wed, 12 Nov 2008 16:11:30 +0000 Subject: [PATCH] =?UTF-8?q?Bug=20560139=20=E2=80=93=20GtkEntry=20doesn't?= =?UTF-8?q?=20paint=20with=20the=20right=20state?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 2008-11-12 Christian Dywan 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 --- ChangeLog | 7 +++++++ gtk/gtkentry.c | 39 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 43 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f80c954a7..b97f470c1a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-11-12 Christian Dywan + + 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 Bug 559619 – invisible-char default cannot be tested diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c index 9aedc51061..c620bc8046 100644 --- a/gtk/gtkentry.c +++ b/gtk/gtkentry.c @@ -987,6 +987,21 @@ gtk_entry_class_init (GtkEntryClass *class) GTK_TYPE_BORDER, 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", P_("Select on focus"), 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); gint x = 0, y = 0, width, height; + gboolean state_hint; + GtkStateType state; gdk_drawable_get_size (widget->window, &width, &height); @@ -1743,9 +1760,16 @@ gtk_entry_draw_frame (GtkWidget *widget, 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_STATE_NORMAL, priv->shadow_type, - area, widget, "entry", x, y, width, height); + state, priv->shadow_type, + area, widget, "entry", x, y, width, height); if (GTK_WIDGET_HAS_FOCUS (widget) && !priv->interior_focus) { @@ -1765,6 +1789,8 @@ gtk_entry_expose (GtkWidget *widget, GdkEventExpose *event) { GtkEntry *entry = GTK_ENTRY (widget); + gboolean state_hint; + GtkStateType state; if (widget->window == event->window) gtk_entry_draw_frame (widget, &event->area); @@ -1773,8 +1799,15 @@ gtk_entry_expose (GtkWidget *widget, gint 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_WIDGET_STATE(widget), GTK_SHADOW_NONE, + state, GTK_SHADOW_NONE, &event->area, widget, "entry_bg", 0, 0, area_width, area_height);