extensionSystem: Add support for mode-specific extensions

As currently envisioned, the fallback replacement in 3.8 should be
a separate session at the login screen. As we will use extensions
to implement this mode, we need a way to specify extensions per
session rather than per user, so add a session-mode property for
extensions that should be loaded in addition to the user-defined
ones.

https://bugzilla.gnome.org/show_bug.cgi?id=689305
This commit is contained in:
Florian Müllner 2012-11-29 16:09:21 +01:00
parent 92083eaf76
commit 31f75e4607
2 changed files with 20 additions and 4 deletions

View File

@ -211,8 +211,16 @@ function initExtension(uuid) {
_signals.emit('extension-loaded', uuid);
}
function getEnabledExtensions() {
let extensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
if (!Array.isArray(Main.sessionMode.enabledExtensions))
return extensions;
return Main.sessionMode.enabledExtensions.concat(extensions);
}
function onEnabledExtensionsChanged() {
let newEnabledExtensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
let newEnabledExtensions = getEnabledExtensions();
if (!enabled)
return;
@ -246,7 +254,7 @@ function onEnabledExtensionsChanged() {
function _loadExtensions() {
global.settings.connect('changed::' + ENABLED_EXTENSIONS_KEY, onEnabledExtensionsChanged);
enabledExtensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
enabledExtensions = getEnabledExtensions();
let finder = new ExtensionUtils.ExtensionFinder();
finder.connect('extension-found', function(signals, extension) {
@ -288,10 +296,17 @@ function disableAllExtensions() {
}
function _sessionUpdated() {
if (Main.sessionMode.allowExtensions)
// For now sessionMode.allowExtensions controls extensions from both the
// 'enabled-extensions' preference and the sessionMode.enabledExtensions
// property; it might make sense to make enabledExtensions independent
// from allowExtensions in the future
if (Main.sessionMode.allowExtensions) {
if (initted)
onEnabledExtensionsChanged();
enableAllExtensions();
else
} else {
disableAllExtensions();
}
}
function init() {

View File

@ -18,6 +18,7 @@ const _modes = {
showCalendarEvents: false,
allowSettings: false,
allowExtensions: false,
enabledExtensions: [],
hasRunDialog: false,
hasWorkspaces: false,
hasWindows: false,