screensaver: factor out a ScreenSaverProxy helper class
This class will be shared between StatusMenu and the upcoming AutomountManager classes. https://bugzilla.gnome.org/show_bug.cgi?id=653520
This commit is contained in:
parent
c632074ba7
commit
6004e3d2e1
@ -10,6 +10,7 @@ nobase_dist_js_DATA = \
|
|||||||
misc/history.js \
|
misc/history.js \
|
||||||
misc/modemManager.js \
|
misc/modemManager.js \
|
||||||
misc/params.js \
|
misc/params.js \
|
||||||
|
misc/screenSaver.js \
|
||||||
misc/util.js \
|
misc/util.js \
|
||||||
perf/core.js \
|
perf/core.js \
|
||||||
ui/altTab.js \
|
ui/altTab.js \
|
||||||
|
59
js/misc/screenSaver.js
Normal file
59
js/misc/screenSaver.js
Normal file
@ -0,0 +1,59 @@
|
|||||||
|
/* -*- mode: js2; js2-basic-offset: 4; indent-tabs-mode: nil -*- */
|
||||||
|
|
||||||
|
const DBus = imports.dbus;
|
||||||
|
const Lang = imports.lang;
|
||||||
|
const Signals = imports.signals;
|
||||||
|
|
||||||
|
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));
|
||||||
|
|
||||||
|
this.connect('ActiveChanged',
|
||||||
|
Lang.bind(this, this._onActiveChanged));
|
||||||
|
},
|
||||||
|
|
||||||
|
_onSSAppeared: function(owner) {
|
||||||
|
this.GetActiveRemote(Lang.bind(this, function(isActive) {
|
||||||
|
this._screenSaverActive = isActive;
|
||||||
|
}))
|
||||||
|
},
|
||||||
|
|
||||||
|
_onSSVanished: function(oldOwner) {
|
||||||
|
this._screenSaverActive = false;
|
||||||
|
},
|
||||||
|
|
||||||
|
_onActiveChanged: function(object, isActive) {
|
||||||
|
this._screenSaverActive = isActive;
|
||||||
|
this.emit('active-changed', this._screenSaverActive);
|
||||||
|
},
|
||||||
|
|
||||||
|
getActive: function() {
|
||||||
|
return this._screenSaverActive;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
DBus.proxifyPrototype(ScreenSaverProxy.prototype, ScreenSaverIface);
|
||||||
|
Signals.addSignalMethods(ScreenSaverProxy.prototype);
|
@ -14,24 +14,14 @@ const GnomeSession = imports.misc.gnomeSession;
|
|||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
const PanelMenu = imports.ui.panelMenu;
|
const PanelMenu = imports.ui.panelMenu;
|
||||||
const PopupMenu = imports.ui.popupMenu;
|
const PopupMenu = imports.ui.popupMenu;
|
||||||
|
const ScreenSaver = imports.misc.screenSaver;
|
||||||
const Util = imports.misc.util;
|
const Util = imports.misc.util;
|
||||||
|
|
||||||
const BUS_NAME = 'org.gnome.ScreenSaver';
|
|
||||||
const OBJECT_PATH = '/org/gnome/ScreenSaver';
|
|
||||||
|
|
||||||
const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
|
const LOCKDOWN_SCHEMA = 'org.gnome.desktop.lockdown';
|
||||||
const DISABLE_USER_SWITCH_KEY = 'disable-user-switching';
|
const DISABLE_USER_SWITCH_KEY = 'disable-user-switching';
|
||||||
const DISABLE_LOCK_SCREEN_KEY = 'disable-lock-screen';
|
const DISABLE_LOCK_SCREEN_KEY = 'disable-lock-screen';
|
||||||
const DISABLE_LOG_OUT_KEY = 'disable-log-out';
|
const DISABLE_LOG_OUT_KEY = 'disable-log-out';
|
||||||
|
|
||||||
const ScreenSaverInterface = {
|
|
||||||
name: BUS_NAME,
|
|
||||||
methods: [ { name: 'Lock', inSignature: '' },
|
|
||||||
{ name: 'SetActive', inSignature: 'b' }]
|
|
||||||
};
|
|
||||||
|
|
||||||
let ScreenSaverProxy = DBus.makeProxyClass(ScreenSaverInterface);
|
|
||||||
|
|
||||||
// Adapted from gdm/gui/user-switch-applet/applet.c
|
// Adapted from gdm/gui/user-switch-applet/applet.c
|
||||||
//
|
//
|
||||||
// Copyright (C) 2004-2005 James M. Cape <jcape@ignore-your.tv>.
|
// Copyright (C) 2004-2005 James M. Cape <jcape@ignore-your.tv>.
|
||||||
@ -63,7 +53,7 @@ StatusMenuButton.prototype = {
|
|||||||
this._account_mgr = Tp.AccountManager.dup()
|
this._account_mgr = Tp.AccountManager.dup()
|
||||||
|
|
||||||
this._upClient = new UPowerGlib.Client();
|
this._upClient = new UPowerGlib.Client();
|
||||||
this._screenSaverProxy = new ScreenSaverProxy(DBus.session, BUS_NAME, OBJECT_PATH);
|
this._screenSaverProxy = new ScreenSaver.ScreenSaverProxy();
|
||||||
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
this.actor.connect('destroy', Lang.bind(this, this._onDestroy));
|
||||||
|
|
||||||
this._iconBox = new St.Bin();
|
this._iconBox = new St.Bin();
|
||||||
|
Loading…
Reference in New Issue
Block a user