Delegate mode information to a dedicated object

Rather than accessing global.session_type / global.session_mode
all over the place, delegate mode information to a dedicated
sessionMode object. While not very useful for now, we will replace
checks for a particular mode with checks for particular properties
that sessionMode defines based on global.session_mode.

https://bugzilla.gnome.org/show_bug.cgi?id=676156
This commit is contained in:
Florian Müllner
2012-05-17 00:26:44 +02:00
parent 940ddb104c
commit 3d26224180
6 changed files with 41 additions and 12 deletions

25
js/ui/sessionMode.js Normal file
View File

@ -0,0 +1,25 @@
// -*- mode: js; js-indent-level: 4; indent-tabs-mode: nil -*-
const Lang = imports.lang;
const Shell = imports.gi.Shell;
const Params = imports.misc.params;
const DEFAULT_MODE = 'user';
const _modes = {
'gdm': { sessionType: Shell.SessionType.GDM },
'user': { sessionType: Shell.SessionType.USER }
};
const SessionMode = new Lang.Class({
Name: 'SessionMode',
_init: function() {
let params = _modes[global.session_mode];
params = Params.parse(params, _modes[DEFAULT_MODE]);
Lang.copyProperties(params, this);
}
});