[gnome-shell/overlay-design02] Update for review of e57b7ec3359ce39e4fa360c744883fb37a069a49



commit e191636f34e0459cdfc3a8f6de9367c810afedf5
Author: Colin Walters <walters verbum org>
Date:   Tue Jun 30 15:05:17 2009 -0400

    Update for review of e57b7ec3359ce39e4fa360c744883fb37a069a49

 js/misc/appInfo.js  |   42 ++++++++++++++++++++----------------------
 js/ui/appDisplay.js |    5 +++--
 js/ui/widget.js     |    2 +-
 3 files changed, 24 insertions(+), 25 deletions(-)
---
diff --git a/js/misc/appInfo.js b/js/misc/appInfo.js
index 4b6dde6..2e9a966 100644
--- a/js/misc/appInfo.js
+++ b/js/misc/appInfo.js
@@ -71,39 +71,43 @@ function getAppInfo(appId) {
     return info;
 }
 
-// getMostUsedApps:
+// getTopApps:
 // @count: maximum number of apps to retrieve
 //
 // Gets a list of #AppInfos for the @count most-frequently-used
-// applications
+// applications, with explicitly-chosen favorites first.
 //
 // Return value: the list of #AppInfo
-function getMostUsedApps(count) {
+function getTopApps(count) {
     let appMonitor = Shell.AppMonitor.get_default();
 
+    let matches = [], alreadyAdded = {};
+
+    let favs = getFavorites();
+    for (let i = 0; i < favs.length && favs.length <= count; i++) {
+        let appId = favs[i].appId;
+
+        if (alreadyAdded[appId])
+            continue;
+        alreadyAdded[appId] = true;
+
+        matches.push(favs[i]);
+    }
+
     // Ask for more apps than we need, since the list of recently used
     // apps might contain an app we don't have a desktop file for
     let apps = appMonitor.get_most_used_apps (0, Math.round(count * 1.5));
-    let matches = [], alreadyAdded = {};
-
     for (let i = 0; i < apps.length && matches.length <= count; i++) {
         let appId = apps[i] + ".desktop";
+        if (alreadyAdded[appId])
+            continue;
+        alreadyAdded[appId] = true;
         let appInfo = getAppInfo(appId);
         if (appInfo) {
             matches.push(appInfo);
-            alreadyAdded[appId] = true;
         }
     }
 
-    let favs = getFavorites();
-    // Fill the list with default applications it's not full yet
-    for (let i = 0; i < favs.length && favs.length <= count; i++) {
-        let appId = favs[i].appId;
-        if (alreadyAdded[appId])
-            continue;
-        matches.push(favs[i]);
-    }
-
     return matches;
 }
 
@@ -126,11 +130,5 @@ function getFavorites() {
 
 function getRunning() {
     let monitor = Shell.AppMonitor.get_default();
-    let basename = function (n) {
-        let i = n.lastIndexOf('/');
-        if (i < 0)
-            return n;
-        return n.substring(i+1);
-    }
-    return _idListToInfos(monitor.get_running_app_ids().map(basename));
+    return _idListToInfos(monitor.get_running_app_ids());
 }
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 93d3304..77db9b0 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -351,7 +351,7 @@ AppDisplay.prototype = {
 
     // Sets the list of the displayed items based on the most used apps.
     _setDefaultList : function() {
-        let matchedInfos = AppInfo.getMostUsedApps(MAX_ITEMS);
+        let matchedInfos = AppInfo.getTopApps(MAX_ITEMS);
         this._matchedItems = matchedInfos.map(function(info) { return info.appId; });
     },
 
@@ -519,7 +519,6 @@ WellArea.prototype = {
 
         children = this.actor.get_children();
         children.forEach(Lang.bind(this, function (v) {
-            this.actor.remove_actor(v);
             v.destroy();
         }));
 
@@ -550,6 +549,8 @@ WellArea.prototype = {
             Mainloop.idle_add(function () {
                 appSystem.add_favorite(id);
             });
+        } else {
+            return false;
         }
 
         return true;
diff --git a/js/ui/widget.js b/js/ui/widget.js
index 8a0644f..0984c5d 100644
--- a/js/ui/widget.js
+++ b/js/ui/widget.js
@@ -284,7 +284,7 @@ AppsWidget.prototype = {
         this.actor = new Big.Box({ spacing: 2 });
         this.collapsedActor = new Big.Box({ spacing: 2});
 
-        let apps = AppInfo.getMostUsedApps(5);
+        let apps = AppInfo.getTopApps(5);
         for (let i = 0; i < apps.length; i++)
             this.addItem(apps[i]);
     }



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