From fd0da9606fd2481bf67cb488f86d73ab388ff947 Mon Sep 17 00:00:00 2001 From: Leleat Date: Thu, 29 Apr 2021 01:09:50 +0200 Subject: [PATCH] appMenu: Only show Open Windows, if there are at least 2 windows It doesn't make sense to show the 'Open Windows' in the app menu, if the app only has 1 open window to switch between. Hide the window section in that case. Fixes https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/4199. Part-of: --- js/ui/panel.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/ui/panel.js b/js/ui/panel.js index cba32416a..1474886ef 100644 --- a/js/ui/panel.js +++ b/js/ui/panel.js @@ -30,7 +30,8 @@ class AppMenu extends PopupMenu.PopupMenu { this._windowsChangedId = 0; /* Translators: This is the heading of a list of open windows */ - this.addMenuItem(new PopupMenu.PopupSeparatorMenuItem(_("Open Windows"))); + this._openWindowsHeader = new PopupMenu.PopupSeparatorMenuItem(_('Open Windows')); + this.addMenuItem(this._openWindowsHeader); this._windowSection = new PopupMenu.PopupMenuSection(); this.addMenuItem(this._windowSection); @@ -118,11 +119,17 @@ class AppMenu extends PopupMenu.PopupMenu { _updateWindowsSection() { this._windowSection.removeAll(); + this._openWindowsHeader.hide(); if (!this._app) return; let windows = this._app.get_windows(); + if (windows.length < 2) + return; + + this._openWindowsHeader.show(); + windows.forEach(window => { let title = window.title || this._app.get_name(); let item = this._windowSection.addAction(title, event => {