sessionMode: Add createSession() hook

Add a sessionMode.createSession() hook, which is executed during
startup to setup mode-specific stuff.

https://bugzilla.gnome.org/show_bug.cgi?id=676156
This commit is contained in:
Florian Müllner 2012-05-17 15:50:51 +02:00
parent f6a2c92bfa
commit c25e7f3c41
2 changed files with 15 additions and 6 deletions

View File

@ -76,7 +76,7 @@ let _overridesSettings = null;
let background = null; let background = null;
function _createUserSession() { function createUserSession() {
// Load the calendar server. Note that we are careful about // Load the calendar server. Note that we are careful about
// not loading any events until the user presses the clock // not loading any events until the user presses the clock
global.launch_calendar_server(); global.launch_calendar_server();
@ -89,7 +89,7 @@ function _createUserSession() {
_initRecorder(); _initRecorder();
} }
function _createGDMSession() { function createGDMSession() {
// We do this this here instead of at the top to prevent GDM // We do this this here instead of at the top to prevent GDM
// related code from getting loaded in normal user sessions // related code from getting loaded in normal user sessions
const LoginDialog = imports.gdm.loginDialog; const LoginDialog = imports.gdm.loginDialog;
@ -204,10 +204,7 @@ function start() {
notificationDaemon = new NotificationDaemon.NotificationDaemon(); notificationDaemon = new NotificationDaemon.NotificationDaemon();
windowAttentionHandler = new WindowAttentionHandler.WindowAttentionHandler(); windowAttentionHandler = new WindowAttentionHandler.WindowAttentionHandler();
if (sessionMode.sessionType == Shell.SessionType.USER) sessionMode.createSession();
_createUserSession();
else if (sessionMode.sessionType == Shell.SessionType.GDM)
_createGDMSession();
panel.startStatusArea(); panel.startStatusArea();

View File

@ -3,6 +3,7 @@
const Lang = imports.lang; const Lang = imports.lang;
const Shell = imports.gi.Shell; const Shell = imports.gi.Shell;
const Main = imports.ui.main;
const Params = imports.misc.params; const Params = imports.misc.params;
const DEFAULT_MODE = 'user'; const DEFAULT_MODE = 'user';
@ -16,6 +17,7 @@ const _modes = {
allowKeybindingsWhenModal: true, allowKeybindingsWhenModal: true,
hasRunDialog: false, hasRunDialog: false,
hasWorkspaces: false, hasWorkspaces: false,
createSession: Main.createGDMSession,
sessionType: Shell.SessionType.GDM }, sessionType: Shell.SessionType.GDM },
'user': { hasOverview: true, 'user': { hasOverview: true,
@ -26,6 +28,7 @@ const _modes = {
allowKeybindingsWhenModal: false, allowKeybindingsWhenModal: false,
hasRunDialog: true, hasRunDialog: true,
hasWorkspaces: true, hasWorkspaces: true,
createSession: Main.createUserSession,
sessionType: Shell.SessionType.USER } sessionType: Shell.SessionType.USER }
}; };
@ -41,6 +44,15 @@ const SessionMode = new Lang.Class({
let params = _modes[global.session_mode]; let params = _modes[global.session_mode];
params = Params.parse(params, _modes[DEFAULT_MODE]); params = Params.parse(params, _modes[DEFAULT_MODE]);
this._createSession = params.createSession;
delete params.createSession;
Lang.copyProperties(params, this); Lang.copyProperties(params, this);
},
createSession: function() {
if (this._createSession)
this._createSession();
} }
}); });