[gnome-maps/wip/mlundblad/cleanup-gtk-deprecations: 13/20] searchPopover: Stop using GtkWidget event signals
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/cleanup-gtk-deprecations: 13/20] searchPopover: Stop using GtkWidget event signals
- Date: Wed, 24 Mar 2021 22:05:13 +0000 (UTC)
commit 09e1ab09a96bb8add2a2e0e2afa5a74da31e3c25
Author: Marcus Lundblad <ml update uu se>
Date: Tue Mar 23 22:27:36 2021 +0100
searchPopover: Stop using GtkWidget event signals
Event controllers and gestures replace event
signals in GTK 4. Prepare this already now
in GTK 3.
src/searchPopover.js | 27 +++++++++++++++------------
1 file changed, 15 insertions(+), 12 deletions(-)
---
diff --git a/src/searchPopover.js b/src/searchPopover.js
index f848c5b5..64c9f229 100644
--- a/src/searchPopover.js
+++ b/src/searchPopover.js
@@ -38,18 +38,21 @@ var SearchPopover = GObject.registerClass({
// 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._entry.connect('key-press-event',
- this._propagateKeys.bind(this));
- this._entry.connect('button-press-event', () => this._list.unselect_all());
- }
+ this._keyController =
+ new Gtk.EventControllerKey({ widget: this._entry });
+ this._keyController.connect('key-pressed',
+ this._propagateKeys.bind(this));
- _propagateKeys(entry, event) {
- let keyval = event.get_keyval()[1];
+ this._buttonPressGesture = new Gtk.GestureSingle({ widget: this._entry });
+ this._buttonPressGesture.connect('begin',
+ () => this._list.unselect_all());
+ }
+ _propagateKeys(controller, keyval, keycode, state) {
if (keyval === Gdk.KEY_Escape) {
this.hide();
this._list.unselect_all();
- return Gdk.EVENT_STOP;
+ return true;
}
if (keyval === Gdk.KEY_Return ||
@@ -61,9 +64,9 @@ var SearchPopover = GObject.registerClass({
let row = this._list.get_selected_row();
if (this.visible && row) {
row.activate();
- return Gdk.EVENT_STOP;
+ return true;
} else {
- return Gdk.EVENT_PROPAGATE;
+ return false;
}
}
@@ -74,7 +77,7 @@ var SearchPopover = GObject.registerClass({
let length = this._list.get_children().length;
if (length === 0) {
- return Gdk.EVENT_PROPAGATE;
+ return false;
}
let direction = (keyval === Gdk.KEY_KP_Up || keyval === Gdk.KEY_Up) ? -1 : 1;
@@ -92,10 +95,10 @@ var SearchPopover = GObject.registerClass({
} else {
this._list.unselect_all();
}
- return Gdk.EVENT_STOP;
+ return true;
}
- return Gdk.EVENT_PROPAGATE;
+ return false;
}
/* Selects given row and ensures that it is visible. */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]