[gnome-control-center/gnome-3-8] search-provider: Concatenate search terms with AND



commit 7e94738f7cc81233b7945c9e011c4055d9b91e7c
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Mar 1 22:01:37 2013 +0100

    search-provider: Concatenate search terms with AND
    
    Currently the provider will match all panels that match at least
    one search term. This differs from the search pattern we use in
    GNOME Shell and other GNOME applications, where a result has to
    match all search terms. The latter allows users to narrow down
    search results by adding additional terms, which is generally
    more useful than potentially adding additional results.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=694960

 search-provider/cc-search-provider.c |   21 ++++++++++-----------
 1 files changed, 10 insertions(+), 11 deletions(-)
---
diff --git a/search-provider/cc-search-provider.c b/search-provider/cc-search-provider.c
index 70d8642..b62576e 100644
--- a/search-provider/cc-search-provider.c
+++ b/search-provider/cc-search-provider.c
@@ -71,21 +71,21 @@ get_casefolded_terms (char **terms)
 }
 
 static gboolean
-matches_multiple_terms (GtkTreeModel  *model,
-                        GtkTreeIter   *iter,
-                        char         **terms)
+matches_all_terms (GtkTreeModel  *model,
+                   GtkTreeIter   *iter,
+                   char         **terms)
 {
   int i;
 
   for (i = 0; terms[i]; i++)
     {
-      if (cc_shell_model_iter_matches_search (CC_SHELL_MODEL (model),
-                                              iter,
-                                              terms[i]))
-        return TRUE;
+      if (!cc_shell_model_iter_matches_search (CC_SHELL_MODEL (model),
+                                               iter,
+                                               terms[i]))
+        return FALSE;
     }
 
-  return FALSE;
+  return TRUE;
 }
 
 static GtkTreeModel *
@@ -116,8 +116,7 @@ handle_get_initial_result_set (CcShellSearchProvider2  *skeleton,
   ok = gtk_tree_model_get_iter_first (model, &iter);
   while (ok)
     {
-      if (matches_multiple_terms (model, &iter,
-                                  casefolded_terms))
+      if (matches_all_terms (model, &iter, casefolded_terms))
         {
           g_ptr_array_add (results,
                            gtk_tree_model_get_string_from_iter (model,
@@ -159,7 +158,7 @@ handle_get_subsearch_result_set (CcShellSearchProvider2  *skeleton,
     {
       if (gtk_tree_model_get_iter_from_string (model, &iter,
                                                previous_results[i]) &&
-          matches_multiple_terms (model, &iter, casefolded_terms))
+          matches_all_terms (model, &iter, casefolded_terms))
         {
           g_ptr_array_add (results, g_strdup (previous_results[i]));
         }


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