[gnome-shell-extensions/wip/fmuellner/alacarte-compat: 5/5] apps-menu: Support separators



commit 21315d74c3be019d43074e4d3d7b01e866d95b2d
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Oct 13 01:44:19 2017 +0200

    apps-menu: Support separators
    
    We currently only load entries and directories, and ignore any
    separators defined by the user/admin. Make some people happy
    by supporting them ...
    
    Fixes https://gitlab.gnome.org/GNOME/gnome-shell-extensions/issues/27

 extensions/apps-menu/extension.js | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js
index 8138d4c..c2ecf5f 100644
--- a/extensions/apps-menu/extension.js
+++ b/extensions/apps-menu/extension.js
@@ -592,6 +592,8 @@ const ApplicationsButton = new Lang.Class({
                     app = new Shell.App({ app_info: entry.get_app_info() });
                 if (app.get_app_info().should_show())
                     this.applicationsByCategory[categoryId].push(app);
+            } else if (nextType == GMenu.TreeItemType.SEPARATOR) {
+                this.applicationsByCategory[categoryId].push('separator');
             } else if (nextType == GMenu.TreeItemType.DIRECTORY) {
                 let subdir = iter.get_directory();
                 if (!subdir.get_is_nodisplay())
@@ -714,7 +716,10 @@ const ApplicationsButton = new Lang.Class({
 
     selectCategory: function(dir, categoryMenuItem) {
         this.applicationsBox.get_children().forEach(c => {
-            this.applicationsBox.remove_actor(c);
+            if (c._delegate instanceof PopupMenu.PopupSeparatorMenuItem)
+                c._delegate.destroy();
+            else
+                this.applicationsBox.remove_actor(c);
         });
 
         if (dir)
@@ -727,7 +732,11 @@ const ApplicationsButton = new Lang.Class({
          if (apps) {
             for (let i = 0; i < apps.length; i++) {
                let app = apps[i];
-               let item = this._applicationsButtons.get(app);
+               let item;
+               if (app instanceof Shell.App)
+                   item = this._applicationsButtons.get(app);
+               else
+                   item = new PopupMenu.PopupSeparatorMenuItem();
                if (!item) {
                   item = new ApplicationMenuItem(this, app);
                   item.setDragEnabled(this._desktopTarget.hasDesktop);


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