[gnome-maps/wip/mlundblad/handle-osm-urls: 3/3] WIP: placeEntry: Parse OSM URLs



commit b4d74faf11aef638fcce2d2dc5e1703aaf122e16
Author: Marcus Lundblad <ml update uu se>
Date:   Fri Jun 21 00:00:46 2019 +0200

    WIP: placeEntry: Parse OSM URLs

 src/placeEntry.js | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
---
diff --git a/src/placeEntry.js b/src/placeEntry.js
index c9950e3..be54129 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -20,6 +20,8 @@
  *         Mattias Bengtsson <mattias jc bengtsson gmail com>
  */
 
+const _ = imports.gettext.gettext;
+
 const GLib = imports.gi.GLib;
 const GObject = imports.gi.GObject;
 const Geocode = imports.gi.GeocodeGlib;
@@ -219,6 +221,24 @@ var PlaceEntry = GObject.registerClass({
             parsed = true;
         }
 
+        if (Place.matchOSMURL(this.text)) {
+            if (this._cancellable)
+                this._cancellable.cancel();
+            this._cancellable = null;
+            Place.parseOSMURL(this.text, (place) => {
+                if (place)
+                    this.place = place;
+                else
+                    Utils.showDialog(_("Object not found in OpenStreetMap"),
+                                     Gtk.MessageType.ERROR, this.get_toplevel());
+            });
+
+            /* don't cancel ongoing search, as we have started an async
+             * operation looking up the OSM object
+             */
+            return true;
+        }
+
         if (parsed && this._cancellable)
             this._cancellable.cancel();
 


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