summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2011-03-07 11:59:33 +0100
committerCarlos Garnacho <carlosg@gnome.org>2011-03-07 12:48:31 +0100
commitb93a2ebeedd656af65e0ef536cad4d5e8614f193 (patch)
treea34f375d4dd953519c047d6ba52fa6401264cf03
parenta3b3c91001840908891c1954a35c6892ca569e6e (diff)
downloadgtk+-b93a2ebeedd656af65e0ef536cad4d5e8614f193.tar.gz
entry: Do not clobber state when rendering the default icons.
Use lower level methods that just require changing the state in the GtkStyleContext instead. Fixes a problem where the insensitive state was being set to the entry becasuse a parent was insensitive, spotted by Alex Larsson.
-rw-r--r--gtk/gtkentry.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index e468fcbf48..84f7204470 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -6570,16 +6570,37 @@ gtk_entry_clear (GtkEntry *entry,
g_object_thaw_notify (G_OBJECT (entry));
}
+static GdkPixbuf *
+create_normal_pixbuf (GtkStyleContext *context,
+ const gchar *stock_id,
+ GtkIconSize icon_size)
+{
+ GtkIconSet *icon_set;
+ GdkPixbuf *pixbuf;
+
+ gtk_style_context_save (context);
+
+ /* Unset any state */
+ gtk_style_context_set_state (context, 0);
+
+ icon_set = gtk_style_context_lookup_icon_set (context, stock_id);
+ pixbuf = gtk_icon_set_render_icon_pixbuf (icon_set, context, icon_size);
+
+ gtk_style_context_restore (context);
+
+ return pixbuf;
+}
+
static void
gtk_entry_ensure_pixbuf (GtkEntry *entry,
GtkEntryIconPosition icon_pos)
{
GtkEntryPrivate *priv = entry->priv;
EntryIconInfo *icon_info = priv->icons[icon_pos];
+ GtkStyleContext *context;
GtkIconInfo *info;
GtkIconTheme *icon_theme;
GtkSettings *settings;
- GtkStateFlags state;
GtkWidget *widget;
GdkScreen *screen;
gint width, height;
@@ -6588,6 +6609,7 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry,
return;
widget = GTK_WIDGET (entry);
+ context = gtk_widget_get_style_context (widget);
switch (icon_info->storage_type)
{
@@ -6595,16 +6617,13 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry,
case GTK_IMAGE_PIXBUF:
break;
case GTK_IMAGE_STOCK:
- state = gtk_widget_get_state_flags (widget);
- gtk_widget_set_state_flags (widget, 0, TRUE);
- icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
- icon_info->stock_id,
- GTK_ICON_SIZE_MENU);
+ icon_info->pixbuf = create_normal_pixbuf (context, icon_info->stock_id,
+ GTK_ICON_SIZE_MENU);
+
if (!icon_info->pixbuf)
- icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
- GTK_STOCK_MISSING_IMAGE,
- GTK_ICON_SIZE_MENU);
- gtk_widget_set_state_flags (widget, state, TRUE);
+ icon_info->pixbuf = create_normal_pixbuf (context,
+ GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_MENU);
break;
case GTK_IMAGE_ICON_NAME:
@@ -6624,14 +6643,9 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry,
0, NULL);
if (icon_info->pixbuf == NULL)
- {
- state = gtk_widget_get_state_flags (widget);
- gtk_widget_set_state_flags (widget, 0, TRUE);
- icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
- GTK_STOCK_MISSING_IMAGE,
- GTK_ICON_SIZE_MENU);
- gtk_widget_set_state_flags (widget, state, TRUE);
- }
+ icon_info->pixbuf = create_normal_pixbuf (context,
+ GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_MENU);
}
break;
@@ -6657,14 +6671,9 @@ gtk_entry_ensure_pixbuf (GtkEntry *entry,
}
if (icon_info->pixbuf == NULL)
- {
- state = gtk_widget_get_state_flags (widget);
- gtk_widget_set_state_flags (widget, 0, TRUE);
- icon_info->pixbuf = gtk_widget_render_icon_pixbuf (widget,
- GTK_STOCK_MISSING_IMAGE,
- GTK_ICON_SIZE_MENU);
- gtk_widget_set_state_flags (widget, state, TRUE);
- }
+ icon_info->pixbuf = create_normal_pixbuf (context,
+ GTK_STOCK_MISSING_IMAGE,
+ GTK_ICON_SIZE_MENU);
}
break;