system: Use iio-sensor-proxy to detect accelerometer
Instead of using gnome-settings-daemon's D-Bus interface's presence. iio-sensor-proxy now offers a D-Bus interface, which will exported "HasAccelerometer = true" when an accelerometer is present. https://bugzilla.gnome.org/show_bug.cgi?id=749671
This commit is contained in:
parent
50d5030949
commit
2e77f6b34b
@ -24,6 +24,17 @@ const DISABLE_LOG_OUT_KEY = 'disable-log-out';
|
||||
const DISABLE_RESTART_KEY = 'disable-restart-buttons';
|
||||
const ALWAYS_SHOW_LOG_OUT_KEY = 'always-show-log-out';
|
||||
|
||||
const SENSOR_BUS_NAME = 'net.hadess.SensorProxy';
|
||||
const SENSOR_OBJECT_PATH = '/net/hadess/SensorProxy';
|
||||
|
||||
const SensorProxyInterface = '<node> \
|
||||
<interface name="net.hadess.SensorProxy"> \
|
||||
<property name="HasAccelerometer" type="b" access="read"/> \
|
||||
</interface> \
|
||||
</node>';
|
||||
|
||||
const SensorProxy = Gio.DBusProxy.makeProxyWrapper(SensorProxyInterface);
|
||||
|
||||
const AltSwitcher = new Lang.Class({
|
||||
Name: 'AltSwitcher',
|
||||
|
||||
@ -144,23 +155,32 @@ const Indicator = new Lang.Class({
|
||||
|
||||
this._orientationSettings.connect('changed::orientation-lock',
|
||||
Lang.bind(this, this._updateOrientationLock));
|
||||
this._orientationExists = false;
|
||||
Gio.DBus.session.watch_name('org.gnome.SettingsDaemon.Orientation',
|
||||
Gio.BusNameWatcherFlags.NONE,
|
||||
Lang.bind(this, function() {
|
||||
this._orientationExists = true;
|
||||
this._updateOrientationLock();
|
||||
}),
|
||||
Lang.bind(this, function() {
|
||||
this._orientationExists = false;
|
||||
this._updateOrientationLock();
|
||||
}));
|
||||
Gio.DBus.system.watch_name(SENSOR_BUS_NAME,
|
||||
Gio.BusNameWatcherFlags.NONE,
|
||||
Lang.bind(this, this._sensorProxyAppeared),
|
||||
Lang.bind(this, function() {
|
||||
this._sensorProxy = null;
|
||||
this._updateOrientationLock();
|
||||
}));
|
||||
this._updateOrientationLock();
|
||||
|
||||
Main.sessionMode.connect('updated', Lang.bind(this, this._sessionUpdated));
|
||||
this._sessionUpdated();
|
||||
},
|
||||
|
||||
_sensorProxyAppeared: function() {
|
||||
this._sensorProxy = new SensorProxy(Gio.DBus.system, SENSOR_BUS_NAME, SENSOR_OBJECT_PATH,
|
||||
Lang.bind(this, function(proxy, error) {
|
||||
if (error) {
|
||||
log(error.message);
|
||||
return;
|
||||
}
|
||||
this._sensorProxy.connect('g-properties-changed',
|
||||
Lang.bind(this, this._updateOrientationLock));
|
||||
this._updateOrientationLock();
|
||||
}));
|
||||
},
|
||||
|
||||
_updateActionsVisibility: function() {
|
||||
let visible = (this._settingsAction.visible ||
|
||||
this._orientationLockAction.visible ||
|
||||
@ -237,7 +257,10 @@ const Indicator = new Lang.Class({
|
||||
},
|
||||
|
||||
_updateOrientationLock: function() {
|
||||
this._orientationLockAction.visible = this._orientationExists;
|
||||
if (this._sensorProxy)
|
||||
this._orientationLockAction.visible = this._sensorProxy.HasAccelerometer;
|
||||
else
|
||||
this._orientationLockAction.visible = false;
|
||||
|
||||
let locked = this._orientationSettings.get_boolean('orientation-lock');
|
||||
let icon = this._orientationLockAction.child;
|
||||
|
Loading…
Reference in New Issue
Block a user