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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1827>
This commit is contained in:
parent
4bf2adb4b9
commit
fd0da9606f
@ -30,7 +30,8 @@ class AppMenu extends PopupMenu.PopupMenu {
|
|||||||
this._windowsChangedId = 0;
|
this._windowsChangedId = 0;
|
||||||
|
|
||||||
/* Translators: This is the heading of a list of open windows */
|
/* 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._windowSection = new PopupMenu.PopupMenuSection();
|
||||||
this.addMenuItem(this._windowSection);
|
this.addMenuItem(this._windowSection);
|
||||||
@ -118,11 +119,17 @@ class AppMenu extends PopupMenu.PopupMenu {
|
|||||||
|
|
||||||
_updateWindowsSection() {
|
_updateWindowsSection() {
|
||||||
this._windowSection.removeAll();
|
this._windowSection.removeAll();
|
||||||
|
this._openWindowsHeader.hide();
|
||||||
|
|
||||||
if (!this._app)
|
if (!this._app)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
let windows = this._app.get_windows();
|
let windows = this._app.get_windows();
|
||||||
|
if (windows.length < 2)
|
||||||
|
return;
|
||||||
|
|
||||||
|
this._openWindowsHeader.show();
|
||||||
|
|
||||||
windows.forEach(window => {
|
windows.forEach(window => {
|
||||||
let title = window.title || this._app.get_name();
|
let title = window.title || this._app.get_name();
|
||||||
let item = this._windowSection.addAction(title, event => {
|
let item = this._windowSection.addAction(title, event => {
|
||||||
|
Loading…
Reference in New Issue
Block a user