[gnome-maps] Track user location toggle -> goto user location button



commit 92248d63f4ba9f8cb536a4d1abf390a4b2a30166
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date:   Tue Aug 6 17:30:25 2013 +0200

    Track user location toggle -> goto user location button
    
    Instead of providing a persistent toggle button to tracker user
    location, provide a simple button to go to user location.
    
    This also means that we now always go to user location on launch.

 data/org.gnome.maps.gschema.xml.in |    5 ----
 src/main-window.ui                 |    4 +-
 src/mainWindow.js                  |   44 ++++++-----------------------------
 3 files changed, 10 insertions(+), 43 deletions(-)
---
diff --git a/data/org.gnome.maps.gschema.xml.in b/data/org.gnome.maps.gschema.xml.in
index f2d9150..2ac23bf 100644
--- a/data/org.gnome.maps.gschema.xml.in
+++ b/data/org.gnome.maps.gschema.xml.in
@@ -25,10 +25,5 @@
       <_summary>Description of last known location</_summary>
       <_description>Description of last known location of user.</_description>
     </key>
-    <key name="track-user-location" type="b">
-      <default>true</default>
-      <_summary>Track user location</_summary>
-      <_description>Track user location.</_description>
-    </key>
   </schema>
 </schemalist>
diff --git a/src/main-window.ui b/src/main-window.ui
index bc62cf3..1d9e4ec 100644
--- a/src/main-window.ui
+++ b/src/main-window.ui
@@ -31,11 +31,11 @@
           </object>
         </child>
         <child>
-          <object class="GdHeaderToggleButton" id="track-user-button">
+          <object class="GdHeaderSimpleButton" id="goto-user-location-button">
             <property name="visible">True</property>
             <property name="can_focus">True</property>
             <property name="symbolic-icon-name">find-location-symbolic</property>
-            <property name="action_name">win.track-user-location</property>
+            <property name="action_name">win.goto-user-location</property>
           </object>
           <packing>
             <property name="pack_type">start</property>
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 1b5fcb5..213cde4 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -58,8 +58,7 @@ const MainWindow = new Lang.Class({
 
         this.mapView = new MapView.MapView();
 
-        if(Application.settings.get_boolean('track-user-location'))
-            this.mapView.gotoUserLocation(false);
+        this.mapView.gotoUserLocation(false);
 
         this._initActions();
         this._initSignals();
@@ -91,10 +90,11 @@ const MainWindow = new Lang.Class({
                     state: GLib.Variant.new('s', 'STREET')
                 },
                 signalHandlers: { activate: this._onMapTypeActivate }
+            }, {
+                properties: { name: 'goto-user-location' },
+                signalHandlers: { activate: this._onGotoUserLocationActivate }
             }
         ], this);
-        let action = Application.settings.create_action('track-user-location');
-        this.window.add_action(action);
     },
 
     _initSignals: function() {
@@ -109,38 +109,6 @@ const MainWindow = new Lang.Class({
         this._searchEntry.connect('activate',
                                   this._onSearchActivate.bind(this));
         this._viewMovedId = 0;
-        this._connectMapMove();
-        this.mapView.connect('going-to-user-location',
-                             this._disconnectMapMove.bind(this));
-        this.mapView.connect('gone-to-user-location',
-                             this._connectMapMove.bind(this));
-
-        this.mapView.connect('user-location-changed',
-                             this._onUserLocationChanged.bind(this));
-        Application.settings.connect('changed::track-user-location',
-                                     this._onUserLocationChanged.bind(this));
-    },
-
-    _connectMapMove: function() {
-        if (this._viewMovedId === 0) {
-            this._viewMovedId = this.mapView.connect('view-moved', (function() {
-                if (!this.mapView.userLocationVisible())
-                    Application.settings.set_boolean('track-user-location', false);
-            }).bind(this));
-        }
-    },
-
-    _disconnectMapMove: function() {
-        if (this._viewMovedId !== 0) {
-            this.mapView.disconnect(this._viewMovedId);
-            this._viewMovedId = 0;
-        }
-    },
-
-    _onUserLocationChanged: function() {
-        if (Application.settings.get_boolean('track-user-location')) {
-            this.mapView.gotoUserLocation(true);
-        }
     },
 
     _saveWindowGeometry: function() {
@@ -241,6 +209,10 @@ const MainWindow = new Lang.Class({
         return false;
     },
 
+    _onGotoUserLocationActivate: function() {
+        this.mapView.gotoUserLocation(true);
+    },
+
     _onMapTypeMenuActivate: function(action) {
         let state = action.get_state().get_boolean();
         action.set_state(GLib.Variant.new('b', !state));


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