[gnome-contacts/new-design] Support edit emails
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts/new-design] Support edit emails
- Date: Thu, 15 Dec 2011 09:38:46 +0000 (UTC)
commit 33f034a30c70f5b4f88e8437be5780f263c36c24
Author: Alexander Larsson <alexl redhat com>
Date: Tue Dec 13 22:29:52 2011 +0100
Support edit emails
src/contacts-contact-pane.vala | 41 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 39 insertions(+), 2 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index b48769b..94944f1 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -795,9 +795,11 @@ class Contacts.LinkFieldSet : FieldSet {
}
class Contacts.EmailFieldRow : DataFieldRow {
- EmailFieldDetails details;
+ public EmailFieldDetails details;
Label text_label;
Label detail_label;
+ Entry? entry;
+ TypeCombo? combo;
public EmailFieldRow (FieldSet field_set, EmailFieldDetails details) {
base (field_set);
@@ -809,6 +811,26 @@ class Contacts.EmailFieldRow : DataFieldRow {
text_label.set_text (details.value);
detail_label.set_text (TypeSet.general.format_type (details));
}
+
+ public override void pack_edit_widgets () {
+ this.pack_entry_detail_combo (details.value, details, TypeSet.general, out entry, out combo);
+ entry.grab_focus ();
+ entry.activate.connect ( () => {
+ field_set.sheet.pane.exit_edit_mode (true);
+ });
+ }
+
+ public override bool finish_edit_widgets (bool save) {
+ var old_details = details;
+ bool changed = details.value != entry.get_text () || combo.modified;
+ if (save && changed) {
+ details = new EmailFieldDetails (entry.get_text (), old_details.parameters);
+ combo.update_details (details);
+ }
+ entry = null;
+ combo = null;
+ return changed;
+ }
}
class Contacts.EmailFieldSet : FieldSet {
@@ -827,6 +849,22 @@ class Contacts.EmailFieldSet : FieldSet {
add_row (row);
}
}
+ public override Value? get_value () {
+ var details = sheet.persona as EmailDetails;
+ if (details == null)
+ return null;
+
+ var new_details = new HashSet<EmailFieldDetails>();
+ foreach (var row in data_rows) {
+ var email_row = row as EmailFieldRow;
+ new_details.add (email_row.details);
+ }
+
+ var value = Value(new_details.get_type ());
+ value.set_object (new_details);
+
+ return value;
+ }
}
class Contacts.PhoneFieldRow : DataFieldRow {
@@ -838,7 +876,6 @@ class Contacts.PhoneFieldRow : DataFieldRow {
base (field_set);
this.details = details;
this.pack_text_detail (out text_label, out detail_label);
-
}
public override void update () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]