[gnome-contacts] Use symbolic fallback avatar as per mockups



commit e40f49a47845651ebdc6765e2e904df7f5dfb7d3
Author: Alexander Larsson <alexl redhat com>
Date:   Mon Aug 22 14:23:31 2011 +0200

    Use symbolic fallback avatar as per mockups

 src/contacts-contact.vala |   19 +++++++++++++++++--
 1 files changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 6b3f7ed..5f8d06e 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -774,8 +774,23 @@ public class Contacts.Contact : GLib.Object  {
 
     Gdk.Pixbuf pixbuf = null;
     try {
-      var icon_info = IconTheme.get_default ().lookup_icon ("avatar-default-symbolic", size, IconLookupFlags.GENERIC_FALLBACK);
-      pixbuf = icon_info.load_icon ();
+      var cst = new Cairo.ImageSurface (Cairo.Format.ARGB32, size, size);
+      var cr = new Cairo.Context (cst);
+
+      var pat = new Cairo.Pattern.linear (0, 0, 0, size);
+      pat.add_color_stop_rgb (0, 0.937, 0.937, 0.937);
+      pat.add_color_stop_rgb (1, 0.969, 0.969, 0.969);
+
+      cr.set_source (pat);
+      cr.paint ();
+
+      int avatar_size = (int) (size * 0.3);
+      var icon_info = IconTheme.get_default ().lookup_icon ("avatar-default-symbolic", avatar_size,
+							    IconLookupFlags.GENERIC_FALLBACK);
+      Gdk.cairo_set_source_pixbuf (cr, icon_info.load_icon (), (size - avatar_size) / 2, (size - avatar_size) / 2);
+      cr.rectangle ((size - avatar_size) / 2, (size - avatar_size) / 2, avatar_size, avatar_size);
+      cr.fill ();
+      pixbuf = Gdk.pixbuf_get_from_surface (cst, 0, 0, size, size);
     } catch {
     }
 



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