[gnome-maps/wip/mlundblad/cleanup-gtk-deprecations: 2/4] contextMenu: 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: 2/4] contextMenu: Stop using GtkWidget event signals
- Date: Wed, 24 Mar 2021 20:40:51 +0000 (UTC)
commit 7e760a92146822cbbee1640481cd00da6f697c7d
Author: Marcus Lundblad <ml update uu se>
Date: Wed Mar 24 21:38:14 2021 +0100
contextMenu: Stop using GtkWidget event signals
Event controllers and gestures replace event
signals in GTK 4. Prepare this already now
in GTK 3.
src/contextMenu.js | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
---
diff --git a/src/contextMenu.js b/src/contextMenu.js
index bfa04d79..c1fc4eb0 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -54,8 +54,10 @@ var ContextMenu = GObject.registerClass({
super._init(params);
- this._mapView.connect('button-release-event',
- this._onButtonReleaseEvent.bind(this));
+ this._buttonGesture =
+ new Gtk.GestureSingle({ widget: this._mapView,
+ button: Gdk.BUTTON_SECONDARY });
+ this._buttonGesture.connect('end', this._onButtonRelease.bind(this));
this._whatsHereItem.connect('activate',
this._onWhatsHereActivated.bind(this));
@@ -74,16 +76,14 @@ var ContextMenu = GObject.registerClass({
this._routingUpdate();
}
- _onButtonReleaseEvent(widget, event) {
- let [, button] = event.get_button();
+ _onButtonRelease(gesture, sequence) {
+ let event = gesture.get_last_event(sequence);
let [, x, y] = event.get_coords();
this._longitude = this._mapView.view.x_to_longitude(x);
this._latitude = this._mapView.view.y_to_latitude(y);
- if (button === Gdk.BUTTON_SECONDARY) {
- // Need idle to avoid Clutter dead-lock on re-entrance
- Mainloop.idle_add(() => this.popup_at_pointer(event));
- }
+ // Need idle to avoid Clutter dead-lock on re-entrance
+ Mainloop.idle_add(() => this.popup_at_pointer(event));
}
_routingUpdate() {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]