summaryrefslogtreecommitdiff
path: root/shell/cc-panel-list.c
diff options
context:
space:
mode:
authorFelipe Borges <felipeborges@gnome.org>2017-11-27 11:05:19 +0100
committerFelipe Borges <felipeborges@gnome.org>2017-11-28 11:04:38 +0100
commitaaabf05ae621dd37a007113f9168f63c7a018674 (patch)
tree42a27fddeb0b6253ce51db08ea9b2b09af9be3de /shell/cc-panel-list.c
parent5d32d8548c3a77a986ada227c1dbd58631636238 (diff)
downloadgnome-control-center-aaabf05ae621dd37a007113f9168f63c7a018674.tar.gz
shell: Include panel "keywords" in the row data
This way GtkListBox filter functions can use the "keywords" in order to provide accurate search results. https://bugzilla.gnome.org/show_bug.cgi?id=790755
Diffstat (limited to 'shell/cc-panel-list.c')
-rw-r--r--shell/cc-panel-list.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/shell/cc-panel-list.c b/shell/cc-panel-list.c
index 9e462efbb..db3382f6d 100644
--- a/shell/cc-panel-list.c
+++ b/shell/cc-panel-list.c
@@ -18,6 +18,8 @@
* Author: Georges Basile Stavracas Neto <gbsneto@gnome.org>
*/
+#include <string.h>
+
#include "cc-panel-list.h"
#include "cc-util.h"
@@ -29,6 +31,7 @@ typedef struct
gchar *id;
gchar *name;
gchar *description;
+ gchar **keywords;
} RowData;
struct _CcPanelList
@@ -148,6 +151,7 @@ update_search (CcPanelList *self)
static void
row_data_free (RowData *data)
{
+ g_strfreev (data->keywords);
g_free (data->description);
g_free (data->name);
g_free (data->id);
@@ -159,6 +163,7 @@ row_data_new (CcPanelCategory category,
const gchar *id,
const gchar *name,
const gchar *description,
+ gchar **keywords,
const gchar *icon)
{
GtkWidget *label, *grid, *image;
@@ -170,6 +175,7 @@ row_data_new (CcPanelCategory category,
data->id = g_strdup (id);
data->name = g_strdup (name);
data->description = g_strdup (description);
+ data->keywords = g_strdupv (keywords);
/* Setup the row */
grid = g_object_new (GTK_TYPE_GRID,
@@ -229,7 +235,8 @@ filter_func (GtkListBoxRow *row,
CcPanelList *self;
RowData *data;
gchar *search_text, *panel_text, *panel_description;
- gboolean retval;
+ gboolean retval = FALSE;
+ gint i;
self = CC_PANEL_LIST (user_data);
data = g_object_get_data (G_OBJECT (row), "data");
@@ -251,7 +258,10 @@ filter_func (GtkListBoxRow *row,
*/
gtk_widget_set_visible (data->description_label, self->view == CC_PANEL_LIST_SEARCH);
- retval = g_strstr_len (panel_text, -1, search_text) != NULL ||
+ for (i = 0; !retval && data->keywords[i] != NULL; i++)
+ retval = (strstr (data->keywords[i], search_text) == data->keywords[i]);
+
+ retval = retval || g_strstr_len (panel_text, -1, search_text) != NULL ||
g_strstr_len (panel_description, -1, search_text) != NULL;
g_free (panel_text);
@@ -859,6 +869,7 @@ cc_panel_list_add_panel (CcPanelList *self,
const gchar *id,
const gchar *title,
const gchar *description,
+ gchar **keywords,
const gchar *icon)
{
GtkWidget *listbox;
@@ -867,7 +878,7 @@ cc_panel_list_add_panel (CcPanelList *self,
g_return_if_fail (CC_IS_PANEL_LIST (self));
/* Add the panel to the proper listbox */
- data = row_data_new (category, id, title, description, icon);
+ data = row_data_new (category, id, title, description, keywords, icon);
switch (category)
{
@@ -887,7 +898,7 @@ cc_panel_list_add_panel (CcPanelList *self,
gtk_container_add (GTK_CONTAINER (listbox), data->row);
/* And add to the search listbox too */
- search_data = row_data_new (category, id, title, description, icon);
+ search_data = row_data_new (category, id, title, description, keywords, icon);
gtk_container_add (GTK_CONTAINER (self->search_listbox), search_data->row);
g_hash_table_insert (self->id_to_data, data->id, data);