[gtk+/icon-shadow: 3/12] themingengine: add gtk_theming_engine_render_icon()



commit 3ee74d4659a2234bdb4fda48b437638c145be4c0
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Mon Jun 6 10:23:06 2011 -0400

    themingengine: add gtk_theming_engine_render_icon()
    
    Renders a pixbuf in the provided rectangle, applying effects such as
    'icon-shadow'.

 gtk/gtkthemingengine.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 gtk/gtkthemingengine.h |    9 ++++++++-
 2 files changed, 54 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index e2580e7..275e3ae 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -177,6 +177,13 @@ static void gtk_theming_engine_render_activity  (GtkThemingEngine *engine,
 static GdkPixbuf * gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine    *engine,
                                                           const GtkIconSource *source,
                                                           GtkIconSize          size);
+static void gtk_theming_engine_render_icon (GtkThemingEngine *engine,
+                                            cairo_t *cr,
+                                            gdouble x,
+                                            gdouble y,
+                                            gdouble width,
+                                            gdouble height,
+					    GdkPixbuf *pixbuf);
 
 G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
 
@@ -215,6 +222,7 @@ gtk_theming_engine_class_init (GtkThemingEngineClass *klass)
   object_class->set_property = gtk_theming_engine_impl_set_property;
   object_class->get_property = gtk_theming_engine_impl_get_property;
 
+  klass->render_icon = gtk_theming_engine_render_icon;
   klass->render_check = gtk_theming_engine_render_check;
   klass->render_option = gtk_theming_engine_render_option;
   klass->render_arrow = gtk_theming_engine_render_arrow;
@@ -3259,3 +3267,41 @@ gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine    *engine,
 
   return stated;
 }
+
+static void
+gtk_theming_engine_render_icon (GtkThemingEngine *engine,
+                                cairo_t *cr,
+                                gdouble x,
+                                gdouble y,
+                                gdouble width,
+                                gdouble height,
+				GdkPixbuf *pixbuf)
+{
+  GtkStateFlags state;
+  GtkShadow *icon_shadow;
+
+  state = gtk_theming_engine_get_state (engine);
+
+  cairo_save (cr);
+
+  cairo_rectangle (cr, x, y,
+                   width, height);
+  cairo_clip (cr);
+
+  gdk_cairo_set_source_pixbuf (cr, pixbuf, x, y);
+
+  gtk_theming_engine_get (engine, state,
+                          "icon-shadow", &icon_shadow,
+                          NULL);
+
+  if (icon_shadow != NULL)
+    {
+      _gtk_icon_shadow_paint (icon_shadow, cr);
+      _gtk_shadow_unref (icon_shadow);
+    }
+
+  cairo_paint (cr);
+
+  cairo_restore (cr);
+}
+
diff --git a/gtk/gtkthemingengine.h b/gtk/gtkthemingengine.h
index b1d4b95..5f60e9e 100644
--- a/gtk/gtkthemingengine.h
+++ b/gtk/gtkthemingengine.h
@@ -168,9 +168,16 @@ struct _GtkThemingEngineClass
   GdkPixbuf * (* render_icon_pixbuf) (GtkThemingEngine    *engine,
                                       const GtkIconSource *source,
                                       GtkIconSize          size);
+  void (* render_icon) (GtkThemingEngine *engine,
+                        cairo_t          *cr,
+                        gdouble           x,
+                        gdouble           y,
+                        gdouble           width,
+                        gdouble           height,
+			GdkPixbuf        *pixbuf);
 
   /*< private >*/
-  gpointer padding[16];
+  gpointer padding[15];
 };
 
 GType gtk_theming_engine_get_type (void) G_GNUC_CONST;



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