=?utf-8?q?=5Bfolks=5D_Bug_656689_=E2=80=94_Re-link_personas_on_linkable_p?= =?utf-8?q?roperties_being_changed?=
- From: Raul Gutierrez Segales <raulgs src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Bug 656689 â Re-link personas on linkable properties being changed
- Date: Wed, 7 Sep 2011 22:19:46 +0000 (UTC)
commit cd1fd7f6cdd9ba89b248eb6096d43f9d8a660af0
Author: Philip Withnall <philip tecnocode co uk>
Date: Tue Sep 6 22:22:52 2011 +0100
Bug 656689 â Re-link personas on linkable properties being changed
Listen for notifications of changes to the linkable properties of every
persona in the IndividualAggregator. When we receive such a notification,
relink that persona by artificially removing them from the aggregator and
immediately re-adding them.
Like many things in the IndividualAggregator, this is ugly â but it appears
to work, and I can get my head around it.
Closes: bgo#656689
folks/individual-aggregator.vala | 45 ++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
---
diff --git a/folks/individual-aggregator.vala b/folks/individual-aggregator.vala
index 46007db..6d6669d 100644
--- a/folks/individual-aggregator.vala
+++ b/folks/individual-aggregator.vala
@@ -892,6 +892,44 @@ public class Folks.IndividualAggregator : Object
}
}
+ private void _persona_linkable_property_changed_cb (Object obj,
+ ParamSpec pspec)
+ {
+ /* The value of one of the linkable properties of one the personas has
+ * changed, so that persona might require re-linking. We do this in a
+ * simplistic and hacky way (which should work) by simply treating the
+ * persona as if it's been removed and re-added. */
+ var persona = obj as Persona;
+
+ debug ("Linkable property '%s' changed for persona '%s' " +
+ "(is user: %s, IID: %s).", pspec.name, persona.uid,
+ persona.is_user ? "yes" : "no", persona.iid);
+
+ var persona_set = new HashSet<Persona> ();
+ persona_set.add (persona);
+
+ this._personas_changed_cb (persona.store, persona_set, persona_set,
+ null, null, GroupDetails.ChangeReason.NONE);
+ }
+
+ private void _connect_to_persona (Persona persona)
+ {
+ foreach (var prop_name in persona.linkable_properties)
+ {
+ persona.notify[prop_name].connect (
+ this._persona_linkable_property_changed_cb);
+ }
+ }
+
+ private void _disconnect_from_persona (Persona persona)
+ {
+ foreach (var prop_name in persona.linkable_properties)
+ {
+ persona.notify[prop_name].disconnect (
+ this._persona_linkable_property_changed_cb);
+ }
+ }
+
private void _add_persona_to_link_map (Persona persona, Individual individual)
{
debug ("Connecting to Persona: %s (is user: %s, IID: %s)", persona.uid,
@@ -996,6 +1034,9 @@ public class Folks.IndividualAggregator : Object
removed_individuals.add (ind);
}
+ /* Stop listening to notifications about the persona's linkable
+ * properties. */
+ this._disconnect_from_persona (persona);
}
/* Remove the Individuals which were pointed to by the linkable properties
@@ -1039,6 +1080,10 @@ public class Folks.IndividualAggregator : Object
{
debug (" %s (is user: %s, IID: %s)", persona.uid,
persona.is_user ? "yes" : "no", persona.iid);
+
+ /* Connect to notifications about the persona's linkable
+ * properties. */
+ this._connect_to_persona (persona);
}
if (added.size > 0)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]