summaryrefslogtreecommitdiff
path: root/src/nautilus-shell-search-provider.c
diff options
context:
space:
mode:
authorCosimo Cecchi <cosimoc@gnome.org>2012-10-14 13:33:01 -0400
committerCosimo Cecchi <cosimoc@gnome.org>2012-10-15 09:51:31 -0400
commit98bcc3ba2b1c991fc1de4874130a3e91c4782096 (patch)
treef3b8d30e6e01066030403189c3032fdbc8bb5819 /src/nautilus-shell-search-provider.c
parenta4e65a637ca001296e4c8f25dcd8e41eac78518d (diff)
downloadnautilus-98bcc3ba2b1c991fc1de4874130a3e91c4782096.tar.gz
query: move string matching code in NautilusQuery
This also allows us to use a heuristic to evaluate how good the filename match is.
Diffstat (limited to 'src/nautilus-shell-search-provider.c')
-rw-r--r--src/nautilus-shell-search-provider.c30
1 files changed, 8 insertions, 22 deletions
diff --git a/src/nautilus-shell-search-provider.c b/src/nautilus-shell-search-provider.c
index 649ea159a..fc0c6551d 100644
--- a/src/nautilus-shell-search-provider.c
+++ b/src/nautilus-shell-search-provider.c
@@ -298,7 +298,7 @@ search_hit_candidate_new (const gchar *uri,
SearchHitCandidate *candidate = g_slice_new0 (SearchHitCandidate);
candidate->uri = g_strdup (uri);
- candidate->string_for_compare = nautilus_search_prepare_string_for_compare (name);
+ candidate->string_for_compare = g_strdup (name);
return candidate;
}
@@ -309,10 +309,9 @@ search_add_volumes_and_bookmarks (NautilusShellSearchProviderApp *self)
NautilusSearchHit *hit;
NautilusBookmark *bookmark;
const gchar *name;
- gint length, idx, j;
- gchar *query_text, *string, *uri;
- gchar **terms;
- gboolean found;
+ gint length, idx;
+ gchar *string, *uri;
+ gdouble match;
GList *l, *m, *drives, *volumes, *mounts, *mounts_to_check, *candidates;
GDrive *drive;
GVolume *volume;
@@ -321,12 +320,6 @@ search_add_volumes_and_bookmarks (NautilusShellSearchProviderApp *self)
SearchHitCandidate *candidate;
candidates = NULL;
- query_text = nautilus_query_get_text (self->current_search->query);
- string = nautilus_search_prepare_string_for_compare (query_text);
- terms = g_strsplit (string, " ", -1);
-
- g_free (string);
- g_free (query_text);
/* first add bookmarks */
length = nautilus_bookmark_list_length (self->bookmarks);
@@ -430,24 +423,17 @@ search_add_volumes_and_bookmarks (NautilusShellSearchProviderApp *self)
for (l = candidates; l != NULL; l = l->next) {
candidate = l->data;
- found = TRUE;
+ match = nautilus_query_matches_string (self->current_search->query,
+ candidate->string_for_compare);
- for (j = 0; terms[j] != NULL; j++) {
- if (strstr (candidate->string_for_compare, terms[j]) == NULL) {
- found = FALSE;
- break;
- }
- }
-
- if (found) {
+ if (match > -1) {
hit = nautilus_search_hit_new (candidate->uri);
+ nautilus_search_hit_set_fts_rank (hit, match);
nautilus_search_hit_compute_scores (hit, self->current_search->query);
g_hash_table_replace (self->current_search->hits, g_strdup (candidate->uri), hit);
}
}
g_list_free_full (candidates, (GDestroyNotify) search_hit_candidate_free);
-
- g_strfreev (terms);
}
static void