Port Individual.personas_changed to use Set<Persona>
authorPhilip Withnall <philip.withnall@collabora.co.uk>
Thu, 24 Mar 2011 15:12:00 +0000 (15:12 +0000)
committerPhilip Withnall <philip.withnall@collabora.co.uk>
Sat, 23 Apr 2011 21:00:16 +0000 (22:00 +0100)
Helps: bgo#640092

NEWS
folks/individual.vala

diff --git a/NEWS b/NEWS
index 58dcadd..f01be27 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -30,6 +30,7 @@ API changes:
     has been renamed folks_backend_store_get_enabled_backends(), and no longer
     returns an owned variable.
 * Individual.personas now has type Set<Persona>
+* Individual.personas_changed now uses Set<Persona>-typed parameters
 
 Overview of changes from libfolks 0.4.0 to libfolks 0.5.0
 =========================================================
index 9e9e6d0..40e5abe 100644 (file)
@@ -452,15 +452,16 @@ public class Folks.Individual : Object,
 
   /**
    * Emitted when one or more {@link Persona}s are added to or removed from
-   * the Individual.
+   * the Individual. As the parameters are (unordered) sets, the orders of their
+   * elements are undefined.
    *
-   * @param added a list of {@link Persona}s which have been added
-   * @param removed a list of {@link Persona}s which have been removed
+   * @param added a set of {@link Persona}s which have been added
+   * @param removed a set of {@link Persona}s which have been removed
    *
-   * @since 0.1.15
+   * @since UNRELEASED
    */
-  public signal void personas_changed (GLib.List<Persona>? added,
-      GLib.List<Persona>? removed);
+  public signal void personas_changed (Set<Persona> added,
+      Set<Persona> removed);
 
   private void _notify_alias_cb (Object obj, ParamSpec ps)
     {
@@ -608,18 +609,18 @@ public class Folks.Individual : Object,
 
   private void _store_removed_cb (PersonaStore store)
     {
-      GLib.List<Persona> removed_personas = null;
+      var removed_personas = new HashSet<Persona> ();
       var iter = this._persona_set.iterator ();
       while (iter.next ())
         {
           var persona = iter.get ();
 
-          removed_personas.prepend (persona);
+          removed_personas.add (persona);
           iter.remove ();
         }
 
       if (removed_personas != null)
-        this.personas_changed (null, removed_personas);
+        this.personas_changed (new HashSet<Persona> (), removed_personas);
 
       if (store != null)
         this._stores.unset (store);
@@ -640,19 +641,19 @@ public class Folks.Individual : Object,
       Persona? actor,
       GroupDetails.ChangeReason reason)
     {
-      GLib.List<Persona> removed_personas = null;
+      var removed_personas = new HashSet<Persona> ();
       removed.foreach ((data) =>
         {
           var p = (Persona) data;
 
           if (this._persona_set.remove (p))
             {
-              removed_personas.prepend (p);
+              removed_personas.add (p);
             }
         });
 
       if (removed_personas != null)
-        this.personas_changed (null, removed_personas);
+        this.personas_changed (new HashSet<Persona> (), removed_personas);
 
       if (this._persona_set.size < 1)
         {
@@ -1369,8 +1370,8 @@ public class Folks.Individual : Object,
   private void _set_personas (Set<Persona>? personas,
       Individual? replacement_individual)
     {
-      GLib.List<Persona> added = null;
-      GLib.List<Persona> removed = null;
+      var added = new HashSet<Persona> ();
+      var removed = new HashSet<Persona> ();
 
       /* Determine which Personas have been added. If personas == null, we
        * assume it's an empty set. */
@@ -1384,7 +1385,7 @@ public class Folks.Individual : Object,
                   if (p.is_user)
                     this._persona_user_count++;
 
-                  added.prepend (p);
+                  added.add (p);
 
                   this._persona_set.add (p);
                   this._connect_to_persona (p);
@@ -1420,7 +1421,7 @@ public class Folks.Individual : Object,
               if (p.is_user)
                 this._persona_user_count--;
 
-              removed.prepend (p);
+              removed.add (p);
 
               /* Decrement the Persona count for this PersonaStore */
               var store = p.store;