[gnome-shell] Add indicator for location service being used
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] Add indicator for location service being used
- Date: Tue, 28 Jan 2014 18:39:11 +0000 (UTC)
commit d163b92e0bd8662aa42afc518726c5ce93e5a61e
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Tue Jan 28 17:41:26 2014 +0000
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
js/js-resources.gresource.xml | 1 +
js/ui/panel.js | 2 +
js/ui/status/location.js | 58 +++++++++++++++++++++++++++++++++++++++++
3 files changed, 61 insertions(+), 0 deletions(-)
---
diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml
index 0369708..6d9d585 100644
--- a/js/js-resources.gresource.xml
+++ b/js/js-resources.gresource.xml
@@ -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>
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 5ffd7b9..a545552 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -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);
diff --git a/js/ui/status/location.js b/js/ui/status/location.js
new file mode 100644
index 0000000..4a46014
--- /dev/null
+++ b/js/ui/status/location.js
@@ -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();
+ }
+});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]