[gnome-shell] weather: Take global location switch into account



commit 74e1058183b0d22a4caaa80710778c8f2e576e2d
Author: Florian Müllner <fmuellner gnome org>
Date:   Sun Mar 19 14:31:19 2017 +0100

    weather: Take global location switch into account
    
    The setting to globally disable location settings altogether isn't
    handled by the geoclue service itself, but by the authorization
    agent. This means that:
    
     - it doesn't apply to system components
       (which gnome-shell is now considered[0])
     - it doesn't apply once the geoclue connection
       has been authorized
    
    However users can reasonably expect that we won't use location services
    after they disabled them, so handle the setting explicitly.
    
    [0] https://cgit.freedesktop.org/geoclue/commit/?id=a4cef6c0ad08
    
    https://bugzilla.gnome.org/show_bug.cgi?id=780252

 js/misc/weather.js |   11 ++++++++++-
 1 files changed, 10 insertions(+), 1 deletions(-)
---
diff --git a/js/misc/weather.js b/js/misc/weather.js
index 04e3295..31ca192 100644
--- a/js/misc/weather.js
+++ b/js/misc/weather.js
@@ -28,6 +28,10 @@ const WeatherClient = new Lang.Class({
         this._gclueStarting = false;
         this._gclueLocationChangedId = 0;
 
+        this._locationSettings = new Gio.Settings({ schema_id: 'org.gnome.system.location' });
+        this._locationSettings.connect('changed::enabled',
+                                       Lang.bind(this, this._updateAutoLocation));
+
         this._world = GWeather.Location.get_world();
 
         let providers = GWeather.Provider.METAR |
@@ -82,7 +86,8 @@ const WeatherClient = new Lang.Class({
     },
 
     get _useAutoLocation() {
-        return this._autoLocationRequested;
+        return this._autoLocationRequested &&
+               this._locationSettings.get_boolean('enabled');
     },
 
     _loadInfo: function() {
@@ -174,6 +179,10 @@ const WeatherClient = new Lang.Class({
 
         this._autoLocationRequested = useAutoLocation;
 
+        this._updateAutoLocation();
+    },
+
+    _updateAutoLocation: function() {
         this._updateLocationMonitoring();
 
         if (this._useAutoLocation)


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