[gnome-contacts/gnome-3-8] Don't search for "empty" strings



commit 86a4ba7786efd20f71cad79dc8ab4327aed2da08
Author: Chris Cummins <christopher e cummins intel com>
Date:   Mon May 20 17:05:29 2013 +0100

    Don't search for "empty" strings
    
    The contact list is only filtered if the search query is not "empty",
    i.e., contains at least one non-space character. This prevents returning
    a list of all the contacts.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=700729

 src/contacts-list-pane.vala |    2 +-
 src/contacts-utils.vala     |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 1 deletions(-)
---
diff --git a/src/contacts-list-pane.vala b/src/contacts-list-pane.vala
index e73dd16..799cfad 100644
--- a/src/contacts-list-pane.vala
+++ b/src/contacts-list-pane.vala
@@ -40,7 +40,7 @@ public class Contacts.ListPane : Frame {
     string []? values;
     string str = filter_entry.get_text ();
 
-    if (str.length == 0)
+    if (Utils.string_is_empty (str))
       values = null;
     else {
       str = Utils.canonicalize_for_search (str);
diff --git a/src/contacts-utils.vala b/src/contacts-utils.vala
index 6754d1f..0b6076c 100644
--- a/src/contacts-utils.vala
+++ b/src/contacts-utils.vala
@@ -174,6 +174,20 @@ public class Contacts.Utils : Object {
     }
   }
 
+  /* Returns false if the given string contains at least one non-"space"
+   * character.
+   */
+  public static bool string_is_empty (string str) {
+    unichar c;
+
+    for (int i = 0; str.get_next_char (ref i, out c);) {
+      if (!c.isspace ())
+       return false;
+    }
+
+    return true;
+  }
+
   public static string canonicalize_for_search (string str) {
     unowned string s;
     var buf = new unichar[18];


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]