summaryrefslogtreecommitdiff
path: root/search-provider/cc-search-provider.c
diff options
context:
space:
mode:
authorFlorian Müllner <fmuellner@gnome.org>2013-03-01 22:01:37 +0100
committerFlorian Müllner <fmuellner@gnome.org>2013-03-02 00:04:41 +0100
commit4d01f6bfed83e7d1520e590a7c3898a01839ebf1 (patch)
tree18890e46305e58778d577d5f0097925bddf3f8a9 /search-provider/cc-search-provider.c
parent6ddd56a9a27a040fd953603f7c9cc5eed5977bba (diff)
downloadgnome-control-center-4d01f6bfed83e7d1520e590a7c3898a01839ebf1.tar.gz
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
Diffstat (limited to 'search-provider/cc-search-provider.c')
-rw-r--r--search-provider/cc-search-provider.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/search-provider/cc-search-provider.c b/search-provider/cc-search-provider.c
index 93767357a..fde0fc7dd 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]));
}