[gnome-maps/wip/mlundblad/maps-uri: 2/3] placeEntry: Allow pasting maps: URIs into the search entry




commit f7d59ca3402dd83a13b453baaa546d47e3fd7dfb
Author: Marcus Lundblad <ml update uu se>
Date:   Wed Nov 3 09:20:46 2021 +0100

    placeEntry: Allow pasting maps: URIs into the search entry

 src/application.js |  6 ++++--
 src/placeEntry.js  | 14 ++++++++++++++
 2 files changed, 18 insertions(+), 2 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 8fc776cc..efb5ccdf 100644
--- a/src/application.js
+++ b/src/application.js
@@ -353,11 +353,13 @@ var Application = GObject.registerClass({
                  * with it's bubble, otherwise present the results in the
                  * search popover
                  */
-                if (places?.length === 1)
+                if (places?.length === 1) {
                     this._mainWindow.mapView.showPlace(places[0], true);
-                else
+                } else {
+                    this._mainWindow.placeEntry.grab_focus();
                     this._mainWindow.placeEntry.updateResults(places, query,
                                                               false);
+                }
             }
         });
     }
diff --git a/src/placeEntry.js b/src/placeEntry.js
index 5bbfd348..c39823cd 100644
--- a/src/placeEntry.js
+++ b/src/placeEntry.js
@@ -34,6 +34,7 @@ const Location = imports.location;
 const Place = imports.place;
 const PlaceStore = imports.placeStore;
 const PlacePopover = imports.placePopover;
+const URIS = imports.uris;
 const Utils = imports.utils;
 
 // minimum number of characters to start completion
@@ -225,6 +226,19 @@ var PlaceEntry = GObject.registerClass({
             parsed = true;
         }
 
+        if (this.text.startsWith('maps:')) {
+            let query = URIS.parseMapsURI(this.text);
+
+            if (query) {
+                this.text = query;
+            } else {
+                let msg = _("Failed to parse Maps URI");
+                Utils.showDialog(msg, Gtk.MessageType.ERROR, this.get_toplevel());
+            }
+
+            parsed = true;
+        }
+
         let parsedLocation = Place.Place.parseCoordinates(this.text);
         if (parsedLocation) {
             /* if the place was a parsed OSM coordinate URL, it will have


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