2011-07-12 15:42:33 +00:00
|
|
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
|
|
|
|
|
|
|
const DBus = imports.dbus;
|
|
|
|
const Lang = imports.lang;
|
|
|
|
|
|
|
|
const ScreenSaverIface = {
|
|
|
|
name: 'org.gnome.ScreenSaver',
|
|
|
|
methods: [{ name: 'GetActive',
|
|
|
|
inSignature: '',
|
|
|
|
outSignature: 'b' },
|
|
|
|
{ name: 'Lock',
|
|
|
|
inSignature: '' },
|
|
|
|
{ name: 'SetActive',
|
|
|
|
inSignature: 'b' }],
|
|
|
|
signals: [{ name: 'ActiveChanged',
|
|
|
|
inSignature: 'b' }]
|
|
|
|
};
|
|
|
|
|
|
|
|
function ScreenSaverProxy() {
|
|
|
|
this._init();
|
|
|
|
}
|
|
|
|
|
|
|
|
ScreenSaverProxy.prototype = {
|
|
|
|
_init: function() {
|
|
|
|
DBus.session.proxifyObject(this,
|
|
|
|
'org.gnome.ScreenSaver',
|
|
|
|
'/org/gnome/ScreenSaver');
|
|
|
|
|
|
|
|
DBus.session.watch_name('org.gnome.ScreenSaver',
|
|
|
|
false, // do not launch a name-owner if none exists
|
|
|
|
Lang.bind(this, this._onSSAppeared),
|
|
|
|
Lang.bind(this, this._onSSVanished));
|
|
|
|
|
2011-07-13 19:07:39 +00:00
|
|
|
this.screenSaverActive = false;
|
2011-07-12 15:42:33 +00:00
|
|
|
this.connect('ActiveChanged',
|
|
|
|
Lang.bind(this, this._onActiveChanged));
|
|
|
|
},
|
|
|
|
|
|
|
|
_onSSAppeared: function(owner) {
|
|
|
|
this.GetActiveRemote(Lang.bind(this, function(isActive) {
|
2011-07-13 19:07:39 +00:00
|
|
|
this.screenSaverActive = isActive;
|
2011-07-12 15:42:33 +00:00
|
|
|
}))
|
|
|
|
},
|
|
|
|
|
|
|
|
_onSSVanished: function(oldOwner) {
|
2011-07-13 19:07:39 +00:00
|
|
|
this.screenSaverActive = false;
|
2011-07-12 15:42:33 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
_onActiveChanged: function(object, isActive) {
|
2011-07-13 19:07:39 +00:00
|
|
|
this.screenSaverActive = isActive;
|
2011-07-12 15:42:33 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
DBus.proxifyPrototype(ScreenSaverProxy.prototype, ScreenSaverIface);
|