[empathy] ui-utils: factor out pixbuf_round_corners()



commit 3cc222d662bc96186bbd19fa75e44ac98e54cbb1
Author: Guillaume Desmottes <guillaume desmottes collabora co uk>
Date:   Wed Jul 4 13:45:11 2012 +0200

    ui-utils: factor out pixbuf_round_corners()

 libempathy-gtk/empathy-ui-utils.c |   32 ++++++++++++++++++--------------
 1 files changed, 18 insertions(+), 14 deletions(-)
---
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index 8d4689a..a2f7a75 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -468,37 +468,41 @@ empathy_gdk_pixbuf_is_opaque (GdkPixbuf *pixbuf)
 }
 
 static GdkPixbuf *
-avatar_pixbuf_from_loader (GdkPixbufLoader *loader)
+pixbuf_round_corners (GdkPixbuf *pixbuf)
 {
-  GdkPixbuf *pixbuf;
-
-  pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+  GdkPixbuf *result;
 
   if (!gdk_pixbuf_get_has_alpha (pixbuf))
     {
-      GdkPixbuf *rounded_pixbuf;
-
-      rounded_pixbuf = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
+      result = gdk_pixbuf_new (GDK_COLORSPACE_RGB, TRUE, 8,
           gdk_pixbuf_get_width (pixbuf),
           gdk_pixbuf_get_height (pixbuf));
 
       gdk_pixbuf_copy_area (pixbuf, 0, 0,
           gdk_pixbuf_get_width (pixbuf),
           gdk_pixbuf_get_height (pixbuf),
-          rounded_pixbuf,
+          result,
           0, 0);
-
-      pixbuf = rounded_pixbuf;
     }
   else
     {
-      g_object_ref (pixbuf);
+      result = g_object_ref (pixbuf);
     }
 
-  if (empathy_gdk_pixbuf_is_opaque (pixbuf))
-    empathy_avatar_pixbuf_roundify (pixbuf);
+  if (empathy_gdk_pixbuf_is_opaque (result))
+    empathy_avatar_pixbuf_roundify (result);
 
-  return pixbuf;
+  return result;
+}
+
+static GdkPixbuf *
+avatar_pixbuf_from_loader (GdkPixbufLoader *loader)
+{
+  GdkPixbuf *pixbuf;
+
+  pixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
+
+  return pixbuf_round_corners (pixbuf);
 }
 
 static GdkPixbuf *



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