workspace-indicator: Fix cancelling editing with Esc

The CallbackAction's callback must return true to stop the event
from propagating to the dialog, where it will trigger the close
binding.

It makes sense to still allow closing the dialog with Escape while
not editing a row. The easiest way to achieve that is by moving the
controller to the entry.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell-extensions/-/merge_requests/208>
This commit is contained in:
Florian Müllner
2022-01-06 01:30:27 +01:00
committed by Marge Bot
parent cdaa837d48
commit 8dd8d6f561

View File

@@ -120,13 +120,6 @@ class WorkspaceRow extends Gtk.ListBoxRow {
_init(name) {
super._init({ name });
const controller = new Gtk.ShortcutController();
controller.add_shortcut(new Gtk.Shortcut({
trigger: Gtk.ShortcutTrigger.parse_string('Escape'),
action: Gtk.CallbackAction.new(this._stopEdit.bind(this)),
}));
this.add_controller(controller);
const box = new Gtk.Box({
spacing: 12,
margin_top: 6,
@@ -156,6 +149,16 @@ class WorkspaceRow extends Gtk.ListBoxRow {
max_width_chars: 25,
});
const controller = new Gtk.ShortcutController();
controller.add_shortcut(new Gtk.Shortcut({
trigger: Gtk.ShortcutTrigger.parse_string('Escape'),
action: Gtk.CallbackAction.new(() => {
this._stopEdit();
return true;
}),
}));
this._entry.add_controller(controller);
this._stack = new Gtk.Stack();
this._stack.add_named(box, 'display');
this._stack.add_named(this._entry, 'edit');