[gnome-contacts] Update contacts when the individual changes



commit e8fc45cd3fd347463d98b9559adb3c6132500c64
Author: Alexander Larsson <alexl redhat com>
Date:   Thu May 12 14:02:55 2011 +0200

    Update contacts when the individual changes

 src/contacts-contact.vala |   20 ++++++++++++++++++--
 1 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 0774189..cab1f21 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -45,6 +45,7 @@ public class Contacts.Contact : GLib.Object  {
   public Individual individual;
   public ContactStore store;
   private TreeIter iter;
+  ulong changed_id;
 
   private Gdk.Pixbuf? _avatar;
   public Gdk.Pixbuf avatar { 
@@ -74,9 +75,9 @@ public class Contacts.Contact : GLib.Object  {
     store.append (out iter);
     store.set (iter, 0, this);
 
+
     individual.notify.connect( (pspec) => {
-	update ();
-	stdout.printf ("changed: %s\n", pspec.get_name());
+	queue_changed ();
       });
   }
 
@@ -92,6 +93,21 @@ public class Contacts.Contact : GLib.Object  {
     return true;
   }
 
+  private bool changed_cb () {
+    changed_id = 0;
+    update ();
+    var path = store.get_path (iter);
+    store.row_changed (path, iter);
+    return false;
+  }
+
+  private void queue_changed () {
+    if (changed_id != 0)
+      return;
+
+    changed_id = Idle.add (changed_cb);
+  }
+
   private void update () {
     var builder = new StringBuilder ();
     if (individual.alias != null) {



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