]> Pileus Git - ~andy/gtk/commitdiff
Bug 560139 – GtkEntry doesn't paint with the right state
authorChristian Dywan <christian@imendio.com>
Wed, 12 Nov 2008 16:11:30 +0000 (16:11 +0000)
committerChristian Dywan <cdywan@src.gnome.org>
Wed, 12 Nov 2008 16:11:30 +0000 (16:11 +0000)
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

ChangeLog
gtk/gtkentry.c

index 7f80c954a7013094a7bd34fb43ed5ed220896801..b97f470c1a59d6314fc5498c8911eb666f6406d0 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
 
        Bug 559619 – invisible-char default cannot be tested
index 9aedc510611d218d1f6126dafa2aac5d694a9093..c620bc80465d1a51abd257d16b2cf3106c331cf1 100644 (file)
@@ -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);