[folks] Make Individual implement the PostalAddressOwner interface
- From: Travis Reitter <treitter src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks] Make Individual implement the PostalAddressOwner interface
- Date: Thu, 3 Mar 2011 19:48:03 +0000 (UTC)
commit e14a7a0c486edd04971d457af9bdbe101dba3781
Author: Marco Barisione <marco barisione org>
Date: Tue Dec 28 17:28:12 2010 +0100
Make Individual implement the PostalAddressOwner interface
folks/individual.vala | 46 ++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 46 insertions(+), 0 deletions(-)
---
diff --git a/folks/individual.vala b/folks/individual.vala
index cbbb15f..9605c8e 100644
--- a/folks/individual.vala
+++ b/folks/individual.vala
@@ -75,6 +75,7 @@ public class Folks.Individual : Object,
NoteOwner,
PresenceOwner,
Phoneable,
+ PostalAddressOwner,
RoleOwner,
Urlable
{
@@ -331,6 +332,22 @@ public class Folks.Individual : Object,
}
}
+ private GLib.List<PostalAddress> _postal_addresses;
+ /**
+ * { inheritDoc}
+ */
+ public GLib.List<PostalAddress> postal_addresses
+ {
+ get { return this._postal_addresses; }
+ private set
+ {
+ this._postal_addresses = new GLib.List<PostalAddress> ();
+ foreach (PostalAddress pa in value)
+ this._postal_addresses.prepend (pa);
+ this._postal_addresses.reverse ();
+ }
+ }
+
/**
* Whether this Individual is a user-defined favourite.
*
@@ -466,6 +483,11 @@ public class Folks.Individual : Object,
this._update_phone_numbers ();
}
+ private void _notify_postal_addresses_cb ()
+ {
+ this._update_postal_addresses ();
+ }
+
private void _notify_email_addresses_cb ()
{
this._update_email_addresses ();
@@ -627,6 +649,7 @@ public class Folks.Individual : Object,
this._update_roles ();
this._update_birthday ();
this._update_notes ();
+ this._update_postal_addresses ();
}
private void _update_groups ()
@@ -911,6 +934,8 @@ public class Folks.Individual : Object,
persona.notify["roles"].connect (this._notify_roles_cb);
persona.notify["birthday"].connect (this._notify_birthday_cb);
persona.notify["notes"].connect (this._notify_notes_cb);
+ persona.notify["postal_addresses"].connect
+ (this._notify_postal_addresses_cb);
if (persona is Groupable)
{
@@ -1003,6 +1028,9 @@ public class Folks.Individual : Object,
persona.notify["roles"].disconnect (this._notify_roles_cb);
persona.notify["birthday"].disconnect (this._notify_birthday_cb);
persona.notify["notes"].disconnect (this._notify_notes_cb);
+ persona.notify["postal_addresses"].disconnect
+ (this._notify_postal_addresses_cb);
+
if (persona is Groupable)
{
@@ -1152,6 +1180,24 @@ public class Folks.Individual : Object,
this.notify_property ("roles");
}
+ private void _update_postal_addresses ()
+ {
+ this._postal_addresses = new GLib.List<PostalAddress> ();
+ /* FIXME: Detect duplicates somehow? */
+ foreach (var persona in this._persona_list)
+ {
+ var address_owner = persona as PostalAddressOwner;
+ if (address_owner != null)
+ {
+ foreach (unowned PostalAddress pa in address_owner.postal_addresses)
+ this._postal_addresses.append (pa);
+ }
+ }
+ this._postal_addresses.reverse ();
+
+ this.notify_property ("postal-addresses");
+ }
+
private void _update_birthday ()
{
unowned DateTime bday = null;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]