shell: Display search results for multiple query words
Before, queries like "remote desktop" were going through g_strstrip() and turning alternative matches to "remote" or "desktop" unreachable. See #2763
This commit is contained in:
parent
ac0afb24d6
commit
216368db4b
1 changed files with 12 additions and 8 deletions
|
@ -312,11 +312,11 @@ filter_func (GtkListBoxRow *row,
|
|||
{
|
||||
CcPanelList *self;
|
||||
RowData *data;
|
||||
g_autofree gchar *search_text = NULL;
|
||||
g_autofree gchar *panel_text = NULL;
|
||||
g_autofree gchar **search_words = NULL;
|
||||
g_autofree gchar *panel_description = NULL;
|
||||
gboolean retval = FALSE;
|
||||
gint i;
|
||||
gint i, j;
|
||||
|
||||
self = CC_PANEL_LIST (user_data);
|
||||
data = g_object_get_data (G_OBJECT (row), "data");
|
||||
|
@ -325,11 +325,11 @@ filter_func (GtkListBoxRow *row,
|
|||
return TRUE;
|
||||
|
||||
panel_text = cc_util_normalize_casefold_and_unaccent (data->name);
|
||||
search_text = cc_util_normalize_casefold_and_unaccent (self->search_query);
|
||||
// Split words separated by a space
|
||||
search_words = g_strsplit (g_strstrip (cc_util_normalize_casefold_and_unaccent (self->search_query)), " ", -1);
|
||||
panel_description = cc_util_normalize_casefold_and_unaccent (data->description);
|
||||
|
||||
g_strstrip (panel_text);
|
||||
g_strstrip (search_text);
|
||||
g_strstrip (panel_description);
|
||||
|
||||
/*
|
||||
|
@ -338,11 +338,15 @@ filter_func (GtkListBoxRow *row,
|
|||
*/
|
||||
gtk_widget_set_visible (data->description_label, self->view == CC_PANEL_LIST_SEARCH);
|
||||
|
||||
for (i = 0; !retval && data->keywords[i] != NULL; i++)
|
||||
retval = (strstr (data->keywords[i], search_text) == data->keywords[i]);
|
||||
for (j = 0; !retval && search_words[j] != NULL; j++) {
|
||||
// Compare keywords
|
||||
for (i = 0; !retval && data->keywords[i] != NULL; i++)
|
||||
retval = (strstr (data->keywords[i], search_words[j]) == data->keywords[i]);
|
||||
|
||||
retval = retval || g_strstr_len (panel_text, -1, search_text) != NULL ||
|
||||
g_strstr_len (panel_description, -1, search_text) != NULL;
|
||||
// Compare panel title and description
|
||||
retval = retval || (g_strstr_len (panel_text, -1, search_words[j]) != NULL ||
|
||||
g_strstr_len (panel_description, -1, search_words[j]) != NULL);
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue