shellMountDialog: Close all dialogs when pressing Escape key

Since we don't really know what the buttons we're adding to the dialogs
are about, we can't configure a button to "be clicked" when the escape
key is pressed. So add a separate escape key handler to fix that, return
-1 and abort the request.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/961
This commit is contained in:
Jonas Dreßler 2020-01-27 18:46:17 +01:00 committed by Florian Müllner
parent 0b51a52c9b
commit 6d2c834694

View File

@ -236,6 +236,15 @@ var ShellMountQuestionDialog = GObject.registerClass({
this.contentLayout.add_child(this._content);
}
vfunc_key_release_event(event) {
if (event.keyval === Clutter.KEY_Escape) {
this.emit('response', -1);
return Clutter.EVENT_STOP;
}
return Clutter.EVENT_PROPAGATE;
}
update(message, choices) {
_setLabelsForMessage(this._content, message);
_setButtonsForChoices(this, this._oldChoices, choices);
@ -481,7 +490,13 @@ var ShellProcessesDialog = GObject.registerClass({
this.contentLayout.add_child(this._applicationSection);
}
vfunc_key_release_event(event) {
if (event.keyval === Clutter.KEY_Escape) {
this.emit('response', -1);
return Clutter.EVENT_STOP;
}
return Clutter.EVENT_PROPAGATE;
}
_setAppsForPids(pids) {
@ -662,8 +677,17 @@ var GnomeShellMountOpHandler = class {
this._dialog = new ShellMountQuestionDialog(message);
this._dialog.connect('response', (object, choice) => {
this._clearCurrentRequest(Gio.MountOperationResult.HANDLED,
{ choice: GLib.Variant.new('i', choice) });
let response;
let details = {};
if (choice == -1) {
response = Gio.MountOperationResult.ABORTED;
} else {
response = Gio.MountOperationResult.HANDLED;
details['choice'] = GLib.Variant.new('i', choice);
}
this._clearCurrentRequest(response, details);
});
this._dialog.update(message, choices);