Add indicator for location service being used
If an application is accessing location through geoclue, show an indicator in the panel for that so that user knows. https://bugzilla.gnome.org/show_bug.cgi?id=709372
This commit is contained in:
parent
887a21afb9
commit
d163b92e0b
@ -101,6 +101,7 @@
|
||||
|
||||
<file>ui/status/accessibility.js</file>
|
||||
<file>ui/status/brightness.js</file>
|
||||
<file>ui/status/location.js</file>
|
||||
<file>ui/status/keyboard.js</file>
|
||||
<file>ui/status/network.js</file>
|
||||
<file>ui/status/power.js</file>
|
||||
|
@ -825,8 +825,10 @@ const AggregateMenu = new Lang.Class({
|
||||
this._brightness = new imports.ui.status.brightness.Indicator();
|
||||
this._system = new imports.ui.status.system.Indicator();
|
||||
this._screencast = new imports.ui.status.screencast.Indicator();
|
||||
this._location = new imports.ui.status.location.Indicator();
|
||||
|
||||
this._indicators.add_child(this._screencast.indicators);
|
||||
this._indicators.add_child(this._location.indicators);
|
||||
this._indicators.add_child(this._network.indicators);
|
||||
if (this._bluetooth) {
|
||||
this._indicators.add_child(this._bluetooth.indicators);
|
||||
|
58
js/ui/status/location.js
Normal file
58
js/ui/status/location.js
Normal file
@ -0,0 +1,58 @@
|
||||
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
||||
|
||||
const Gio = imports.gi.Gio;
|
||||
const Lang = imports.lang;
|
||||
|
||||
const PanelMenu = imports.ui.panelMenu;
|
||||
|
||||
var GeoclueIface = '<node> \
|
||||
<interface name="org.freedesktop.GeoClue2.Manager"> \
|
||||
<property name="InUse" type="b" access="read"/> \
|
||||
</interface> \
|
||||
</node>';
|
||||
|
||||
const GeoclueManager = Gio.DBusProxy.makeProxyWrapper(GeoclueIface);
|
||||
|
||||
const Indicator = new Lang.Class({
|
||||
Name: 'LocationIndicator',
|
||||
Extends: PanelMenu.SystemIndicator,
|
||||
|
||||
_init: function() {
|
||||
this.parent();
|
||||
|
||||
this._indicator = this._addIndicator();
|
||||
this._indicator.icon_name = 'find-location-symbolic';
|
||||
this._sync();
|
||||
|
||||
this._watchId = Gio.bus_watch_name(Gio.BusType.SYSTEM,
|
||||
'org.freedesktop.GeoClue2',
|
||||
0,
|
||||
Lang.bind(this, this._onGeoclueAppeared),
|
||||
Lang.bind(this, this._onGeoclueVanished));
|
||||
},
|
||||
|
||||
_sync: function() {
|
||||
if (this._proxy == null) {
|
||||
this._indicator.visible = false;
|
||||
return;
|
||||
}
|
||||
|
||||
this._indicator.visible = this._proxy.InUse;
|
||||
},
|
||||
|
||||
_onGeoclueAppeared: function() {
|
||||
// FIXME: This should be done async
|
||||
this._proxy = new GeoclueManager(Gio.DBus.system,
|
||||
'org.freedesktop.GeoClue2',
|
||||
'/org/freedesktop/GeoClue2/Manager');
|
||||
this._proxy.connect('g-properties-changed', Lang.bind(this, this._sync));
|
||||
|
||||
this._sync();
|
||||
},
|
||||
|
||||
_onGeoclueVanished: function() {
|
||||
this._proxy = null;
|
||||
|
||||
this._sync();
|
||||
}
|
||||
});
|
Loading…
Reference in New Issue
Block a user