[gnome-control-center] shell: Don't repeat the item title when searching



commit 93d7d6b6ea93f3b2bcf80d09f065b26083d3c92b
Author: Bastien Nocera <hadess hadess net>
Date:   Fri Aug 26 13:59:23 2011 +0100

    shell: Don't repeat the item title when searching
    
    https://bugzilla.gnome.org/show_bug.cgi?id=657020

 shell/cc-shell-model.c       |    9 +--------
 shell/cc-shell-model.h       |    2 +-
 shell/gnome-control-center.c |   25 +++++++++++++++++--------
 3 files changed, 19 insertions(+), 17 deletions(-)
---
diff --git a/shell/cc-shell-model.c b/shell/cc-shell-model.c
index dd916f8..736c0a9 100644
--- a/shell/cc-shell-model.c
+++ b/shell/cc-shell-model.c
@@ -161,7 +161,6 @@ cc_shell_model_add_item (CcShellModel   *model,
   const gchar *comment = g_app_info_get_description (appinfo);
   gchar *id;
   GdkPixbuf *pixbuf = NULL;
-  gchar *search_target;
   GKeyFile *key_file;
   gchar **keywords;
 
@@ -199,23 +198,17 @@ cc_shell_model_add_item (CcShellModel   *model,
 
   pixbuf = load_pixbuf_for_gicon (icon);
 
-  if (comment && comment[0])
-    search_target = g_strconcat (name, " - ", comment, NULL);
-  else
-    search_target = g_strdup (name);
-
   gtk_list_store_insert_with_values (GTK_LIST_STORE (model), NULL, 0,
                                      COL_NAME, name,
                                      COL_DESKTOP_FILE, desktop,
                                      COL_ID, id,
                                      COL_PIXBUF, pixbuf,
                                      COL_CATEGORY, category_name,
-                                     COL_SEARCH_TARGET, search_target,
+                                     COL_DESCRIPTION, comment,
                                      COL_GICON, icon,
                                      COL_KEYWORDS, keywords,
                                      -1);
 
   g_free (id);
-  g_free (search_target);
   g_strfreev (keywords);
 }
diff --git a/shell/cc-shell-model.h b/shell/cc-shell-model.h
index 97ac160..5279b99 100644
--- a/shell/cc-shell-model.h
+++ b/shell/cc-shell-model.h
@@ -60,7 +60,7 @@ enum
   COL_ID,
   COL_PIXBUF,
   COL_CATEGORY,
-  COL_SEARCH_TARGET,
+  COL_DESCRIPTION,
   COL_GICON,
   COL_KEYWORDS,
 
diff --git a/shell/gnome-control-center.c b/shell/gnome-control-center.c
index a42aa79..a52e04a 100644
--- a/shell/gnome-control-center.c
+++ b/shell/gnome-control-center.c
@@ -399,29 +399,39 @@ model_filter_func (GtkTreeModel              *model,
                    GtkTreeIter               *iter,
                    GnomeControlCenterPrivate *priv)
 {
-  gchar *name, *target;
+  gchar *name, *description;
   gchar *needle, *haystack;
   gboolean result;
   gchar **keywords;
 
-  gtk_tree_model_get (model, iter, COL_NAME, &name,
-                      COL_SEARCH_TARGET, &target,
+  gtk_tree_model_get (model, iter,
+                      COL_NAME, &name,
+                      COL_DESCRIPTION, &description,
                       COL_KEYWORDS, &keywords,
                       -1);
 
-  if (!priv->filter_string || !name || !target)
+  if (!priv->filter_string || !name)
     {
       g_free (name);
-      g_free (target);
+      g_free (description);
       g_strfreev (keywords);
       return FALSE;
     }
 
   needle = g_utf8_casefold (priv->filter_string, -1);
-  haystack = g_utf8_casefold (target, -1);
+  haystack = g_utf8_casefold (name, -1);
 
   result = (strstr (haystack, needle) != NULL);
 
+  if (!result && description)
+    {
+      gchar *folded;
+
+      folded = g_utf8_casefold (description, -1);
+      result = (strstr (folded, needle) != NULL);
+      g_free (folded);
+    }
+
   if (!result && keywords)
     {
       gint i;
@@ -436,7 +446,6 @@ model_filter_func (GtkTreeModel              *model,
     }
 
   g_free (name);
-  g_free (target);
   g_free (haystack);
   g_free (needle);
   g_strfreev (keywords);
@@ -582,7 +591,7 @@ setup_search (GnomeControlCenter *shell)
                                  "title", COL_NAME);
   gtk_cell_layout_add_attribute (GTK_CELL_LAYOUT (search_view),
                                  priv->search_renderer,
-                                 "search-target", COL_SEARCH_TARGET);
+                                 "search-target", COL_DESCRIPTION);
 
   /* connect the activated signal */
   g_signal_connect (search_view, "desktop-item-activated",



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]