[gtk+] themingengine: add gtk_theming_engine_render_icon()



commit 2446aef0ea695fd8d4ac9959db6d3106dde77a0b
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 |   38 ++++++++++++++++++++++++++++++++++++++
 gtk/gtkthemingengine.h |    8 +++++++-
 2 files changed, 45 insertions(+), 1 deletions(-)
---
diff --git a/gtk/gtkthemingengine.c b/gtk/gtkthemingengine.c
index 9cb7e33..367f07c 100644
--- a/gtk/gtkthemingengine.c
+++ b/gtk/gtkthemingengine.c
@@ -177,6 +177,11 @@ 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,
+					    GdkPixbuf *pixbuf,
+                                            gdouble x,
+                                            gdouble y);
 
 G_DEFINE_TYPE (GtkThemingEngine, gtk_theming_engine, G_TYPE_OBJECT)
 
@@ -215,6 +220,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;
@@ -3230,3 +3236,35 @@ gtk_theming_engine_render_icon_pixbuf (GtkThemingEngine    *engine,
 
   return stated;
 }
+
+static void
+gtk_theming_engine_render_icon (GtkThemingEngine *engine,
+                                cairo_t *cr,
+				GdkPixbuf *pixbuf,
+                                gdouble x,
+                                gdouble y)
+{
+  GtkStateFlags state;
+  GtkShadow *icon_shadow;
+
+  state = gtk_theming_engine_get_state (engine);
+
+  cairo_save (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..148bbd2 100644
--- a/gtk/gtkthemingengine.h
+++ b/gtk/gtkthemingengine.h
@@ -69,6 +69,7 @@ struct _GtkThemingEngine
  * @render_activity: Renders an area displaying activity, such as in #GtkSpinner,
  *                   or #GtkProgressBar.
  * @render_icon_pixbuf: Renders an icon as a #GdkPixbuf.
+ * @render_icon: Renders an icon given as a #GdkPixbuf.
  *
  * Base class for theming engines.
  */
@@ -168,9 +169,14 @@ struct _GtkThemingEngineClass
   GdkPixbuf * (* render_icon_pixbuf) (GtkThemingEngine    *engine,
                                       const GtkIconSource *source,
                                       GtkIconSize          size);
+  void (* render_icon) (GtkThemingEngine *engine,
+                        cairo_t          *cr,
+			GdkPixbuf        *pixbuf,
+                        gdouble           x,
+                        gdouble           y);
 
   /*< 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]