diff --git a/js/js-resources.gresource.xml b/js/js-resources.gresource.xml index 036970885..6d9d58529 100644 --- a/js/js-resources.gresource.xml +++ b/js/js-resources.gresource.xml @@ -101,6 +101,7 @@ ui/status/accessibility.js ui/status/brightness.js + ui/status/location.js ui/status/keyboard.js ui/status/network.js ui/status/power.js diff --git a/js/ui/panel.js b/js/ui/panel.js index 5ffd7b919..a54555205 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 000000000..4a4601487 --- /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 = ' \ + \ + \ + \ +'; + +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(); + } +});