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:
25
js/ui/sessionMode.js
Normal file
25
js/ui/sessionMode.js
Normal 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);
|
||||
}
|
||||
});
|
Reference in New Issue
Block a user