[gnome-contacts] Make Contact.is_hidden a property getter and cache the value
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Make Contact.is_hidden a property getter and cache the value
- Date: Tue, 29 Nov 2011 11:11:58 +0000 (UTC)
commit 9335c9b9bca029cdcb7a0ccd61ca0eb9427b5489
Author: Alexander Larsson <alexl redhat com>
Date: Tue Nov 29 11:40:29 2011 +0100
Make Contact.is_hidden a property getter and cache the value
Its already semi-expensive to calculate and we're gonna add more stuff
src/contacts-contact.vala | 17 ++++++++++++++++-
src/contacts-store.vala | 2 +-
src/contacts-view.vala | 2 +-
3 files changed, 18 insertions(+), 3 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 82693bd..fd9dcc0 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -253,7 +253,10 @@ public class Contacts.Contact : GLib.Object {
public signal void changed ();
- public bool is_hidden () {
+ private bool _is_hidden;
+ private bool _is_hidden_uptodate;
+
+ private bool _get_is_hidden () {
// Don't show the user itself
if (individual.is_user)
return true;
@@ -278,6 +281,16 @@ public class Contacts.Contact : GLib.Object {
return false;
}
+ public bool is_hidden {
+ get {
+ if (!_is_hidden_uptodate) {
+ _is_hidden = _get_is_hidden ();
+ _is_hidden_uptodate = true;
+ }
+ return _is_hidden;
+ }
+ }
+
public static Contact from_individual (Individual i) {
return i.get_data ("contact");
}
@@ -717,6 +730,8 @@ public class Contacts.Contact : GLib.Object {
}
private void queue_changed () {
+ _is_hidden_uptodate = false;
+
if (changed_id != 0)
return;
diff --git a/src/contacts-store.vala b/src/contacts-store.vala
index f82ab35..53699f8 100644
--- a/src/contacts-store.vala
+++ b/src/contacts-store.vala
@@ -190,7 +190,7 @@ public class Contacts.Store : GLib.Object {
public bool is_empty () {
foreach (var contact in contacts) {
- if (!contact.is_hidden ())
+ if (!contact.is_hidden)
return false;
}
return true;
diff --git a/src/contacts-view.vala b/src/contacts-view.vala
index 20c7bbe..d56fd0e 100644
--- a/src/contacts-view.vala
+++ b/src/contacts-view.vala
@@ -113,7 +113,7 @@ public class Contacts.View : GLib.Object {
public TreeModel model { get { return list_store; } }
private bool apply_filter (Contact contact) {
- if (contact.is_hidden ())
+ if (contact.is_hidden)
return false;
if (contact in hidden_contacts)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]