[gnome-contacts] Show availibility via phone by using an icon



commit e4a0cbeda1739544b76e55014db4231fbbd158f0
Author: Alexander Larsson <alexl redhat com>
Date:   Tue Aug 16 21:47:05 2011 +0200

    Show availibility via phone by using an icon
    
    Icons scale better and don't mix weirdly with custom away
    messages.
    
    Closes bug #653824

 src/contacts-contact.vala   |   24 +++++++++++++++++-------
 src/contacts-list-pane.vala |   20 +++++++++++---------
 2 files changed, 28 insertions(+), 16 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index fd449e6..f1bde99 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -28,10 +28,11 @@ public errordomain ContactError {
 public class Contacts.ContactPresence : Grid {
   Contact contact;
   Image image;
+  Image phone_image;
   Label label;
   string last_class;
 
-  private void update_presence_widgets (Image image, Label label) {
+  private void update_presence_widgets () {
     PresenceType type;
     string message;
     bool is_phone;
@@ -45,6 +46,7 @@ public class Contacts.ContactPresence : Grid {
       image.hide ();
       label.hide ();
       label.set_text ("");
+      phone_image.hide ();
       return;
     }
 
@@ -55,13 +57,16 @@ public class Contacts.ContactPresence : Grid {
     image.get_style_context ().add_class (last_class);
     image.show ();
     label.show ();
+    phone_image.show ();
     if (message.length == 0)
       message = Contact.presence_to_string (type);
 
-    if (is_phone) {
-      label.set_markup (GLib.Markup.escape_text (message) + " <span color='#8e9192'>(via phone)</span>");
-    } else
-      label.set_text (message);
+    label.set_text (message);
+
+    if (is_phone)
+      phone_image.show ();
+    else
+      phone_image.hide ();
   }
 
   public ContactPresence (Contact contact) {
@@ -78,10 +83,15 @@ public class Contacts.ContactPresence : Grid {
 
     this.add (label);
 
-    update_presence_widgets (image, label);
+    phone_image = new Image ();
+    phone_image.set_no_show_all (true);
+    phone_image.set_from_icon_name ("phone-symbolic", IconSize.MENU);
+    this.add (phone_image);
+
+    update_presence_widgets ();
 
     var id = contact.changed.connect ( () => {
-	update_presence_widgets (image, label);
+	update_presence_widgets ();
       });
 
     this.destroy.connect (() => {
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index e775c84..a943252 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -33,9 +33,10 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
 
   private struct IconShape {
     string icon;
+    bool colorize;
   }
 
-  Gdk.Pixbuf? create_symbolic_pixbuf (Widget widget, string icon_name, int size) {
+  Gdk.Pixbuf? create_symbolic_pixbuf (Widget widget, string icon_name, bool colorize, int size) {
     var screen = widget. get_screen ();
     var icon_theme = Gtk.IconTheme.get_for_screen (screen);
 
@@ -47,7 +48,8 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
 
     context.save ();
     bool is_symbolic;
-    context.add_class (Contact.presence_to_class (presence));
+    if (colorize)
+      context.add_class (Contact.presence_to_class (presence));
     Gdk.Pixbuf? pixbuf = null;
     try {
       pixbuf = info.load_symbolic_for_context (context,
@@ -84,6 +86,7 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
 			    CellRendererShape.IMAGE_SIZE*1024, CellRendererShape.IMAGE_SIZE*1024 };
       IconShape icon_shape = IconShape();
       icon_shape.icon = iconname;
+      icon_shape.colorize = true;
       a = new Pango.AttrShape<IconShape?>.with_data (r, r, icon_shape, (s) => { return s;} );
       a.start_index = str.length - 1;
       a.end_index = a.start_index + 1;
@@ -94,15 +97,14 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
 	  m = Contact.presence_to_string (presence);
 	str += " " + m;
 	if (is_phone) {
-	  if ((flags & CellRendererState.SELECTED) != 0)
-	    a = Pango.attr_foreground_new (0xffff-0x8e8e, 0xffff-0x9191, 0xffff-0x9292);
-	  else
-	    a = Pango.attr_foreground_new (0x8e8e, 0x9191, 0x9292);
+	  icon_shape = IconShape();
+	  icon_shape.icon = "phone-symbolic";
+	  a = new Pango.AttrShape<IconShape?>.with_data (r, r, icon_shape, (s) => { return s;});
 	  a.start_index = str.length;
-	  str += " (via phone)";
+	  str += "*";
 	  a.end_index = str.length;
 	  attr_list.insert ((owned) a);
-	}
+	  }
       }
     }
 
@@ -285,7 +287,7 @@ public class Contacts.CellRendererShape : Gtk.CellRenderer {
 
   public void render_shape (Cairo.Context cr, Pango.AttrShape attr, bool do_path) {
     unowned Pango.AttrShape<IconShape?> sattr = (Pango.AttrShape<IconShape?>)attr;
-    var pixbuf = create_symbolic_pixbuf (current_widget, sattr.data.icon, IMAGE_SIZE);
+    var pixbuf = create_symbolic_pixbuf (current_widget, sattr.data.icon, sattr.data.colorize, IMAGE_SIZE);
     if (pixbuf != null) {
       double x, y;
       cr.get_current_point (out x, out y);



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