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;
|
|
|
|
|
|
|
|
const DEFAULT_MODE = 'user';
|
|
|
|
|
|
|
|
const _modes = {
|
2012-05-16 18:59:02 -04:00
|
|
|
'gdm': { hasOverview: false,
|
2012-05-17 18:32:04 -04:00
|
|
|
showCalendarEvents: false,
|
2012-05-16 19:43:59 -04:00
|
|
|
allowSettings: false,
|
2012-05-16 20:08:56 -04:00
|
|
|
allowExtensions: false,
|
2012-05-17 09:55:35 -04:00
|
|
|
allowKeybindingsWhenModal: true,
|
2012-05-17 07:41:02 -04:00
|
|
|
hasRunDialog: false,
|
2012-05-17 09:32:32 -04:00
|
|
|
hasWorkspaces: false,
|
2012-09-01 08:42:53 -04:00
|
|
|
hasWindows: false,
|
2012-05-17 09:50:51 -04:00
|
|
|
createSession: Main.createGDMSession,
|
2012-05-26 11:04:25 -04:00
|
|
|
createUnlockDialog: Main.createGDMLoginDialog,
|
2012-08-28 17:10:44 -04:00
|
|
|
panel: {
|
|
|
|
left: [],
|
|
|
|
center: ['dateMenu'],
|
|
|
|
right: ['a11y', 'display', 'keyboard',
|
2012-09-01 08:42:53 -04:00
|
|
|
'volume', 'battery', 'powerMenu']
|
2012-05-17 10:11:54 -04:00
|
|
|
}
|
|
|
|
},
|
2012-05-16 18:26:44 -04:00
|
|
|
|
2012-09-01 08:42:53 -04:00
|
|
|
'lock-screen': {
|
|
|
|
hasOverview: false,
|
|
|
|
showCalendarEvents: false,
|
|
|
|
allowSettings: false,
|
|
|
|
allowExtensions: false,
|
|
|
|
allowKeybindingsWhenModal: false,
|
|
|
|
hasRunDialog: false,
|
|
|
|
hasWorkspaces: false,
|
|
|
|
hasWindows: false,
|
|
|
|
panel: {
|
|
|
|
left: ['userMenu'],
|
|
|
|
center: [],
|
|
|
|
right: ['lockScreen']
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2012-05-23 23:37:09 -04:00
|
|
|
'initial-setup': { hasOverview: false,
|
|
|
|
showCalendarEvents: false,
|
|
|
|
allowSettings: false,
|
|
|
|
allowExtensions: false,
|
|
|
|
allowKeybindingsWhenModal: false,
|
|
|
|
hasRunDialog: false,
|
|
|
|
hasWorkspaces: false,
|
|
|
|
createSession: Main.createInitialSetupSession,
|
2012-08-28 17:10:44 -04:00
|
|
|
panel: {
|
|
|
|
left: [],
|
|
|
|
center: ['dateMenu'],
|
2012-09-01 08:42:53 -04:00
|
|
|
right: ['a11y', 'keyboard', 'volume']
|
2012-08-28 17:10:44 -04:00
|
|
|
}
|
|
|
|
},
|
2012-05-23 23:37:09 -04:00
|
|
|
|
2012-05-16 18:59:02 -04:00
|
|
|
'user': { hasOverview: true,
|
2012-05-17 18:32:04 -04:00
|
|
|
showCalendarEvents: true,
|
2012-05-16 19:43:59 -04:00
|
|
|
allowSettings: true,
|
2012-05-16 20:08:56 -04:00
|
|
|
allowExtensions: true,
|
2012-05-17 09:55:35 -04:00
|
|
|
allowKeybindingsWhenModal: false,
|
2012-05-17 07:41:02 -04:00
|
|
|
hasRunDialog: true,
|
2012-05-17 09:32:32 -04:00
|
|
|
hasWorkspaces: true,
|
2012-09-01 08:42:53 -04:00
|
|
|
hasWindows: true,
|
2012-05-17 09:50:51 -04:00
|
|
|
createSession: Main.createUserSession,
|
2012-05-26 11:04:25 -04:00
|
|
|
createUnlockDialog: Main.createSessionUnlockDialog,
|
2012-08-28 17:10:44 -04:00
|
|
|
panel: {
|
|
|
|
left: ['activities', 'appMenu'],
|
|
|
|
center: ['dateMenu'],
|
|
|
|
right: ['a11y', 'keyboard', 'volume', 'bluetooth',
|
2012-09-01 08:42:53 -04:00
|
|
|
'network', 'battery', 'userMenu']
|
2012-05-17 10:11:54 -04:00
|
|
|
}
|
|
|
|
}
|
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
|
|
|
|
|
|
|
this._createSession = params.createSession;
|
|
|
|
delete params.createSession;
|
2012-05-26 11:04:25 -04:00
|
|
|
this._createUnlockDialog = params.createUnlockDialog;
|
|
|
|
delete params.createUnlockDialog;
|
2012-05-17 09:50:51 -04:00
|
|
|
|
2012-05-16 18:26:44 -04:00
|
|
|
Lang.copyProperties(params, this);
|
2012-09-01 08:42:53 -04:00
|
|
|
this.emit('updated');
|
2012-05-17 09:50:51 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
createSession: function() {
|
|
|
|
if (this._createSession)
|
|
|
|
this._createSession();
|
2012-05-26 11:04:25 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
createUnlockDialog: function() {
|
|
|
|
if (this._createUnlockDialog)
|
|
|
|
return this._createUnlockDialog.apply(this, arguments);
|
|
|
|
else
|
|
|
|
return null;
|
|
|
|
},
|
2012-05-16 18:26:44 -04:00
|
|
|
});
|
2012-09-01 08:42:53 -04:00
|
|
|
Signals.addSignalMethods(SessionMode.prototype);
|