From 204e4d53d1f29b4ed4c2b66ff16634aa9dbe25a4 Mon Sep 17 00:00:00 2001 From: Gustavo Noronha Silva Date: Mon, 19 Jan 2009 23:48:58 +0000 Subject: Implement multiple keyword-based AND-search for the location bar Bug #568101 svn path=/trunk/; revision=8706 --- src/ephy-location-action.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) (limited to 'src/ephy-location-action.c') diff --git a/src/ephy-location-action.c b/src/ephy-location-action.c index c33664e39..94deac3cd 100644 --- a/src/ephy-location-action.c +++ b/src/ephy-location-action.c @@ -98,7 +98,7 @@ match_func (GtkEntryCompletion *completion, gboolean ret = FALSE; GtkTreeModel *model; - GRegex *regex; + GSList *search_terms; model = gtk_entry_completion_get_model (completion); @@ -112,12 +112,26 @@ match_func (GtkEntryCompletion *completion, if (!key) return FALSE; - regex = ephy_location_entry_get_regex (data); - - ret = (g_regex_match (regex, item, G_REGEX_MATCH_NOTEMPTY, NULL) - || g_regex_match (regex, url, G_REGEX_MATCH_NOTEMPTY, NULL) - || g_regex_match (regex, keywords, G_REGEX_MATCH_NOTEMPTY, NULL) - ); + search_terms = ephy_location_entry_get_search_terms (data); + + if (search_terms) + { + GSList *iter; + GRegex *current = NULL; + + ret = TRUE; + for (iter = search_terms; iter != NULL; iter = iter->next) + { + current = (GRegex*) iter->data; + if ((!g_regex_match (current, item, G_REGEX_MATCH_NOTEMPTY, NULL)) && + (!g_regex_match (current, url, G_REGEX_MATCH_NOTEMPTY, NULL)) && + (!g_regex_match (current, keywords, G_REGEX_MATCH_NOTEMPTY, NULL))) + { + ret = FALSE; + break; + } + } + } g_free (item); g_free (url); -- cgit v1.2.3