[gnome-maps] userLocationBubble: Merge into placeBubble



commit 7247026a6564f66cc0596a0ce31d1fa068812be2
Author: James Westman <james flyingpimonster net>
Date:   Wed Nov 25 14:58:21 2020 -0600

    userLocationBubble: Merge into placeBubble
    
    Instead of two separate classes, all bubble contents are handled by PlaceBubble.
    This cuts down a bit of code duplication. Also, it will make adaptive place
    bubbles much easier since only one bubble type has to be made adaptive.

 data/org.gnome.Maps.data.gresource.xml |  1 -
 data/ui/user-location-bubble.ui        | 92 ----------------------------------
 po/POTFILES.in                         |  1 -
 src/org.gnome.Maps.src.gresource.xml   |  1 -
 src/placeBubble.js                     | 66 +++++++++++++++++-------
 src/userLocationBubble.js              | 55 --------------------
 src/userLocationMarker.js              |  6 +--
 7 files changed, 51 insertions(+), 171 deletions(-)
---
diff --git a/data/org.gnome.Maps.data.gresource.xml b/data/org.gnome.Maps.data.gresource.xml
index 789866ce..e020e549 100644
--- a/data/org.gnome.Maps.data.gresource.xml
+++ b/data/org.gnome.Maps.data.gresource.xml
@@ -37,7 +37,6 @@
     <file preprocess="xml-stripblanks">ui/transit-options-panel.ui</file>
     <file preprocess="xml-stripblanks">ui/transit-route-label.ui</file>
     <file preprocess="xml-stripblanks">ui/transit-stop-row.ui</file>
-    <file preprocess="xml-stripblanks">ui/user-location-bubble.ui</file>
     <file preprocess="xml-stripblanks">ui/zoom-in-dialog.ui</file>
     <file alias="application.css">gnome-maps.css</file>
     <file alias="osm-types.json" compressed="true">osm-types.json</file>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c83a4eeb..db80a06e 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -58,7 +58,6 @@ src/transitMoreRow.js
 src/transitOptionsPanel.js
 src/transitPlan.js
 src/translations.js
-src/userLocationBubble.js
 src/utils.js
 src/transitplugins/goMetro.js
 src/transitplugins/openTripPlanner.js
diff --git a/src/org.gnome.Maps.src.gresource.xml b/src/org.gnome.Maps.src.gresource.xml
index 67b9643c..c398e3cd 100644
--- a/src/org.gnome.Maps.src.gresource.xml
+++ b/src/org.gnome.Maps.src.gresource.xml
@@ -100,7 +100,6 @@
     <file>transitWalkMarker.js</file>
     <file>translations.js</file>
     <file>turnPointMarker.js</file>
-    <file>userLocationBubble.js</file>
     <file>userLocationMarker.js</file>
     <file>utils.js</file>
     <file>urls.js</file>
diff --git a/src/placeBubble.js b/src/placeBubble.js
index ffdd8a6b..e1256694 100644
--- a/src/placeBubble.js
+++ b/src/placeBubble.js
@@ -62,6 +62,11 @@ var PlaceBubble = GObject.registerClass({
         if (!(params.place instanceof ContactPlace.ContactPlace) && params.place.osm_id)
             params.buttons |= MapBubble.Button.EDIT_ON_OSM;
 
+        if (params.place.isUserLocation) {
+            params.buttons |= MapBubble.Button.CHECK_IN;
+            params.buttons &= ~MapBubble.Button.ROUTE;
+        }
+
         super._init(params);
 
         this.loading = true;
@@ -70,31 +75,40 @@ var PlaceBubble = GObject.registerClass({
                                            visible: true});
         this.content.add(this._placeDetails);
 
-        let overpass = new Overpass.Overpass();
-
-        /* use a property binding from the Overpass instance to avoid
-         * accessing accessing this object after the underlying GObject has
-         * been finalized */
-        overpass.bind_property('place', this, 'overpass-place',
-                               GObject.BindingFlags.DEFAULT);
-        this.connect('notify::overpass-place', () => this._onInfoAdded());
-
-        if (Application.placeStore.exists(this.place, null)) {
-
-            // If the place is stale, update from Overpass.
-            if (Application.placeStore.isStale(this.place)) {
+        if (this.place.isCurrentLocation) {
+            this._populate(this.place);
+        } else {
+            let overpass = new Overpass.Overpass();
+
+            /* use a property binding from the Overpass instance to avoid
+             * accessing this object after the underlying GObject has
+             * been finalized */
+            overpass.bind_property('place', this, 'overpass-place',
+                                   GObject.BindingFlags.DEFAULT);
+            this.connect('notify::overpass-place', () => this._onInfoAdded());
+
+            if (Application.placeStore.exists(this.place, null)) {
+
+                // If the place is stale, update from Overpass.
+                if (Application.placeStore.isStale(this.place)) {
+                    overpass.addInfo(this.place);
+                } else {
+                    this._place = Application.placeStore.get(this.place);
+                    this._populate(this.place);
+                }
+            } else if (this.place.store && !this.place.prefilled) {
                 overpass.addInfo(this.place);
             } else {
-                this._place = Application.placeStore.get(this.place);
                 this._populate(this.place);
             }
-        } else if (this.place.store && !this.place.prefilled) {
-            overpass.addInfo(this.place);
-        } else {
-            this._populate(this.place);
         }
     }
 
+    updateLocation() {
+        /* Called by the UserLocationMarker when its location changes */
+        this._populate(this.place);
+    }
+
     _onInfoAdded() {
         this._populate(this.place);
         if (Application.placeStore.exists(this.place, null))
@@ -113,6 +127,22 @@ var PlaceBubble = GObject.registerClass({
     _createContent(place) {
         let content = [];
 
+        if (place.isCurrentLocation) {
+            let coordinates = place.location.latitude.toFixed(5)
+                              + ', '
+                              + place.location.longitude.toFixed(5);
+            let accuracyDescription = Utils.getAccuracyDescription(this.place.location.accuracy);
+
+            content.push({ label: _("Coordinates"),
+                           icon: 'map-marker-symbolic',
+                           info: coordinates });
+
+            content.push({ label: _("Accuracy"),
+                           icon: 'find-location-symbolic',
+                           /* Translators: %s can be "Unknown", "Exact" or "%f km" (or ft/mi/m) */
+                           info: _("Accuracy: %s").format(accuracyDescription) });
+        }
+
         if (place.website) {
             if (Utils.isValidWebsite(place.website)) {
                 content.push({ label: _("Website"),
diff --git a/src/userLocationMarker.js b/src/userLocationMarker.js
index 2eee4f53..21126a84 100644
--- a/src/userLocationMarker.js
+++ b/src/userLocationMarker.js
@@ -24,7 +24,7 @@ const Clutter = imports.gi.Clutter;
 const GObject = imports.gi.GObject;
 
 const MapMarker = imports.mapMarker;
-const UserLocationBubble = imports.userLocationBubble;
+const PlaceBubble = imports.placeBubble;
 
 var AccuracyCircleMarker = GObject.registerClass(
 class AccuracyCirleMarker extends Champlain.Point {
@@ -91,8 +91,8 @@ class UserLocationMarker extends MapMarker.MapMarker {
     }
 
     _createBubble() {
-        return new UserLocationBubble.UserLocationBubble({ place: this.place,
-                                                           mapView: this._mapView });
+        return new PlaceBubble.PlaceBubble({ place: this.place,
+                                             mapView: this._mapView });
     }
 
     addToLayer(layer) {


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