[gnome-shell-extensions] apps-menu: don't load subdirectories as separate categories



commit c70b1526282bf8877e203dd37942b71f31f25214
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Sun Feb 10 17:26:23 2013 +0100

    apps-menu: don't load subdirectories as separate categories
    
    Directories that are not immediate children of the root should be merged
    in the parent, to preserve the flat structure and to be consistent with
    the Activities overview.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=693241

 extensions/apps-menu/extension.js |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index afc1048..8be1ee8 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -301,7 +301,7 @@ const ApplicationsButton = new Lang.Class({
         this._display();
     },
 
-    _loadCategory: function(dir) {
+    _loadCategory: function(categoryId, dir) {
         let iter = dir.iter();
         let nextType;
         while ((nextType = iter.next()) != GMenu.TreeItemType.INVALID) {
@@ -310,19 +310,12 @@ const ApplicationsButton = new Lang.Class({
                 if (!entry.get_app_info().get_nodisplay()) {
                     let app = appSys.lookup_app_by_tree_entry(entry);
                     let menu_id = dir.get_menu_id();
-                    this.applicationsByCategory[menu_id].push(app);
+                    this.applicationsByCategory[categoryId].push(app);
                 }
             } else if (nextType == GMenu.TreeItemType.DIRECTORY) {
                 let subdir = iter.get_directory();
-                if (!subdir.get_is_nodisplay()) {
-                    let menu_id = subdir.get_menu_id();
-                    this.applicationsByCategory[menu_id] = new Array();
-                    this._loadCategory(subdir);
-                    if (this.applicationsByCategory[menu_id].length > 0) {
-                        let categoryMenuItem = new CategoryMenuItem(this, subdir);
-                        this.categoriesBox.add_actor(categoryMenuItem.actor);
-                    }
-                }
+                if (!subdir.get_is_nodisplay())
+                    this._loadCategory(categoryId, subdir);
             }
         }
     },
@@ -421,10 +414,10 @@ const ApplicationsButton = new Lang.Class({
             if (nextType == GMenu.TreeItemType.DIRECTORY) {
                 let dir = iter.get_directory();
                 if (!dir.get_is_nodisplay()) {
-                    let menu_id = dir.get_menu_id();
-                    this.applicationsByCategory[menu_id] = new Array();
-                    this._loadCategory(dir);
-                    if (this.applicationsByCategory[menu_id].length > 0) {
+                    let categoryId = dir.get_menu_id();
+                    this.applicationsByCategory[categoryId] = [];
+                    this._loadCategory(categoryId, dir);
+                    if (this.applicationsByCategory[categoryId].length > 0) {
                         let categoryMenuItem = new CategoryMenuItem(this, dir);
                         this.categoriesBox.add_actor(categoryMenuItem.actor);
                     }


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