[gtk+/wip/icon-helper] entry: always prepare the style context when using it for entry icons



commit 2d2acf5e2557621757b65b6f0114a2b9144c6eab
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Wed Nov 30 11:40:32 2011 -0500

    entry: always prepare the style context when using it for entry icons
    
    Make sure to always prepare the entry's style context for the entry icon
    style when passing it to GtkIconHelper.

 gtk/gtkentry.c |   55 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 29 insertions(+), 26 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index a8235c5..dcbf369 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -2450,20 +2450,47 @@ gtk_entry_init (GtkEntry *entry)
   gtk_entry_update_cached_style_values (entry);
 }
 
+static void
+gtk_entry_prepare_context_for_icon (GtkEntry             *entry,
+                                    GtkStyleContext      *context,
+                                    GtkEntryIconPosition  icon_pos)
+{
+  GtkEntryPrivate *priv = entry->priv;
+  EntryIconInfo *icon_info = priv->icons[icon_pos];
+  GtkWidget *widget;
+  GtkStateFlags state;
+
+  widget = GTK_WIDGET (entry);
+  state = GTK_STATE_FLAG_NORMAL;
+
+  if (!gtk_widget_is_sensitive (widget) || icon_info->insensitive)
+    state |= GTK_STATE_FLAG_INSENSITIVE;
+  else if (icon_info->prelight)
+    state |= GTK_STATE_FLAG_PRELIGHT;
+
+  gtk_style_context_save (context);
+
+  gtk_style_context_set_state (context, state);
+  gtk_style_context_add_class (context, GTK_STYLE_CLASS_IMAGE);
+}
+
 static gint
 get_icon_width (GtkEntry             *entry,
                 GtkEntryIconPosition  icon_pos)
 {
   GtkEntryPrivate *priv = entry->priv;
   EntryIconInfo *icon_info = priv->icons[icon_pos];
+  GtkStyleContext *context;
   gint width;
 
   if (!icon_info)
     return 0;
 
-  _gtk_icon_helper_get_size (icon_info->icon_helper,
-                             gtk_widget_get_style_context (GTK_WIDGET (entry)),
+  context = gtk_widget_get_style_context (GTK_WIDGET (entry));
+  gtk_entry_prepare_context_for_icon (entry, context, icon_pos);
+  _gtk_icon_helper_get_size (icon_info->icon_helper, context,
                              &width, NULL);
+  gtk_style_context_restore (context);
 
   return width;
 }
@@ -3338,30 +3365,6 @@ should_prelight (GtkEntry             *entry,
 }
 
 static void
-gtk_entry_prepare_context_for_icon (GtkEntry             *entry,
-                                    GtkStyleContext      *context,
-                                    GtkEntryIconPosition  icon_pos)
-{
-  GtkEntryPrivate *priv = entry->priv;
-  EntryIconInfo *icon_info = priv->icons[icon_pos];
-  GtkWidget *widget;
-  GtkStateFlags state;
-
-  widget = GTK_WIDGET (entry);
-  state = GTK_STATE_FLAG_NORMAL;
-
-  if (!gtk_widget_is_sensitive (widget) || icon_info->insensitive)
-    state |= GTK_STATE_FLAG_INSENSITIVE;
-  else if (icon_info->prelight)
-    state |= GTK_STATE_FLAG_PRELIGHT;
-
-  gtk_style_context_save (context);
-
-  gtk_style_context_set_state (context, state);
-  gtk_style_context_add_class (context, GTK_STYLE_CLASS_IMAGE);
-}
-
-static void
 draw_icon (GtkWidget            *widget,
            cairo_t              *cr,
            GtkEntryIconPosition  icon_pos)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]