[gnome-maps/wip/mlundblad/touch-gestures: 53/54] contextMenu: Add a long-press gesture to activate on touch



commit 833efcce99ed915f7df47676615c3fbcedccdb3d
Author: Marcus Lundblad <ml update uu se>
Date:   Mon Oct 16 22:21:32 2017 +0200

    contextMenu: Add a long-press gesture to activate on touch
    
    https://bugzilla.gnome.org/show_bug.cgi?id=709605

 src/contextMenu.js |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 297f0f6..db5c58f 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -70,6 +70,25 @@ var ContextMenu = GObject.registerClass({
                                        this._routingUpdate.bind(this));
         this._routeItem.visible = false;
         this._routingUpdate();
+        this._initLongPress();
+    }
+
+    _initLongPress() {
+        this._longPressGesture =
+            new Gtk.GestureLongPress({ widget: this._mapView, 'touch-only': true });
+        this._longPressGesture.connect('pressed', this._onLongPress.bind(this));
+    }
+
+    _onLongPress(gesture, x, y) {
+        this._longitude = this._mapView.view.x_to_longitude(x);
+        this._latitude = this._mapView.view.y_to_latitude(y);
+        Mainloop.idle_add(() => {
+            let rect = new Gdk.Rectangle({ x: 0, y: 0, width: x, height: y });
+
+            this.popup_at_rect(this._mapView.window, rect,
+                               Gdk.Gravity.SOUTH_EAST, Gdk.Gravity.NORTH_WEST,
+                               null);
+        });
     }
 
     _onButtonReleaseEvent(widget, event) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]