[gnome-contacts] Add all custom labels seen to the TypeSet



commit efe695ac141655a0519be245d108f773fc49beb0
Author: Alexander Larsson <alexl redhat com>
Date:   Wed Jun 22 14:35:23 2011 +0200

    Add all custom labels seen to the TypeSet

 src/contacts-contact.vala |    8 ++++++++
 src/contacts-types.vala   |    7 +++++++
 2 files changed, 15 insertions(+), 0 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 6b63d1b..f455cd4 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -532,6 +532,14 @@ public class Contacts.Contact : GLib.Object  {
   }
 
   private void update () {
+    foreach (var email in individual.email_addresses) {
+      TypeSet.general.type_seen (email);
+    }
+
+    foreach (var phone in individual.phone_numbers) {
+      TypeSet.phone.type_seen (phone);
+    }
+
     update_presence ();
     update_filter_data ();
   }
diff --git a/src/contacts-types.vala b/src/contacts-types.vala
index d0d9d3c..1e939d2 100644
--- a/src/contacts-types.vala
+++ b/src/contacts-types.vala
@@ -300,4 +300,11 @@ public class Contacts.TypeSet : Object  {
     store.set (iter, 0, label, 1, null);
     custom_hash.insert (label, iter);
   }
+
+  public void type_seen (FieldDetails detail) {
+    if (detail.parameters.contains ("x-google-label")) {
+      var label = get_first_string (detail.parameters.get ("x-google-label"));
+      add_custom_label (label, null);
+    }
+  }
 }



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