location: Allow user to disable GPS
When exact accuracy (i-e GPS) is available, allow user to disable that. When users don't want application to get their precise location, they can now opt for network-based geolocation only, which can be street-level at best. https://bugzilla.gnome.org/show_bug.cgi?id=723684
This commit is contained in:
parent
59634b2cf5
commit
5d05b66902
@ -35,6 +35,14 @@ var AgentIface = '<node> \
|
|||||||
</interface> \
|
</interface> \
|
||||||
</node>';
|
</node>';
|
||||||
|
|
||||||
|
const AccuracyLevel = {
|
||||||
|
NONE: 0,
|
||||||
|
COUNTRY: 1,
|
||||||
|
CITY: 4,
|
||||||
|
STREET: 6,
|
||||||
|
EXACT: 8,
|
||||||
|
};
|
||||||
|
|
||||||
const Indicator = new Lang.Class({
|
const Indicator = new Lang.Class({
|
||||||
Name: 'LocationIndicator',
|
Name: 'LocationIndicator',
|
||||||
Extends: PanelMenu.SystemIndicator,
|
Extends: PanelMenu.SystemIndicator,
|
||||||
@ -61,6 +69,18 @@ const Indicator = new Lang.Class({
|
|||||||
this._item.status.text = _("On");
|
this._item.status.text = _("On");
|
||||||
this._onoffAction = this._item.menu.addAction(_("Turn Off"), Lang.bind(this, this._onOnOffAction));
|
this._onoffAction = this._item.menu.addAction(_("Turn Off"), Lang.bind(this, this._onOnOffAction));
|
||||||
|
|
||||||
|
this._accurateItem = new PopupMenu.PopupMenuItem(_("Accurate (GPS + Network)"), false);
|
||||||
|
this._accurateItem.connect('activate', Lang.bind(this, this._onAccurateItemActivated));
|
||||||
|
this._item.menu.addMenuItem(this._accurateItem);
|
||||||
|
|
||||||
|
this._powerSavingItem = new PopupMenu.PopupMenuItem(_("Power Saving (Network Only)"), false);
|
||||||
|
this._powerSavingItem.connect('activate', Lang.bind(this, this._onPowerSavingItemActivated));
|
||||||
|
this._item.menu.addMenuItem(this._powerSavingItem);
|
||||||
|
|
||||||
|
this._offItem = new PopupMenu.PopupMenuItem(_("Off"), false);
|
||||||
|
this._offItem.connect('activate', Lang.bind(this, this._onOffItemActivated));
|
||||||
|
this._item.menu.addMenuItem(this._offItem);
|
||||||
|
|
||||||
this.menu.addMenuItem(this._item);
|
this.menu.addMenuItem(this._item);
|
||||||
|
|
||||||
this._watchId = Gio.bus_watch_name(Gio.BusType.SYSTEM,
|
this._watchId = Gio.bus_watch_name(Gio.BusType.SYSTEM,
|
||||||
@ -150,16 +170,48 @@ const Indicator = new Lang.Class({
|
|||||||
if (this._getMaxAccuracyLevel() == 0)
|
if (this._getMaxAccuracyLevel() == 0)
|
||||||
this._settings.set_enum(MAX_ACCURACY_LEVEL, this._availableAccuracyLevel);
|
this._settings.set_enum(MAX_ACCURACY_LEVEL, this._availableAccuracyLevel);
|
||||||
else
|
else
|
||||||
this._settings.set_enum(MAX_ACCURACY_LEVEL, 0);
|
this._settings.set_enum(MAX_ACCURACY_LEVEL, AccuracyLevel.NONE);
|
||||||
|
},
|
||||||
|
|
||||||
|
_onAccurateItemActivated: function() {
|
||||||
|
this._settings.set_enum(MAX_ACCURACY_LEVEL, AccuracyLevel.EXACT);
|
||||||
|
},
|
||||||
|
|
||||||
|
_onPowerSavingItemActivated: function() {
|
||||||
|
this._settings.set_enum(MAX_ACCURACY_LEVEL, AccuracyLevel.STREET);
|
||||||
|
},
|
||||||
|
|
||||||
|
_onOffItemActivated: function() {
|
||||||
|
this._settings.set_enum(MAX_ACCURACY_LEVEL, AccuracyLevel.NONE);
|
||||||
},
|
},
|
||||||
|
|
||||||
_onMaxAccuracyLevelChanged: function() {
|
_onMaxAccuracyLevelChanged: function() {
|
||||||
if (this._getMaxAccuracyLevel() == 0) {
|
let maxAccuracyLevel = this._getMaxAccuracyLevel();
|
||||||
this._item.status.text = _("Off");
|
if (this._availableAccuracyLevel < AccuracyLevel.EXACT) {
|
||||||
this._onoffAction.label.text = "Turn On";
|
if (maxAccuracyLevel == 0) {
|
||||||
|
this._item.status.text = _("Off");
|
||||||
|
this._onoffAction.label.text = "Turn On";
|
||||||
|
} else {
|
||||||
|
this._item.status.text = _("On");
|
||||||
|
this._onoffAction.label.text = "Turn Off";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this._item.status.text = _("On");
|
if (maxAccuracyLevel == 0) {
|
||||||
this._onoffAction.label.text = "Turn Off";
|
this._item.status.text = _("Off");
|
||||||
|
this._offItem.setOrnament(PopupMenu.Ornament.DOT);
|
||||||
|
this._accurateItem.setOrnament(PopupMenu.Ornament.NONE);
|
||||||
|
this._powerSavingItem.setOrnament(PopupMenu.Ornament.NONE);
|
||||||
|
} else if (maxAccuracyLevel < AccuracyLevel.EXACT) {
|
||||||
|
this._item.status.text = _("Power Saving");
|
||||||
|
this._powerSavingItem.setOrnament(PopupMenu.Ornament.DOT);
|
||||||
|
this._accurateItem.setOrnament(PopupMenu.Ornament.NONE);
|
||||||
|
this._offItem.setOrnament(PopupMenu.Ornament.NONE);
|
||||||
|
} else {
|
||||||
|
this._item.status.text = _("Accurate");
|
||||||
|
this._accurateItem.setOrnament(PopupMenu.Ornament.DOT);
|
||||||
|
this._offItem.setOrnament(PopupMenu.Ornament.NONE);
|
||||||
|
this._powerSavingItem.setOrnament(PopupMenu.Ornament.NONE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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
|
||||||
@ -180,6 +232,22 @@ const Indicator = new Lang.Class({
|
|||||||
_updateMenu: function() {
|
_updateMenu: function() {
|
||||||
this._availableAccuracyLevel = this._proxy.AvailableAccuracyLevel;
|
this._availableAccuracyLevel = this._proxy.AvailableAccuracyLevel;
|
||||||
this.menu.actor.visible = (this._availableAccuracyLevel != 0);
|
this.menu.actor.visible = (this._availableAccuracyLevel != 0);
|
||||||
|
if (this._availableAccuracyLevel == 0)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (this._availableAccuracyLevel < AccuracyLevel.EXACT) {
|
||||||
|
this._onoffAction.actor.show();
|
||||||
|
this._accurateItem.actor.hide();
|
||||||
|
this._powerSavingItem.actor.hide();
|
||||||
|
this._offItem.actor.hide();
|
||||||
|
} else {
|
||||||
|
this._onoffAction.actor.hide();
|
||||||
|
this._accurateItem.actor.show();
|
||||||
|
this._powerSavingItem.actor.show();
|
||||||
|
this._offItem.actor.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
this._onMaxAccuracyLevelChanged();
|
||||||
},
|
},
|
||||||
|
|
||||||
_onGeocluePropsChanged: function(proxy, properties) {
|
_onGeocluePropsChanged: function(proxy, properties) {
|
||||||
|
Loading…
Reference in New Issue
Block a user