[gnome-contacts] Update contact info if it changes
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Update contact info if it changes
- Date: Wed, 18 May 2011 11:40:43 +0000 (UTC)
commit 5d7272010c537f50193a471edd9752cde4c9f38e
Author: Alexander Larsson <alexl redhat com>
Date: Wed May 18 13:39:35 2011 +0200
Update contact info if it changes
src/contacts-app.vala | 39 ++++++++++++++++++++++++++-------------
src/contacts-contact.vala | 3 +++
2 files changed, 29 insertions(+), 13 deletions(-)
---
diff --git a/src/contacts-app.vala b/src/contacts-app.vala
index 0846b4d..baf53b4 100644
--- a/src/contacts-app.vala
+++ b/src/contacts-app.vala
@@ -24,6 +24,7 @@ public class Contacts.App : Window {
private ContactStore contacts_store;
private TreeModelFilter filter_model;
private Entry filter_entry;
+ private Contact selected_contact;
string []? filter_values;
bool filter_favourites;
TreeView contacts_tree_view;
@@ -39,7 +40,7 @@ public class Contacts.App : Window {
var selection = tree_view.get_selection ();
selection.set_mode (SelectionMode.BROWSE);
- selection.changed.connect (contacts_selected_changed);
+ selection.changed.connect (contacts_selection_changed);
var column = new TreeViewColumn ();
column.set_spacing (10);
@@ -267,26 +268,38 @@ public class Contacts.App : Window {
fields_grid.show_all ();
}
- private void contacts_selected_changed (TreeSelection selection) {
+ private void clear_display () {
+ foreach (var w in card_grid.get_children ()) {
+ w.destroy ();
+ }
+ foreach (var w in fields_grid.get_children ()) {
+ w.destroy ();
+ }
+ }
+
+ private void selected_contact_changed () {
+ clear_display ();
+ display_contact (selected_contact);
+ }
+
+ private void contacts_selection_changed (TreeSelection selection) {
TreeIter iter;
TreeModel model;
+ if (selected_contact != null)
+ selected_contact.changed.disconnect (selected_contact_changed);
+ clear_display ();
+ selected_contact = null;
+
if (selection.get_selected (out model, out iter)) {
- Contact contact;
- model.get (iter, 0, out contact);
- foreach (var w in card_grid.get_children ()) {
- w.destroy ();
- }
- foreach (var w in fields_grid.get_children ()) {
- w.destroy ();
- }
- if (contact != null) {
- display_contact (contact);
+ model.get (iter, 0, out selected_contact);
+ if (selected_contact != null) {
+ display_contact (selected_contact);
+ selected_contact.changed.connect (selected_contact_changed);
}
}
}
-
public App () {
contacts_store = new ContactStore ();
filter_model = new TreeModelFilter (contacts_store, null);
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 78b3c89..7e29421 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -69,6 +69,8 @@ public class Contacts.Contact : GLib.Object {
private string filter_data;
+ public signal void changed ();
+
public static Contact from_individual (Individual i) {
return i.get_data ("contact");
}
@@ -169,6 +171,7 @@ public class Contacts.Contact : GLib.Object {
private bool changed_cb () {
changed_id = 0;
update ();
+ changed ();
var path = store.get_path (iter);
store.row_changed (path, iter);
return false;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]