2012-05-16 18:26:44 -04:00
|
|
|
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
|
|
|
|
|
|
|
|
const Lang = imports.lang;
|
2012-09-01 08:42:53 -04:00
|
|
|
const Signals = imports.signals;
|
2012-05-16 18:26:44 -04:00
|
|
|
|
2012-05-17 09:50:51 -04:00
|
|
|
const Main = imports.ui.main;
|
2012-05-16 18:26:44 -04:00
|
|
|
const Params = imports.misc.params;
|
|
|
|
|
2012-09-03 21:26:37 -04:00
|
|
|
const DEFAULT_MODE = 'restrictive';
|
2012-05-16 18:26:44 -04:00
|
|
|
|
|
|
|
const _modes = {
|
2012-09-03 21:26:37 -04:00
|
|
|
'restrictive': {
|
2012-09-03 21:23:22 -04:00
|
|
|
hasOverview: false,
|
|
|
|
showCalendarEvents: false,
|
|
|
|
allowSettings: false,
|
|
|
|
allowExtensions: false,
|
2012-09-03 21:26:37 -04:00
|
|
|
allowKeybindingsWhenModal: false,
|
2012-09-03 21:23:22 -04:00
|
|
|
hasRunDialog: false,
|
|
|
|
hasWorkspaces: false,
|
|
|
|
hasWindows: false,
|
2012-09-03 21:26:37 -04:00
|
|
|
isLocked: false,
|
2012-09-04 13:28:19 -04:00
|
|
|
isGreeter: false,
|
|
|
|
unlockDialog: null,
|
2012-09-03 21:23:22 -04:00
|
|
|
components: [],
|
2012-09-03 21:26:37 -04:00
|
|
|
panel: {
|
|
|
|
left: [],
|
|
|
|
center: [],
|
|
|
|
right: []
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
'gdm': {
|
|
|
|
allowKeybindingsWhenModal: true,
|
2012-09-04 13:28:19 -04:00
|
|
|
isGreeter: true,
|
|
|
|
unlockDialog: imports.gdm.loginDialog.LoginDialog,
|
2012-09-05 06:50:16 -04:00
|
|
|
components: ['polkitAgent'],
|
2012-09-03 21:23:22 -04:00
|
|
|
panel: {
|
|
|
|
left: [],
|
|
|
|
center: ['dateMenu'],
|
|
|
|
right: ['a11y', 'display', 'keyboard',
|
|
|
|
'volume', 'battery', 'powerMenu']
|
|
|
|
}
|
|
|
|
},
|
2012-05-16 18:26:44 -04:00
|
|
|
|
2012-09-01 08:42:53 -04:00
|
|
|
'lock-screen': {
|
2012-09-01 17:44:46 -04:00
|
|
|
isLocked: true,
|
2012-09-04 13:28:19 -04:00
|
|
|
isGreeter: undefined,
|
|
|
|
unlockDialog: undefined,
|
2012-09-02 21:23:50 -04:00
|
|
|
components: ['networkAgent', 'polkitAgent', 'telepathyClient'],
|
2012-09-01 08:42:53 -04:00
|
|
|
panel: {
|
|
|
|
left: ['userMenu'],
|
|
|
|
center: [],
|
|
|
|
right: ['lockScreen']
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2012-09-03 21:23:22 -04:00
|
|
|
'initial-setup': {
|
|
|
|
components: ['keyring'],
|
|
|
|
panel: {
|
|
|
|
left: [],
|
|
|
|
center: ['dateMenu'],
|
|
|
|
right: ['a11y', 'keyboard', 'volume']
|
|
|
|
}
|
|
|
|
},
|
2012-05-23 23:37:09 -04:00
|
|
|
|
2012-09-03 21:23:22 -04:00
|
|
|
'user': {
|
|
|
|
hasOverview: true,
|
|
|
|
showCalendarEvents: true,
|
|
|
|
allowSettings: true,
|
|
|
|
allowExtensions: true,
|
|
|
|
hasRunDialog: true,
|
|
|
|
hasWorkspaces: true,
|
|
|
|
hasWindows: true,
|
2012-09-04 13:28:19 -04:00
|
|
|
unlockDialog: imports.ui.unlockDialog.UnlockDialog,
|
|
|
|
isLocked: false,
|
2012-09-03 21:23:22 -04:00
|
|
|
components: ['networkAgent', 'polkitAgent', 'telepathyClient',
|
|
|
|
'keyring', 'recorder', 'autorunManager', 'automountManager'],
|
|
|
|
panel: {
|
|
|
|
left: ['activities', 'appMenu'],
|
|
|
|
center: ['dateMenu'],
|
|
|
|
right: ['a11y', 'keyboard', 'volume', 'bluetooth',
|
|
|
|
'network', 'battery', 'userMenu']
|
|
|
|
}
|
|
|
|
}
|
2012-05-16 18:26:44 -04:00
|
|
|
};
|
|
|
|
|
2012-05-17 21:52:57 -04:00
|
|
|
function listModes() {
|
|
|
|
let modes = Object.getOwnPropertyNames(_modes);
|
|
|
|
for (let i = 0; i < modes.length; i++)
|
|
|
|
print(modes[i]);
|
|
|
|
}
|
|
|
|
|
2012-05-16 18:26:44 -04:00
|
|
|
const SessionMode = new Lang.Class({
|
|
|
|
Name: 'SessionMode',
|
|
|
|
|
|
|
|
_init: function() {
|
2012-09-01 08:42:53 -04:00
|
|
|
global.connect('notify::session-mode', Lang.bind(this, this._sync));
|
|
|
|
this._modeStack = [global.session_mode];
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
pushMode: function(mode) {
|
|
|
|
this._modeStack.push(mode);
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
popMode: function(mode) {
|
|
|
|
if (this.currentMode != mode || this._modeStack.length === 1)
|
|
|
|
throw new Error("Invalid SessionMode.popMode");
|
|
|
|
this._modeStack.pop();
|
|
|
|
this._sync();
|
|
|
|
},
|
|
|
|
|
|
|
|
get currentMode() {
|
|
|
|
return this._modeStack[this._modeStack.length - 1];
|
|
|
|
},
|
2012-05-16 18:26:44 -04:00
|
|
|
|
2012-09-01 08:42:53 -04:00
|
|
|
_sync: function() {
|
|
|
|
let params = _modes[this.currentMode];
|
2012-05-16 18:26:44 -04:00
|
|
|
params = Params.parse(params, _modes[DEFAULT_MODE]);
|
2012-05-17 09:50:51 -04:00
|
|
|
|
2012-09-04 13:28:19 -04:00
|
|
|
// A simplified version of Lang.copyProperties, handles
|
|
|
|
// undefined as a special case for "no change / inherit from previous mode"
|
|
|
|
for (let prop in params) {
|
|
|
|
if (params[prop] !== undefined)
|
|
|
|
this[prop] = params[prop];
|
|
|
|
}
|
2012-05-17 09:50:51 -04:00
|
|
|
|
2012-09-01 08:42:53 -04:00
|
|
|
this.emit('updated');
|
2012-09-04 13:28:19 -04:00
|
|
|
}
|
2012-05-16 18:26:44 -04:00
|
|
|
});
|
2012-09-01 08:42:53 -04:00
|
|
|
Signals.addSignalMethods(SessionMode.prototype);
|