[gnome-contacts] Break out the internal filtering to Contact
- From: Alexander Larsson <alexl src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-contacts] Break out the internal filtering to Contact
- Date: Mon, 22 Aug 2011 11:07:46 +0000 (UTC)
commit 3ca86753b5a60b223bb02b98d49cd33d9e535757
Author: Alexander Larsson <alexl redhat com>
Date: Mon Aug 22 10:41:16 2011 +0200
Break out the internal filtering to Contact
src/contacts-contact.vala | 25 +++++++++++++++++++++++++
src/contacts-view.vala | 21 +--------------------
2 files changed, 26 insertions(+), 20 deletions(-)
---
diff --git a/src/contacts-contact.vala b/src/contacts-contact.vala
index 34e3d75..c2fc735 100644
--- a/src/contacts-contact.vala
+++ b/src/contacts-contact.vala
@@ -191,6 +191,31 @@ public class Contacts.Contact : GLib.Object {
public signal void changed ();
+ public bool is_hidden () {
+ // Don't show the user itself
+ if (individual.is_user)
+ return true;
+
+ var personas = individual.personas;
+ var i = personas.iterator();
+ // Look for single-persona individuals
+ if (i.next() && !i.has_next ()) {
+ var persona = i.get();
+ var store = persona.store;
+
+ // Filter out pure key-file persona individuals as these are
+ // not very interesting
+ if (store.type_id == "key-file")
+ return true;
+
+ // Filter out uncertain things like link-local xmpp
+ if (store.type_id == "telepathy" &&
+ store.trust_level == PersonaStoreTrust.NONE)
+ return true;
+ }
+ return false;
+ }
+
public static Contact from_individual (Individual i) {
return i.get_data ("contact");
}
diff --git a/src/contacts-view.vala b/src/contacts-view.vala
index 7503eef..cb93103 100644
--- a/src/contacts-view.vala
+++ b/src/contacts-view.vala
@@ -55,28 +55,9 @@ public class Contacts.View : GLib.Object {
public TreeModel model { get { return list_store; } }
private bool apply_filter (Contact contact) {
- // Don't show the user itself
- if (contact.individual.is_user)
+ if (contact.is_hidden ())
return false;
- var personas = contact.individual.personas;
- var i = personas.iterator();
- // Look for single-persona individuals
- if (i.next() && !i.has_next ()) {
- var persona = i.get();
- var store = persona.store;
-
- // Filter out pure key-file persona individuals as these are
- // not very interesting
- if (store.type_id == "key-file")
- return false;
-
- // Filter out uncertain things like link-local xmpp
- if (store.type_id == "telepathy" &&
- store.trust_level == PersonaStoreTrust.NONE)
- return false;
- }
-
if (filter_values == null || filter_values.length == 0)
return true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]