From a91f33c152c1f463d21a388727e64945c88e4d54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 13 Oct 2017 01:20:17 +0200 Subject: [PATCH 1/2] apps-menu: Minor code cleanup The parameter to _clearApplicationBox() has never been used, so remove it. In fact, modern javascript makes the function so compact that we can just move the code inline. https://bugzilla.gnome.org/show_bug.cgi?id=788939 --- extensions/apps-menu/extension.js | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/extensions/apps-menu/extension.js b/extensions/apps-menu/extension.js index 600eda3..8138d4c 100644 --- a/extensions/apps-menu/extension.js +++ b/extensions/apps-menu/extension.js @@ -712,19 +712,10 @@ const ApplicationsButton = new Lang.Class({ this.mainBox.style+=('height: ' + height); }, - _clearApplicationsBox: function(selectedActor) { - let actors = this.applicationsBox.get_children(); - for (let i = 0; i < actors.length; i++) { - let actor = actors[i]; - this.applicationsBox.remove_actor(actor); - } - }, - selectCategory: function(dir, categoryMenuItem) { - if (categoryMenuItem) - this._clearApplicationsBox(categoryMenuItem.actor); - else - this._clearApplicationsBox(null); + this.applicationsBox.get_children().forEach(c => { + this.applicationsBox.remove_actor(c); + }); if (dir) this._displayButtons(this._listApplications(dir.get_menu_id())); -- 2.14.2 From dd79357f429fabfec63ab1ea772428000bf038d0 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 2/2] 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 ... https://bugzilla.gnome.org/show_bug.cgi?id=788939 --- 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); -- 2.14.2