sessionMode: Introduce the concept of "primary" modes

With the recent session mode changes, there is now a mix of modes
that are meant to apply to the entire session (specified as parameter
to the --mode command line switch) and temporary modes like the lock
screen; introduce a property to make the difference explicit, and only
allow "primary" modes to be specified on the command line.

https://bugzilla.gnome.org/show_bug.cgi?id=683488
This commit is contained in:
Florian Müllner 2012-09-06 13:21:12 +02:00
parent 5a259dd6b0
commit 8109dd684e

View File

@ -20,6 +20,7 @@ const _modes = {
hasWindows: false, hasWindows: false,
isLocked: false, isLocked: false,
isGreeter: false, isGreeter: false,
isPrimary: false,
unlockDialog: null, unlockDialog: null,
components: [], components: [],
panel: { panel: {
@ -32,6 +33,7 @@ const _modes = {
'gdm': { 'gdm': {
allowKeybindingsWhenModal: true, allowKeybindingsWhenModal: true,
isGreeter: true, isGreeter: true,
isPrimary: true,
unlockDialog: imports.gdm.loginDialog.LoginDialog, unlockDialog: imports.gdm.loginDialog.LoginDialog,
components: ['polkitAgent'], components: ['polkitAgent'],
panel: { panel: {
@ -55,6 +57,7 @@ const _modes = {
}, },
'initial-setup': { 'initial-setup': {
isPrimary: true,
components: ['keyring'], components: ['keyring'],
panel: { panel: {
left: [], left: [],
@ -73,6 +76,7 @@ const _modes = {
hasWindows: true, hasWindows: true,
unlockDialog: imports.ui.unlockDialog.UnlockDialog, unlockDialog: imports.ui.unlockDialog.UnlockDialog,
isLocked: false, isLocked: false,
isPrimary: true,
components: ['networkAgent', 'polkitAgent', 'telepathyClient', components: ['networkAgent', 'polkitAgent', 'telepathyClient',
'keyring', 'recorder', 'autorunManager', 'automountManager'], 'keyring', 'recorder', 'autorunManager', 'automountManager'],
panel: { panel: {
@ -87,7 +91,8 @@ const _modes = {
function listModes() { function listModes() {
let modes = Object.getOwnPropertyNames(_modes); let modes = Object.getOwnPropertyNames(_modes);
for (let i = 0; i < modes.length; i++) for (let i = 0; i < modes.length; i++)
print(modes[i]); if (_modes[modes[i]].isPrimary)
print(modes[i]);
} }
const SessionMode = new Lang.Class({ const SessionMode = new Lang.Class({
@ -95,7 +100,9 @@ const SessionMode = new Lang.Class({
_init: function() { _init: function() {
global.connect('notify::session-mode', Lang.bind(this, this._sync)); global.connect('notify::session-mode', Lang.bind(this, this._sync));
this._modeStack = [global.session_mode]; let mode = _modes[global.session_mode].isPrimary ? global.session_mode
: 'user';
this._modeStack = [mode];
this._sync(); this._sync();
}, },