[gnome-maps/wip/routing2: 11/18] Make GeoClue a global service



commit 8b101130d8dc13c983fb0450dd66fc79d94df0a0
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Fri May 2 20:49:17 2014 +0200

    Make GeoClue a global service
    
    Move GeoClue out from mapView and put it together with the other services.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728695

 src/application.js |    3 +++
 src/mainWindow.js  |   12 ++++++------
 src/mapView.js     |   15 +++++++--------
 3 files changed, 16 insertions(+), 14 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 40dfb9b..01cb7a1 100644
--- a/src/application.js
+++ b/src/application.js
@@ -34,6 +34,7 @@ const GLib = imports.gi.GLib;
 
 const Main = imports.main;
 const Format = imports.format;
+const Geoclue = imports.geoclue;
 const MainWindow = imports.mainWindow;
 const Notification = imports.notification;
 const NotificationManager = imports.notificationManager;
@@ -49,6 +50,7 @@ let settings = null;
 let placeStore = null;
 let notificationManager = null;
 let routeService = null;
+let geoclue = null;
 
 const Application = new Lang.Class({
     Name: 'Application',
@@ -97,6 +99,7 @@ const Application = new Lang.Class({
         application = this;
         settings = new Settings.Settings('org.gnome.maps');
         routeService = new RouteService.GraphHopper();
+        geoclue =  new Geoclue.Geoclue();
 
         Utils.initActions(this, [{
             properties: { name: 'quit' },
diff --git a/src/mainWindow.js b/src/mainWindow.js
index ea07ada..f0cd777 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -131,9 +131,9 @@ const MainWindow = new Lang.Class({
         ], this);
 
         let action = this.window.lookup_action('goto-user-location');
-        this.mapView.geoclue.bind_property('connected',
-                                           action, 'enabled',
-                                           GObject.BindingFlags.SYNC_CREATE);
+        Application.geoclue.bind_property('connected',
+                                          action, 'enabled',
+                                          GObject.BindingFlags.SYNC_CREATE);
     },
 
     _initSignals: function() {
@@ -237,13 +237,13 @@ const MainWindow = new Lang.Class({
     },
 
     _onGotoUserLocationActivate: function() {
-        if (this.mapView.geoclue.userSetLocation) {
-            Utils.once(this.mapView.geoclue,
+        if (Application.geoclue.userSetLocation) {
+            Utils.once(Application.geoclue,
                        'location-changed',
                        (function() {
                 this.mapView.gotoUserLocation(true);
             }).bind(this));
-            this.mapView.geoclue.findLocation();
+            Application.geoclue.findLocation();
         } else
             this.mapView.gotoUserLocation(true);
     },
diff --git a/src/mapView.js b/src/mapView.js
index 19a6f39..493dccb 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -39,7 +39,6 @@ const Utils = imports.utils;
 const Path = imports.path;
 const MapLocation = imports.mapLocation;
 const UserLocation = imports.userLocation;
-const Geoclue = imports.geoclue;
 const _ = imports.gettext.gettext;
 
 const MapType = {
@@ -94,11 +93,9 @@ const MapView = new Lang.Class({
         this._factory = Champlain.MapSourceFactory.dup_default();
         this.setMapType(MapType.STREET);
 
-
-        this.geoclue = new Geoclue.Geoclue();
         this._updateUserLocation();
-        this.geoclue.connect("location-changed",
-                             this._updateUserLocation.bind(this));
+        Application.geoclue.connect("location-changed",
+                                    this._updateUserLocation.bind(this));
 
         this._connectRouteSignals(Application.routeService.route);
     },
@@ -170,12 +167,14 @@ const MapView = new Lang.Class({
     },
 
     _updateUserLocation: function() {
-        if (!this.geoclue.location)
+        let location = Application.geoclue.location;
+
+        if (!location)
             return;
 
-        let place = Geocode.Place.new_with_location(this.geoclue.location.description,
+        let place = Geocode.Place.new_with_location(location.description,
                                                     Geocode.PlaceType.UNKNOWN,
-                                                    this.geoclue.location);
+                                                    location);
 
         let selected = this._userLocation && this._userLocation.getSelected();
         this._userLocation = new UserLocation.UserLocation(place, this);


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