location,schema: Keep max accuracy in gsetting
Instead of relying on geoclue to store this user configuration, lets keep it in gsettings. Geoclue is a system service and therefore is not the appropriate entity to keep this info. https://bugzilla.gnome.org/show_bug.cgi?id=723684
This commit is contained in:
parent
38f241479c
commit
d6146197dd
@ -65,6 +65,7 @@
|
|||||||
<child name="calendar" schema="org.gnome.shell.calendar"/>
|
<child name="calendar" schema="org.gnome.shell.calendar"/>
|
||||||
<child name="keybindings" schema="org.gnome.shell.keybindings"/>
|
<child name="keybindings" schema="org.gnome.shell.keybindings"/>
|
||||||
<child name="keyboard" schema="org.gnome.shell.keyboard"/>
|
<child name="keyboard" schema="org.gnome.shell.keyboard"/>
|
||||||
|
<child name="location" schema="org.gnome.shell.location"/>
|
||||||
</schema>
|
</schema>
|
||||||
|
|
||||||
<schema id="org.gnome.shell.calendar" path="/org/gnome/shell/calendar/"
|
<schema id="org.gnome.shell.calendar" path="/org/gnome/shell/calendar/"
|
||||||
@ -134,6 +135,32 @@
|
|||||||
</key>
|
</key>
|
||||||
</schema>
|
</schema>
|
||||||
|
|
||||||
|
<enum id="org.gnome.shell.geoclue.AccuracyLevel">
|
||||||
|
<value value="0" nick="off"/>
|
||||||
|
<value value="1" nick="country"/>
|
||||||
|
<value value="4" nick="city"/>
|
||||||
|
<value value="5" nick="neighborhood"/>
|
||||||
|
<value value="6" nick="street"/>
|
||||||
|
<value value="8" nick="exact"/>
|
||||||
|
</enum>
|
||||||
|
<schema id="org.gnome.shell.location"
|
||||||
|
path="/org/gnome/shell/location/"
|
||||||
|
gettext-domain="@GETTEXT_PACKAGE@">
|
||||||
|
<key name="max-accuracy-level" enum="org.gnome.shell.geoclue.AccuracyLevel">
|
||||||
|
<default>'exact'</default>
|
||||||
|
<_summary>The maximum accuracy level of location.</_summary>
|
||||||
|
<_description>
|
||||||
|
Configures the maximum level of location accuracy applications are
|
||||||
|
allowed to see. Valid options are 'off' (disable location tracking),
|
||||||
|
'country', 'city', 'neighborhood', 'street', and 'exact' (typically
|
||||||
|
requires GPS receiver). Please keep in mind that this only controls
|
||||||
|
what Geoclue will allow applications to see and they can find user's
|
||||||
|
location on their own using network resources (albeit with street-level
|
||||||
|
accuracy at best).
|
||||||
|
</_description>
|
||||||
|
</key>
|
||||||
|
</schema>
|
||||||
|
|
||||||
<schema id="org.gnome.shell.app-switcher"
|
<schema id="org.gnome.shell.app-switcher"
|
||||||
path="/org/gnome/shell/app-switcher/"
|
path="/org/gnome/shell/app-switcher/"
|
||||||
gettext-domain="@GETTEXT_PACKAGE@">
|
gettext-domain="@GETTEXT_PACKAGE@">
|
||||||
|
@ -8,6 +8,9 @@ const Shell = imports.gi.Shell;
|
|||||||
const PanelMenu = imports.ui.panelMenu;
|
const PanelMenu = imports.ui.panelMenu;
|
||||||
const PopupMenu = imports.ui.popupMenu;
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
|
|
||||||
|
const LOCATION_SCHEMA = 'org.gnome.shell.location';
|
||||||
|
const MAX_ACCURACY_LEVEL = 'max-accuracy-level';
|
||||||
|
|
||||||
var GeoclueIface = '<node> \
|
var GeoclueIface = '<node> \
|
||||||
<interface name="org.freedesktop.GeoClue2.Manager"> \
|
<interface name="org.freedesktop.GeoClue2.Manager"> \
|
||||||
<property name="InUse" type="b" access="read"/> \
|
<property name="InUse" type="b" access="read"/> \
|
||||||
@ -39,6 +42,10 @@ const Indicator = new Lang.Class({
|
|||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent();
|
this.parent();
|
||||||
|
|
||||||
|
this._settings = new Gio.Settings({ schema: LOCATION_SCHEMA });
|
||||||
|
this._settings.connect('changed::' + MAX_ACCURACY_LEVEL,
|
||||||
|
Lang.bind(this, this._onMaxAccuracyLevelChanged));
|
||||||
|
|
||||||
this._indicator = this._addIndicator();
|
this._indicator = this._addIndicator();
|
||||||
this._indicator.icon_name = 'find-location-symbolic';
|
this._indicator.icon_name = 'find-location-symbolic';
|
||||||
|
|
||||||
@ -61,20 +68,12 @@ const Indicator = new Lang.Class({
|
|||||||
0,
|
0,
|
||||||
Lang.bind(this, this._connectToGeoclue),
|
Lang.bind(this, this._connectToGeoclue),
|
||||||
Lang.bind(this, this._onGeoclueVanished));
|
Lang.bind(this, this._onGeoclueVanished));
|
||||||
|
this._onMaxAccuracyLevelChanged();
|
||||||
this._connectToGeoclue();
|
this._connectToGeoclue();
|
||||||
},
|
},
|
||||||
|
|
||||||
get MaxAccuracyLevel() {
|
get MaxAccuracyLevel() {
|
||||||
return this._maxAccuracyLevel;
|
return this._getMaxAccuracyLevel();
|
||||||
},
|
|
||||||
|
|
||||||
set MaxAccuracyLevel(value) {
|
|
||||||
if (this._userSetAccuracy)
|
|
||||||
// If user set the max accuracy level, don't let geoclue override
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._setMaxAccuracyLevel(value, false);
|
|
||||||
},
|
},
|
||||||
|
|
||||||
// We (and geoclue) have currently no way to reliably identifying apps so
|
// We (and geoclue) have currently no way to reliably identifying apps so
|
||||||
@ -87,7 +86,7 @@ const Indicator = new Lang.Class({
|
|||||||
return [false, 0];
|
return [false, 0];
|
||||||
}
|
}
|
||||||
|
|
||||||
var allowedAccuracyLevel = clamp(reqAccuracyLevel, 0, this._maxAccuracyLevel);
|
let allowedAccuracyLevel = clamp(reqAccuracyLevel, 0, this._getMaxAccuracyLevel());
|
||||||
return [true, allowedAccuracyLevel];
|
return [true, allowedAccuracyLevel];
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -115,7 +114,6 @@ const Indicator = new Lang.Class({
|
|||||||
_onProxyReady: function(proxy, error) {
|
_onProxyReady: function(proxy, error) {
|
||||||
if (error != null) {
|
if (error != null) {
|
||||||
log(error.message);
|
log(error.message);
|
||||||
this._userSetAccuracy = false;
|
|
||||||
this._connecting = false;
|
this._connecting = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -144,16 +142,14 @@ const Indicator = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onOnOffAction: function() {
|
_onOnOffAction: function() {
|
||||||
if (this._maxAccuracyLevel == 0)
|
if (this._getMaxAccuracyLevel() == 0)
|
||||||
this._setMaxAccuracyLevel(this._availableAccuracyLevel, true);
|
this._settings.set_enum(MAX_ACCURACY_LEVEL, this._availableAccuracyLevel);
|
||||||
else
|
else
|
||||||
this._setMaxAccuracyLevel(0, true);
|
this._settings.set_enum(MAX_ACCURACY_LEVEL, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
_setMaxAccuracyLevel: function(maxAccuracyLevel, userSet) {
|
_onMaxAccuracyLevelChanged: function() {
|
||||||
this._maxAccuracyLevel = maxAccuracyLevel;
|
if (this._getMaxAccuracyLevel() == 0) {
|
||||||
|
|
||||||
if (this._maxAccuracyLevel == 0) {
|
|
||||||
this._item.status.text = _("Off");
|
this._item.status.text = _("Off");
|
||||||
this._onoffAction.label.text = "Turn On";
|
this._onoffAction.label.text = "Turn On";
|
||||||
} else {
|
} else {
|
||||||
@ -161,31 +157,23 @@ const Indicator = new Lang.Class({
|
|||||||
this._onoffAction.label.text = "Turn Off";
|
this._onoffAction.label.text = "Turn Off";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!userSet)
|
|
||||||
return;
|
|
||||||
|
|
||||||
this._userSetAccuracy = true;
|
|
||||||
// Gotta ensure geoclue is up and we are registered as agent to it
|
// Gotta ensure geoclue is up and we are registered as agent to it
|
||||||
// before we emit the notify for this property change.
|
// before we emit the notify for this property change.
|
||||||
if (!this._connectToGeoclue())
|
if (!this._connectToGeoclue())
|
||||||
this._notifyMaxAccuracyLevel();
|
this._notifyMaxAccuracyLevel();
|
||||||
},
|
},
|
||||||
|
|
||||||
_notifyMaxAccuracyLevel: function() {
|
_getMaxAccuracyLevel: function() {
|
||||||
if (!this._userSetAccuracy)
|
return this._settings.get_enum(MAX_ACCURACY_LEVEL);
|
||||||
return;
|
},
|
||||||
|
|
||||||
var variant = new GLib.Variant('u', this._maxAccuracyLevel);
|
_notifyMaxAccuracyLevel: function() {
|
||||||
|
let variant = new GLib.Variant('u', this._getMaxAccuracyLevel());
|
||||||
this._agent.emit_property_changed('MaxAccuracyLevel', variant);
|
this._agent.emit_property_changed('MaxAccuracyLevel', variant);
|
||||||
this._userSetAccuracy = false;
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_updateMenuVisibility: function() {
|
_updateMenuVisibility: function() {
|
||||||
this._availableAccuracyLevel = this._proxy.AvailableAccuracyLevel;
|
this._availableAccuracyLevel = this._proxy.AvailableAccuracyLevel;
|
||||||
if (!this._maxAccuracyLevelInitialized) {
|
|
||||||
this._maxAccuracyLevel = this._availableAccuracyLevel;
|
|
||||||
this._maxAccuracyLevelInitialized = true;
|
|
||||||
}
|
|
||||||
this.menu.actor.visible = (this._availableAccuracyLevel != 0);
|
this.menu.actor.visible = (this._availableAccuracyLevel != 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user