[gtk+/icon-shadow: 7/11] entry: ues gtk_render_icon()



commit ce662add68122a9901a92466cba0ccd1a0a629bf
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue May 24 20:02:23 2011 -0400

    entry: ues gtk_render_icon()

 gtk/gtkentry.c |   29 +++++++++++++++++++----------
 1 files changed, 19 insertions(+), 10 deletions(-)
---
diff --git a/gtk/gtkentry.c b/gtk/gtkentry.c
index b95fd8b..90c13a6 100644
--- a/gtk/gtkentry.c
+++ b/gtk/gtkentry.c
@@ -3338,6 +3338,9 @@ draw_icon (GtkWidget            *widget,
   GtkIconSource *icon_source;
   GtkStateFlags state;
 
+  cairo_surface_t *surface;
+  cairo_t *surface_cr;
+
   if (!icon_info)
     return;
 
@@ -3372,11 +3375,8 @@ draw_icon (GtkWidget            *widget,
   x = (width  - gdk_pixbuf_get_width (pixbuf)) / 2;
   y = (height - gdk_pixbuf_get_height (pixbuf)) / 2;
 
-  icon_source = gtk_icon_source_new ();
-  gtk_icon_source_set_pixbuf (icon_source, pixbuf);
-  gtk_icon_source_set_state_wildcarded (icon_source, TRUE);
+  state = GTK_STATE_FLAG_NORMAL;
 
-  state = 0;
   if (!gtk_widget_is_sensitive (widget) || icon_info->insensitive)
     state |= GTK_STATE_FLAG_INSENSITIVE;
   else if (icon_info->prelight)
@@ -3385,14 +3385,23 @@ draw_icon (GtkWidget            *widget,
   context = gtk_widget_get_style_context (widget);
   gtk_style_context_save (context);
   gtk_style_context_set_state (context, state);
-  pixbuf = gtk_render_icon_pixbuf (context, icon_source, (GtkIconSize)-1);
-  gtk_style_context_restore (context);
 
-  gtk_icon_source_free (icon_source);
+  surface = cairo_image_surface_create (CAIRO_FORMAT_ARGB32,
+                                        width, height);
+  surface_cr = cairo_create (surface);
+  gdk_cairo_set_source_pixbuf (surface_cr, pixbuf, 0, 0);
+  cairo_paint (surface_cr);
+  cairo_destroy (surface_cr);
 
-  gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
-  cairo_paint (cr);
+  gtk_render_icon (context, cr,
+                   x, y,
+                   width, height,
+                   surface,
+                   FALSE);
+
+  gtk_style_context_restore (context);
 
+  cairo_surface_destroy (surface);
   g_object_unref (pixbuf);
 }
 
@@ -6711,7 +6720,7 @@ create_normal_pixbuf (GtkStyleContext *context,
   gtk_style_context_save (context);
 
   /* Unset any state */
-  gtk_style_context_set_state (context, 0);
+  gtk_style_context_set_state (context, GTK_STATE_FLAG_NORMAL);
 
   icon_set = gtk_style_context_lookup_icon_set (context, stock_id);
   pixbuf = gtk_icon_set_render_icon_pixbuf (icon_set, context, icon_size);



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