[folks] Use the alias from a writeable Persona in preference to other aliases
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Use the alias from a writeable Persona in preference to other aliases
- Date: Thu, 26 Aug 2010 21:19:59 +0000 (UTC)
commit b6e3d2cb6d730584160116f766d1a8fc5f090e37
Author: Philip Withnall <philip withnall collabora co uk>
Date: Wed Aug 25 16:33:28 2010 +0100
Use the alias from a writeable Persona in preference to other aliases
The writeable Persona's alias, if non-empty, is the one which has been set
by the user, so should be the preference.
folks/individual.vala | 26 ++++++++++++++++++++++++++
1 files changed, 26 insertions(+), 0 deletions(-)
---
diff --git a/folks/individual.vala b/folks/individual.vala
index b5d7099..bfe5a7b 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -482,6 +482,32 @@ public class Folks.Individual : Object,
string alias = null;
bool alias_is_display_id = false;
+ /* Search for an alias from a writeable Persona, and use it as our first
+ * choice if it's non-empty, since that's where the user-set alias is
+ * stored. */
+ foreach (Persona p in this._persona_list)
+ {
+ if (p is Alias && p.store.is_writeable == true)
+ {
+ unowned Alias a = (Alias) p;
+
+ if (a.alias != null && a.alias.strip () != "")
+ {
+ alias = a.alias;
+
+ /* Only notify if the value has changed */
+ if (this.alias != alias)
+ this.alias = alias;
+
+ return;
+ }
+ }
+ }
+
+ /* Since we can't find a non-empty alias from a writeable backend, try
+ * the aliases from other personas. Use a non-empty alias which isn't
+ * equal to the persona's display ID as our preference. If we can't find
+ * one of those, fall back to one which is equal to the display ID. */
foreach (Persona p in this._persona_list)
{
if (p is Alias)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]