[gnome-shell/wip/desktop-file-index: 16/20] appDisplay: Use a proper string key for the app search provider



commit e1648f8fe9fd3d3ded358a0a93281bac741ba809
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Fri Feb 8 22:08:13 2013 -0500

    appDisplay: Use a proper string key for the app search provider
    
    We were always sort of cheating when we used objects as the search ID.
    Since the new desktop file index will return us a list of desktop file
    IDs, just use those as IDs instead.

 js/ui/appDisplay.js    |    9 +++++----
 src/shell-app-system.c |   22 +++++++++++++++-------
 2 files changed, 20 insertions(+), 11 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 4ea384d..8f5dfcd 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -864,8 +864,8 @@ const AppSearchProvider = new Lang.Class({
     getResultMetas: function(apps, callback) {
         let metas = [];
         for (let i = 0; i < apps.length; i++) {
-            let app = apps[i];
-            metas.push({ 'id': app,
+            let app = this._appSys.lookup_app(apps[i]);
+            metas.push({ 'id': app.get_id(),
                          'name': app.get_name(),
                          'createIcon': function(size) {
                              return app.create_icon_texture(size);
@@ -883,7 +883,8 @@ const AppSearchProvider = new Lang.Class({
         this.searchSystem.setResults(this, this._appSys.subsearch(previousResults, terms));
     },
 
-    activateResult: function(app) {
+    activateResult: function(result) {
+        let app = this._appSys.lookup_app(result);
         let event = Clutter.get_current_event();
         let modifiers = event ? event.get_state() : 0;
         let openNewWindow = modifiers & Clutter.ModifierType.CONTROL_MASK;
@@ -903,7 +904,7 @@ const AppSearchProvider = new Lang.Class({
     },
 
     createResultObject: function (resultMeta, terms) {
-        let app = resultMeta['id'];
+        let app = this._appSys.lookup_app(resultMeta['id']);
         return new AppIcon(app);
     }
 });
diff --git a/src/shell-app-system.c b/src/shell-app-system.c
index 408dbb4..0b36318 100644
--- a/src/shell-app-system.c
+++ b/src/shell-app-system.c
@@ -332,13 +332,22 @@ sort_and_concat_results (ShellAppSystem *system,
                          GSList         *prefix_matches,
                          GSList         *substring_matches)
 {
+  GSList *matches = NULL;
+  GSList *l;
+
   prefix_matches = g_slist_sort_with_data (prefix_matches,
                                            compare_apps_by_usage,
                                            system);
   substring_matches = g_slist_sort_with_data (substring_matches,
                                               compare_apps_by_usage,
                                               system);
-  return g_slist_concat (prefix_matches, substring_matches);
+
+  for (l = substring_matches; l != NULL; l = l->next)
+    matches = g_slist_prepend (matches, (char *) shell_app_get_id (SHELL_APP (l->data)));
+  for (l = prefix_matches; l != NULL; l = l->next)
+    matches = g_slist_prepend (matches, (char *) shell_app_get_id (SHELL_APP (l->data)));
+
+  return g_slist_reverse (matches);
 }
 
 /**
@@ -385,7 +394,6 @@ search_tree (ShellAppSystem *self,
   g_slist_free_full (normalized_terms, g_free);
 
   return sort_and_concat_results (self, prefix_results, substring_results);
-
 }
 
 /**
@@ -395,7 +403,7 @@ search_tree (ShellAppSystem *self,
  *
  * Search through applications for the given search terms.
  *
- * Returns: (transfer container) (element-type ShellApp): List of applications
+ * Returns: (transfer container) (element-type utf8): List of applications
  */
 GSList *
 shell_app_system_initial_search (ShellAppSystem  *self,
@@ -407,7 +415,7 @@ shell_app_system_initial_search (ShellAppSystem  *self,
 /**
  * shell_app_system_subsearch:
  * @system: A #ShellAppSystem
- * @previous_results: (element-type ShellApp): List of previous results
+ * @previous_results: (element-type utf8): List of previous results
  * @terms: (element-type utf8): List of terms, logical AND
  *
  * Search through a previous result set; for more information, see
@@ -415,7 +423,7 @@ shell_app_system_initial_search (ShellAppSystem  *self,
  * the same as passed to shell_app_system_initial_search().  Note that returned
  * strings are only valid until a return to the main loop.
  *
- * Returns: (transfer container) (element-type ShellApp): List of application identifiers
+ * Returns: (transfer container) (element-type utf8): List of application identifiers
  */
 GSList *
 shell_app_system_subsearch (ShellAppSystem   *system,
@@ -431,8 +439,8 @@ shell_app_system_subsearch (ShellAppSystem   *system,
 
   for (iter = previous_results; iter; iter = iter->next)
     {
-      ShellApp *app = iter->data;
-      
+      ShellApp *app = shell_app_system_lookup_app (system, iter->data);
+
       _shell_app_do_match (app, normalized_terms,
                            &prefix_results,
                            &substring_results);


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