2020-02-06 21:04:21 +00:00
|
|
|
From f91a2109fb139131a5f4ba5d00fca043df82ba10 Mon Sep 17 00:00:00 2001
|
2018-09-27 07:26:30 +00:00
|
|
|
From: Hans de Goede <hdegoede@redhat.com>
|
|
|
|
Date: Wed, 15 Aug 2018 15:03:56 +0200
|
|
|
|
Subject: [PATCH 2/2] endSessionDialog: Support rebooting into the bootloader
|
|
|
|
menu aka ("Boot Options")
|
|
|
|
|
|
|
|
This implements the "Alt" behavior for the "Reboot" button as outlined in
|
|
|
|
the design here: https://wiki.gnome.org/Design/OS/BootOptions
|
|
|
|
|
|
|
|
This causes the endSessionDialog to send a ConfirmedRebootToBootOptions signal
|
|
|
|
to gnome-session instead of the normal ConfirmedReboot signal, actually
|
|
|
|
telling the boot-loader that it should show its menu the next boot is left
|
|
|
|
up to gnome-session.
|
|
|
|
|
2019-02-07 01:50:26 +00:00
|
|
|
Note I've tried implemeting this with the AltSwitcher class from
|
2018-09-27 07:26:30 +00:00
|
|
|
js/ui/status/system.js first, but that puts the button in a St.Bin()
|
|
|
|
which causes the button to think it is the only button on the dialog
|
|
|
|
and makes it have rounded corners on both of its bottom corners.
|
|
|
|
---
|
2019-12-11 22:39:28 +00:00
|
|
|
js/ui/endSessionDialog.js | 52 +++++++++++++++++++++++++++++++++++++++
|
|
|
|
1 file changed, 52 insertions(+)
|
2018-09-27 07:26:30 +00:00
|
|
|
|
|
|
|
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
|
2020-02-06 21:04:21 +00:00
|
|
|
index 27ddf6804..6cebf2a81 100644
|
2018-09-27 07:26:30 +00:00
|
|
|
--- a/js/ui/endSessionDialog.js
|
|
|
|
+++ b/js/ui/endSessionDialog.js
|
2020-02-06 21:04:21 +00:00
|
|
|
@@ -239,6 +239,9 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
|
2018-09-27 07:26:30 +00:00
|
|
|
this._totalSecondsToStayOpen = 0;
|
|
|
|
this._applications = [];
|
|
|
|
this._sessions = [];
|
|
|
|
+ this._capturedEventId = 0;
|
|
|
|
+ this._rebootButton = null;
|
|
|
|
+ this._rebootButtonAlt = null;
|
|
|
|
|
|
|
|
this.connect('destroy',
|
|
|
|
this._onDestroy.bind(this));
|
2020-02-06 21:04:21 +00:00
|
|
|
@@ -368,6 +371,26 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
|
|
|
|
this._sessionSection.visible = hasSessions;
|
2019-02-07 01:50:26 +00:00
|
|
|
}
|
2018-09-27 07:26:30 +00:00
|
|
|
|
|
|
|
+ _onCapturedEvent(actor, event) {
|
|
|
|
+ let altEnabled = false;
|
|
|
|
+
|
|
|
|
+ let type = event.type();
|
|
|
|
+ if (type != Clutter.EventType.KEY_PRESS && type != Clutter.EventType.KEY_RELEASE)
|
|
|
|
+ return Clutter.EVENT_PROPAGATE;
|
|
|
|
+
|
|
|
|
+ let key = event.get_key_symbol();
|
|
|
|
+ if (key != Clutter.KEY_Alt_L && key != Clutter.KEY_Alt_R)
|
|
|
|
+ return Clutter.EVENT_PROPAGATE;
|
|
|
|
+
|
|
|
|
+ if (type == Clutter.EventType.KEY_PRESS)
|
|
|
|
+ altEnabled = true;
|
|
|
|
+
|
|
|
|
+ this._rebootButton.visible = !altEnabled;
|
|
|
|
+ this._rebootButtonAlt.visible = altEnabled;
|
|
|
|
+
|
|
|
|
+ return Clutter.EVENT_PROPAGATE;
|
2019-02-07 01:50:26 +00:00
|
|
|
+ }
|
2018-09-27 07:26:30 +00:00
|
|
|
+
|
|
|
|
_updateButtons() {
|
|
|
|
this.clearButtons();
|
|
|
|
|
2020-02-06 21:04:21 +00:00
|
|
|
@@ -389,7 +412,34 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
|
2019-08-09 22:56:47 +00:00
|
|
|
},
|
2019-12-11 22:39:28 +00:00
|
|
|
label,
|
2019-08-09 22:56:47 +00:00
|
|
|
});
|
2018-09-27 07:26:30 +00:00
|
|
|
+
|
|
|
|
+ // Add Alt "Boot Options" option to the Reboot button
|
|
|
|
+ if (signal == 'ConfirmedReboot') {
|
|
|
|
+ this._rebootButton = button;
|
2019-08-09 22:56:47 +00:00
|
|
|
+ this._rebootButtonAlt = this.addButton({
|
|
|
|
+ action: () => {
|
|
|
|
+ this.close(true);
|
|
|
|
+ let signalId = this.connect('closed', () => {
|
|
|
|
+ this.disconnect(signalId);
|
|
|
|
+ this._confirm('ConfirmedRebootToBootOptions');
|
|
|
|
+ });
|
|
|
|
+ },
|
|
|
|
+ label: C_("button", "Boot Options")
|
|
|
|
+ });
|
2018-09-27 07:26:30 +00:00
|
|
|
+ this._rebootButtonAlt.visible = false;
|
2019-12-11 22:39:28 +00:00
|
|
|
+ this._capturedEventId = global.stage.connect('captured-event',
|
|
|
|
+ this._onCapturedEvent.bind(this));
|
2018-09-27 07:26:30 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
2019-02-07 01:50:26 +00:00
|
|
|
+ }
|
2018-09-27 07:26:30 +00:00
|
|
|
+
|
|
|
|
+ _stopAltCapture() {
|
|
|
|
+ if (this._capturedEventId > 0) {
|
|
|
|
+ global.stage.disconnect(this._capturedEventId);
|
|
|
|
+ this._capturedEventId = 0;
|
|
|
|
}
|
|
|
|
+ this._rebootButton = null;
|
|
|
|
+ this._rebootButtonAlt = null;
|
2019-02-07 01:50:26 +00:00
|
|
|
}
|
2018-09-27 07:26:30 +00:00
|
|
|
|
|
|
|
close(skipSignal) {
|
2020-02-06 21:04:21 +00:00
|
|
|
@@ -401,6 +451,7 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
|
2018-09-27 07:26:30 +00:00
|
|
|
|
|
|
|
cancel() {
|
|
|
|
this._stopTimer();
|
|
|
|
+ this._stopAltCapture();
|
|
|
|
this._dbusImpl.emit_signal('Canceled', null);
|
|
|
|
this.close();
|
2019-02-07 01:50:26 +00:00
|
|
|
}
|
2020-02-06 21:04:21 +00:00
|
|
|
@@ -409,6 +460,7 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
|
2018-09-27 07:26:30 +00:00
|
|
|
let callback = () => {
|
|
|
|
this._fadeOutDialog();
|
|
|
|
this._stopTimer();
|
|
|
|
+ this._stopAltCapture();
|
|
|
|
this._dbusImpl.emit_signal(signal, null);
|
|
|
|
};
|
|
|
|
|
|
|
|
--
|
2020-02-06 21:04:21 +00:00
|
|
|
2.24.1
|
2018-09-27 07:26:30 +00:00
|
|
|
|