diff options
author | Marcus Lundblad <ml@dfupdate.se> | 2023-01-06 23:47:46 +0100 |
---|---|---|
committer | Marcus Lundblad <ml@dfupdate.se> | 2023-01-17 22:52:50 +0100 |
commit | f32b99b4cc37c46810edff0e6f54de382e1c7a37 (patch) | |
tree | f785f36ab15894a2bd0a8a7dcd59dc7759028448 /src | |
parent | b430db3230b5ef0e4ea79cb7cbf0f92b3b25dd5d (diff) | |
download | gnome-maps-f32b99b4cc37c46810edff0e6f54de382e1c7a37.tar.gz |
searchPopover: Remove key controller
Since the popover doesn't grab the focus
and the key controller to handle cursor
keys will be re-implemented on the search
entry.
Diffstat (limited to 'src')
-rw-r--r-- | src/searchPopover.js | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/src/searchPopover.js b/src/searchPopover.js index a830c8b1..f14a1c54 100644 --- a/src/searchPopover.js +++ b/src/searchPopover.js @@ -20,7 +20,6 @@ * Jonas Danielsson <jonas@threetimestwo.org> */ -import Gdk from 'gi://Gdk'; import GObject from 'gi://GObject'; import Gtk from 'gi://Gtk'; @@ -33,14 +32,6 @@ export class SearchPopover extends Gtk.Popover { this._entry = entry; - // We need to propagate events to the listbox so that we can - // keep typing while selecting a place. But we do not want to - // propagate the 'enter' key press if there is a selection. - this._keyController = new Gtk.EventControllerKey(); - this.add_controller(this._keyController); - this._keyController.connect('key-pressed', - this._propagateKeys.bind(this)); - this._buttonPressGesture = new Gtk.GestureSingle(); this._entry.add_controller(this._buttonPressGesture); this._buttonPressGesture.connect('begin', @@ -50,71 +41,6 @@ export class SearchPopover extends Gtk.Popover { this.add_css_class('suggestions'); } - - _propagateKeys(controller, keyval, keycode, state) { - if (keyval === Gdk.KEY_Escape) { - this.hide(); - this._list.unselect_all(); - } else if (keyval === Gdk.KEY_Return || - keyval === Gdk.KEY_KP_ENTER || - keyval === Gdk.KEY_ISO_Enter) { - - // If we get an 'enter' keypress and we have a selected - // row, we do not want to propagate the event. - let row = this._list.get_selected_row(); - - if (this.visible && row) { - row.activate(); - } else { - controller.forward(this._entry); - } - } else if (keyval === Gdk.KEY_KP_Up || - keyval === Gdk.KEY_Up || - keyval === Gdk.KEY_KP_Down || - keyval === Gdk.KEY_Down) { - - let length = this._numResults; - if (length === 0) { - controller.forward(this._entry); - } - - let direction = (keyval === Gdk.KEY_KP_Up || keyval === Gdk.KEY_Up) ? -1 : 1; - let row = this._list.get_selected_row(); - let idx; - if (!row) { - idx = (direction === 1) ? 0 : length - 1; - } else { - idx = row.get_index() + direction; - } - let inBounds = 0 <= idx && idx < length; - if (inBounds) { - this.show(); - this._selectRow(this._list.get_row_at_index(idx)); - } else { - this._list.unselect_all(); - } - } else { - if (keyval === Gdk.KEY_space) { - /* forwarding space seems to not work for some reason, - * work around by manually injecting a space into the entry string - */ - this._entry.set_text(this._entry.text + ' '); - this._entry.set_position(this._entry.text.length); - } else { - controller.forward(this._entry); - } - } - } - - /* Selects given row and ensures that it is visible. */ - _selectRow(row) { - this._list.select_row(row); - let adjustment = this._list.get_adjustment(); - if (adjustment) { - let allocation = row.get_allocation(); - adjustment.clamp_page(allocation.y, allocation.y + allocation.height); - } - } } GObject.registerClass({ |