[gtk+] entry: always prepare the style context when using it for entry icons
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] entry: always prepare the style context when using it for entry icons
- Date: Wed, 30 Nov 2011 21:41:09 +0000 (UTC)
commit 5224302a30428ad64f6c819791dd6021a850aeca
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 b432f8b..f0b6cb7 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;
}
@@ -3337,30 +3364,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]