[gnome-contacts] Write details to personas like Tpf.Personas.
- From: Erick PÃrez Castellanos <erickpc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Write details to personas like Tpf.Personas.
- Date: Sat, 16 Feb 2013 18:02:32 +0000 (UTC)
commit d709d88916c63e658cc156993075e0c19294548b
Author: Erick PÃrez Castellanos <erick red gmail com>
Date: Sat Feb 16 08:42:17 2013 -0500
Write details to personas like Tpf.Personas.
There's personas that won't have the details I want to add
as writeable properties. e.g. Tpf.Persona doesn't have 'email-addresses'
as wrietable.
src/contacts-contact-editor.vala | 16 ++++++++++++++--
src/contacts-contact.vala | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/contacts-contact-editor.vala b/src/contacts-contact-editor.vala
index 96e1d23..459c8a7 100644
--- a/src/contacts-contact-editor.vala
+++ b/src/contacts-contact-editor.vala
@@ -55,6 +55,8 @@ public class Contacts.AddressEditor : Grid {
}
public class Contacts.ContactEditor : Grid {
+ Contact contact;
+
public struct PropertyData {
Persona persona;
Value value;
@@ -630,6 +632,8 @@ public class Contacts.ContactEditor : Grid {
}
public void update (Contact c) {
+ contact = c;
+
var image_frame = new ContactFrame (PROFILE_SIZE, true);
image_frame.set_vexpand (false);
image_frame.set_valign (Align.START);
@@ -767,8 +771,16 @@ public class Contacts.ContactEditor : Grid {
return v;
}
- public void add_new_row_for_property (Persona p, string prop_name, string? type = null) {
+ public void add_new_row_for_property (Persona? p, string prop_name, string? type = null) {
/* Somehow, I need to ensure that p is the main/default/first persona */
+ Persona persona;
+ if (p == null) {
+ persona = new FakePersona (contact);
+ writable_personas.set (persona, new HashMap<string, Field?> ());
+ } else {
+ persona = p;
+ }
+
int next_idx = 0;
foreach (var fields in writable_personas.values) {
if (fields.has_key (prop_name)) {
@@ -781,7 +793,7 @@ public class Contacts.ContactEditor : Grid {
}
next_idx = (next_idx == 0 ? last_row : next_idx) + 1;
insert_row_at (next_idx);
- add_edit_row (p, prop_name, ref next_idx, true, type);
+ add_edit_row (persona, prop_name, ref next_idx, true, type);
last_row++;
show_all ();
}
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 3a67386..89b293e 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -1362,6 +1362,7 @@ public class Contacts.Contact : GLib.Object {
if (persona is FakePersona) {
var fake = persona as FakePersona;
yield fake.make_real_and_set (property_name, new_value);
+ return;
}
/* FIXME: It should be possible to move these all to being delegates which are
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]