status/system: Add separate 'Restart' item

A side effect of removing the action buttons in favor of a regular
submenu is that we are a lot less constrained by size. So instead
of lumping "Restart" in with "Power Off", make it a separate menu
item.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2202
This commit is contained in:
Florian Müllner 2020-07-01 17:15:48 +02:00 committed by Florian Müllner
parent e6153bb578
commit 263320696e

View File

@ -27,6 +27,8 @@ class Indicator extends PanelMenu.SystemIndicator {
() => this._updateSessionSubMenu());
this._powerOffItem.connect('notify::visible',
() => this._updateSessionSubMenu());
this._restartItem.connect('notify::visible',
() => this._updateSessionSubMenu());
// Whether shutdown is available or not depends on both lockdown
// settings (disable-log-out) and Polkit policy - the latter doesn't
// notify, so we update the menu item each time the menu opens or
@ -52,6 +54,7 @@ class Indicator extends PanelMenu.SystemIndicator {
this._loginScreenItem.visible ||
this._logoutItem.visible ||
this._suspendItem.visible ||
this._restartItem.visible ||
this._powerOffItem.visible;
}
@ -124,6 +127,17 @@ class Indicator extends PanelMenu.SystemIndicator {
this._suspendItem, 'visible',
bindFlags);
item = new PopupMenu.PopupMenuItem(_('Restart…'));
item.connect('activate', () => {
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);
this._systemActions.activateRestart();
});
this._sessionSubMenu.menu.addMenuItem(item);
this._restartItem = item;
this._systemActions.bind_property('can-restart',
this._restartItem, 'visible',
bindFlags);
item = new PopupMenu.PopupMenuItem(_('Power Off…'));
item.connect('activate', () => {
this.menu.itemActivated(BoxPointer.PopupAnimation.NONE);