From 21315d74c3be019d43074e4d3d7b01e866d95b2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 13 Oct 2017 01:44:19 +0200 Subject: [PATCH] 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 8138d4ca..c2ecf5f5 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);