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



commit 19f3c0de52b72b87b7fcad78a7d92f45a1ae9e6d
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 d1a446a..2614dd3 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;
@@ -213,6 +215,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]