[gnome-shell] appDisplay: Support the 'categories' key for app folders



commit bb8fa61cb4696f2248a6cf65f3a64e00d342d828
Author: Jasper St. Pierre <jstpierre mecheye net>
Date:   Tue Jan 28 12:06:11 2014 -0500

    appDisplay: Support the 'categories' key for app folders
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723179

 js/ui/appDisplay.js |   26 ++++++++++++++++++++++----
 1 files changed, 22 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/appDisplay.js b/js/ui/appDisplay.js
index 165fa59..ec71ad0 100644
--- a/js/ui/appDisplay.js
+++ b/js/ui/appDisplay.js
@@ -61,6 +61,13 @@ function _isTerminal(app) {
     return categories.indexOf('TerminalEmulator') > -1;
 }
 
+function _listsIntersect(a, b) {
+    for (let itemA of a)
+        if (b.indexOf(itemA) >= 0)
+            return true;
+    return false;
+}
+
 function _getFolderName(folder) {
     let name = folder.get_string('name');
 
@@ -1069,9 +1076,7 @@ const FolderIcon = new Lang.Class({
         this.view.removeAll();
 
         let appSys = Shell.AppSystem.get_default();
-
-        let folderApps = this._folder.get_strv('apps');
-        folderApps.forEach(Lang.bind(this, function(appId) {
+        let addAppId = (function addAppId(appId) {
             let app = appSys.lookup_app(appId);
             if (!app)
                 return;
@@ -1081,7 +1086,20 @@ const FolderIcon = new Lang.Class({
 
             let icon = new AppIcon(app);
             this.view.addItem(icon);
-        }));
+        }).bind(this);
+
+        let folderApps = this._folder.get_strv('apps');
+        folderApps.forEach(addAppId);
+
+        let folderCategories = this._folder.get_strv('categories');
+        Gio.AppInfo.get_all().forEach(function(appInfo) {
+            let appCategories = _getCategories(appInfo);
+            if (!_listsIntersect(folderCategories, appCategories))
+                return;
+
+            addAppId(appInfo.get_id());
+        });
+
         this.view.loadGrid();
         this.emit('apps-changed');
     },


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