[Xfce4-commits] <thunar:master> Use cairo in the icon renderers.

Nick Schermer noreply at xfce.org
Sat Oct 13 20:58:01 CEST 2012


Updating branch refs/heads/master
         to 8e90cfa3e9ec0d1d1248294d47ad61bab1f0950e (commit)
       from c4d3a3a9abe1977251779aa5427b854d2bc0435b (commit)

commit 8e90cfa3e9ec0d1d1248294d47ad61bab1f0950e
Author: Nick Schermer <nick at xfce.org>
Date:   Sat Oct 13 20:56:24 2012 +0200

    Use cairo in the icon renderers.

 thunar/thunar-icon-renderer.c           |   22 ++++++++++++++--------
 thunar/thunar-shortcuts-icon-renderer.c |   10 ++++++----
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/thunar/thunar-icon-renderer.c b/thunar/thunar-icon-renderer.c
index a42ed77..a8a073d 100644
--- a/thunar/thunar-icon-renderer.c
+++ b/thunar/thunar-icon-renderer.c
@@ -333,6 +333,7 @@ thunar_icon_renderer_render (GtkCellRenderer     *renderer,
   GList                  *lp;
   gint                    max_emblems;
   gint                    position;
+  cairo_t                *cr;
 
   if (G_UNLIKELY (icon_renderer->file == NULL))
     return;
@@ -378,6 +379,9 @@ thunar_icon_renderer_render (GtkCellRenderer     *renderer,
   icon_area.x = cell_area->x + (cell_area->width - icon_area.width) / 2;
   icon_area.y = cell_area->y + (cell_area->height - icon_area.height) / 2;
 
+  /* create the context */
+  cr = gdk_cairo_create (window);
+
   /* check whether the icon is affected by the expose event */
   if (gdk_rectangle_intersect (expose_area, &icon_area, &draw_area))
     {
@@ -438,10 +442,9 @@ thunar_icon_renderer_render (GtkCellRenderer     *renderer,
         }
 
       /* render the invalid parts of the icon */
-      gdk_draw_pixbuf (window, widget->style->black_gc, icon,
-                       draw_area.x - icon_area.x, draw_area.y - icon_area.y,
-                       draw_area.x, draw_area.y, draw_area.width, draw_area.height,
-                       GDK_RGB_DITHER_NORMAL, 0, 0);
+      gdk_cairo_set_source_pixbuf (cr, icon, icon_area.x, icon_area.y);
+      gdk_cairo_rectangle (cr, &draw_area);
+      cairo_fill (cr);
     }
 
   /* release the file's icon */
@@ -520,10 +523,10 @@ thunar_icon_renderer_render (GtkCellRenderer     *renderer,
               /* render the emblem */
               if (gdk_rectangle_intersect (expose_area, &emblem_area, &draw_area))
                 {
-                  gdk_draw_pixbuf (window, widget->style->black_gc, emblem,
-                                   draw_area.x - emblem_area.x, draw_area.y - emblem_area.y,
-                                   draw_area.x, draw_area.y, draw_area.width, draw_area.height,
-                                   GDK_RGB_DITHER_NORMAL, 0, 0);
+                  /* render the invalid parts of the icon */
+                  gdk_cairo_set_source_pixbuf (cr, emblem, emblem_area.x, emblem_area.y);
+                  gdk_cairo_rectangle (cr, &draw_area);
+                  cairo_fill (cr);
                 }
 
               /* release the emblem */
@@ -538,6 +541,9 @@ thunar_icon_renderer_render (GtkCellRenderer     *renderer,
         }
     }
 
+  /* destroy the context */
+  cairo_destroy (cr);
+
   /* release our reference on the icon factory */
   g_object_unref (G_OBJECT (icon_factory));
 }
diff --git a/thunar/thunar-shortcuts-icon-renderer.c b/thunar/thunar-shortcuts-icon-renderer.c
index b49de6a..b0a9529 100644
--- a/thunar/thunar-shortcuts-icon-renderer.c
+++ b/thunar/thunar-shortcuts-icon-renderer.c
@@ -220,6 +220,7 @@ thunar_shortcuts_icon_renderer_render (GtkCellRenderer     *renderer,
   GdkPixbuf                   *icon = NULL;
   GdkPixbuf                   *temp;
   GIcon                       *gicon;
+  cairo_t                     *cr;
 
   /* check if we have a volume set */
   if (G_UNLIKELY (shortcuts_icon_renderer->gicon != NULL
@@ -281,10 +282,11 @@ thunar_shortcuts_icon_renderer_render (GtkCellRenderer     *renderer,
           if (gdk_rectangle_intersect (expose_area, &icon_area, &draw_area))
             {
               /* render the invalid parts of the icon */
-              gdk_draw_pixbuf (window, widget->style->black_gc, icon,
-                               draw_area.x - icon_area.x, draw_area.y - icon_area.y,
-                               draw_area.x, draw_area.y, draw_area.width, draw_area.height,
-                               GDK_RGB_DITHER_NORMAL, 0, 0);
+              cr = gdk_cairo_create (window);
+              gdk_cairo_set_source_pixbuf (cr, icon, icon_area.x, icon_area.y);
+              gdk_cairo_rectangle (cr, &draw_area);
+              cairo_fill (cr);
+              cairo_destroy (cr);
             }
 
           /* cleanup */


More information about the Xfce4-commits mailing list