[gnome-maps] sendToDialog: Ensure consistency when marker moves



commit c28cb59a284c5d51c2218f3c48330479d280746f
Author: James Westman <flyingpimonster gmail com>
Date:   Wed Jan 1 21:51:22 2020 -0600

    sendToDialog: Ensure consistency when marker moves
    
    The Send To dialog now remembers the exact coordinates, not just the
    Place object, from when it was created. This way, if the place moves
    (such as a moving current location marker), the coordinates shown in the
    dialog remain the same as when the Send To button was pressed.
    
    Also, the map bubble now creates a new sendToDialog every time the Send
    To button is pressed, so that the latest marker position is shown in the
    dialog.

 src/mapBubble.js    | 10 +++++-----
 src/sendToDialog.js | 13 +++++++------
 2 files changed, 12 insertions(+), 11 deletions(-)
---
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 211acc36..998f0213 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -143,13 +143,13 @@ class MapBubble extends Gtk.Popover {
     }
 
     _initSendToButton(button) {
-        let dialog = new SendToDialog.SendToDialog({ transient_for: this.get_toplevel(),
-                                                     modal: true,
-                                                     mapView: this._mapView,
-                                                     place: this._place });
         button.visible = true;
         button.connect('clicked', () => {
-            dialog.connect('response', () => dialog.hide());
+            let dialog = new SendToDialog.SendToDialog({ transient_for: this.get_toplevel(),
+                                                         modal: true,
+                                                         mapView: this._mapView,
+                                                         place: this._place });
+            dialog.connect('response', () => dialog.destroy());
             dialog.show();
         });
     }
diff --git a/src/sendToDialog.js b/src/sendToDialog.js
index ed3a1548..9c3e9632 100644
--- a/src/sendToDialog.js
+++ b/src/sendToDialog.js
@@ -59,6 +59,7 @@ var SendToDialog = GObject.registerClass({
 
     _init(params) {
         this._place = params.place;
+        this._location = this._place.location;
         delete params.place;
 
         this._mapView = params.mapView;
@@ -95,7 +96,7 @@ var SendToDialog = GObject.registerClass({
 
         if (GWeather) {
             let world = GWeather.Location.get_world();
-            let location = this._place.location;
+            let location = this._location;
             this._city = world.find_nearest_city(location.latitude,
                                                  location.longitude);
             /* Translators: The first string is the name of the city, the
@@ -157,8 +158,8 @@ var SendToDialog = GObject.registerClass({
             lines.push(details);
         }
 
-        lines.push('%f, %f'.format(place.location.latitude,
-                                   place.location.longitude));
+        lines.push('%f, %f'.format(this._location.latitude,
+                                   this._location.longitude));
 
         return lines.join('\n');
     }
@@ -174,8 +175,8 @@ var SendToDialog = GObject.registerClass({
                                      place.osm_id);
         } else {
             return '%s?mlat=%f&mlon=%f&zoom=%d'.format(base,
-                                                       place.location.latitude,
-                                                       place.location.longitude,
+                                                       this._location.latitude,
+                                                       this._location.longitude,
                                                        view.zoom_level);
         }
     }
@@ -237,7 +238,7 @@ var SendToDialog = GObject.registerClass({
                                  new GLib.Variant('v', this._city.serialize()),
                                  timestamp);
         } else if (row instanceof OpenWithRow) {
-            let uri = this._place.location.to_uri(Geocode.LocationURIScheme.GEO);
+            let uri = this._location.to_uri(Geocode.LocationURIScheme.GEO);
             row.appinfo.launch_uris([ uri ], this._getAppLaunchContext());
         }
         this.response(Response.SUCCESS);


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