]> git.0d.be Git - empathy.git/commitdiff
ui-utils: factor out pixbuf_round_corners()
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 4 Jul 2012 11:45:11 +0000 (13:45 +0200)
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 4 Jul 2012 11:45:11 +0000 (13:45 +0200)
libempathy-gtk/empathy-ui-utils.c

index 8d4689ae1f7b0cefd3cc1d9de6af8d3d2fbb7f09..a2f7a75c6c85052992de9d41c640886475d1007e 100644 (file)
@@ -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 *