[gnome-contacts/new-design] Support editing nicknames
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts/new-design] Support editing nicknames
- Date: Thu, 15 Dec 2011 20:55:17 +0000 (UTC)
commit 904f33b5a81f132ab183684efa822b7397351873
Author: Alexander Larsson <alexl redhat com>
Date: Thu Dec 15 19:22:33 2011 +0100
Support editing nicknames
src/contacts-contact-pane.vala | 40 ++++++++++++++++++++++++++++++++++------
1 files changed, 34 insertions(+), 6 deletions(-)
---
diff --git a/src/contacts-contact-pane.vala b/src/contacts-contact-pane.vala
index 4e7720b..8232f96 100644
--- a/src/contacts-contact-pane.vala
+++ b/src/contacts-contact-pane.vala
@@ -1086,19 +1086,33 @@ class Contacts.BirthdayFieldSet : FieldSet {
}
}
-class Contacts.NicknameFieldRow : DataFieldRow {
- string nickname;
+class Contacts.StringFieldRow : DataFieldRow {
+ public string value;
Label text_label;
+ Entry? entry;
- public NicknameFieldRow (FieldSet field_set, string nickname) {
+ public StringFieldRow (FieldSet field_set, string value) {
base (field_set);
- this.nickname = nickname;
+ this.value = value;
text_label = this.pack_text ();
}
public override void update () {
- text_label.set_text (nickname);
+ text_label.set_text (value);
+ }
+
+ public override void pack_edit_widgets () {
+ entry = this.pack_entry (value);
+ setup_entry_for_edit (entry);
+ }
+
+ public override bool finish_edit_widgets (bool save) {
+ var changed = entry.get_text () != value;
+ if (save && changed)
+ value = entry.get_text ();
+ entry = null;
+ return changed;
}
}
@@ -1113,10 +1127,24 @@ class Contacts.NicknameFieldSet : FieldSet {
return;
if (is_set (details.nickname)) {
- var row = new NicknameFieldRow (this, details.nickname);
+ var row = new StringFieldRow (this, details.nickname);
add_row (row);
}
}
+ public override Value? get_value () {
+ var details = sheet.persona as NameDetails;
+ if (details == null)
+ return null;
+
+ var value = Value(typeof (string));
+ value.set_string ("");
+ foreach (var row in data_rows) {
+ var string_row = row as StringFieldRow;
+ value.set_string (string_row.value);
+ }
+
+ return value;
+ }
}
class Contacts.NoteFieldRow : DataFieldRow {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]