[gnome-maps/wip/mlundblad/touch-gestures] contextMenu: WIP: use a GtkGestureLongPress...



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

    contextMenu: WIP: use a GtkGestureLongPress...

 src/contextMenu.js |   22 ++++++++++++++++++++++
 1 files changed, 22 insertions(+), 0 deletions(-)
---
diff --git a/src/contextMenu.js b/src/contextMenu.js
index 5306093..3dee94a 100644
--- a/src/contextMenu.js
+++ b/src/contextMenu.js
@@ -72,6 +72,28 @@ var ContextMenu = new Lang.Class({
                                        this._routingUpdate.bind(this));
         this._routeItem.visible = false;
         this._routingUpdate();
+        this._initLongPress();
+    },
+
+    _initLongPress: function() {
+        this._longPressGesture = new Gtk.GestureLongPress({ widget: this._mapView });
+        this._longPressGesture.connect('pressed', (function(gesture, x, y) {
+            Mainloop.idle_add((function() {
+                Utils.debug('long press');
+                Utils.debug('active: ' + gesture.is_active());
+                let rect = new Gdk.Rectangle({x: x, y: y, width: 0, height: 0});
+                let sequence = gesture.get_last_updated_sequence();
+                let sequences = gesture.get_sequences();
+                Utils.debug('current sequence: ' + sequence);
+                Utils.debug('len: ' + sequences.length);
+                Utils.debug('seq: ' + sequences[0]);
+                //this.popup_at_pointer(gesture.get_last_event(sequence));
+
+                // This gives a GTK warning, but I can't find a better way to do it
+                this.popup_at_rect(this._mapView.window, rect,
+                                   Gdk.Gravity.NORTH_WEST, Gdk.Gravity.NORTH_WEST, null);
+            }).bind(this));
+        }).bind(this));
     },
 
     _onButtonReleaseEvent: function(widget, event) {


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