extensionSystem: Turn into a class
The extension system started out as a set of simple functions, but gained more state later, and even some hacks to emit signals without having an object to emit them on. There is no good reason for that weirdness, so rather than imitating an object, wrap the existing system into a real ExtensionManager object. https://bugzilla.gnome.org/show_bug.cgi?id=789852
This commit is contained in:
parent
d82810240f
commit
ea17740719
@ -7,6 +7,7 @@ const Dialog = imports.ui.dialog;
|
|||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
const ExtensionSystem = imports.ui.extensionSystem;
|
const ExtensionSystem = imports.ui.extensionSystem;
|
||||||
const FileUtils = imports.misc.fileUtils;
|
const FileUtils = imports.misc.fileUtils;
|
||||||
|
const Main = imports.ui.main;
|
||||||
const ModalDialog = imports.ui.modalDialog;
|
const ModalDialog = imports.ui.modalDialog;
|
||||||
|
|
||||||
var REPOSITORY_URL_BASE = 'https://extensions.gnome.org';
|
var REPOSITORY_URL_BASE = 'https://extensions.gnome.org';
|
||||||
@ -24,7 +25,7 @@ function installExtension(uuid, invocation) {
|
|||||||
|
|
||||||
_httpSession.queue_message(message, (session, message) => {
|
_httpSession.queue_message(message, (session, message) => {
|
||||||
if (message.status_code != Soup.KnownStatusCode.OK) {
|
if (message.status_code != Soup.KnownStatusCode.OK) {
|
||||||
ExtensionSystem.logExtensionError(uuid, `downloading info: ${message.status_code}`);
|
Main.extensionManager.logExtensionError(uuid, `downloading info: ${message.status_code}`);
|
||||||
invocation.return_dbus_error('org.gnome.Shell.DownloadInfoError', message.status_code.toString());
|
invocation.return_dbus_error('org.gnome.Shell.DownloadInfoError', message.status_code.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -33,7 +34,7 @@ function installExtension(uuid, invocation) {
|
|||||||
try {
|
try {
|
||||||
info = JSON.parse(message.response_body.data);
|
info = JSON.parse(message.response_body.data);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
ExtensionSystem.logExtensionError(uuid, `parsing info: ${e}`);
|
Main.extensionManager.logExtensionError(uuid, `parsing info: ${e}`);
|
||||||
invocation.return_dbus_error('org.gnome.Shell.ParseInfoError', e.toString());
|
invocation.return_dbus_error('org.gnome.Shell.ParseInfoError', e.toString());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -52,7 +53,7 @@ function uninstallExtension(uuid) {
|
|||||||
if (extension.type != ExtensionUtils.ExtensionType.PER_USER)
|
if (extension.type != ExtensionUtils.ExtensionType.PER_USER)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!ExtensionSystem.unloadExtension(extension))
|
if (!Main.extensionManager.unloadExtension(extension))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
FileUtils.recursivelyDeleteDir(extension.dir, true);
|
FileUtils.recursivelyDeleteDir(extension.dir, true);
|
||||||
@ -116,7 +117,7 @@ function updateExtension(uuid) {
|
|||||||
let oldExtension = ExtensionUtils.extensions[uuid];
|
let oldExtension = ExtensionUtils.extensions[uuid];
|
||||||
let extensionDir = oldExtension.dir;
|
let extensionDir = oldExtension.dir;
|
||||||
|
|
||||||
if (!ExtensionSystem.unloadExtension(oldExtension))
|
if (!Main.extensionManager.unloadExtension(oldExtension))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir);
|
FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir);
|
||||||
@ -126,10 +127,10 @@ function updateExtension(uuid) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, ExtensionUtils.ExtensionType.PER_USER);
|
extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, ExtensionUtils.ExtensionType.PER_USER);
|
||||||
ExtensionSystem.loadExtension(extension);
|
Main.extensionManager.loadExtension(extension);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (extension)
|
if (extension)
|
||||||
ExtensionSystem.unloadExtension(extension);
|
Main.extensionManager.unloadExtension(extension);
|
||||||
|
|
||||||
logError(e, 'Error loading extension %s'.format(uuid));
|
logError(e, 'Error loading extension %s'.format(uuid));
|
||||||
|
|
||||||
@ -138,7 +139,7 @@ function updateExtension(uuid) {
|
|||||||
|
|
||||||
// Restore what was there before. We can't do much if we
|
// Restore what was there before. We can't do much if we
|
||||||
// fail here.
|
// fail here.
|
||||||
ExtensionSystem.loadExtension(oldExtension);
|
Main.extensionManager.loadExtension(oldExtension);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +234,7 @@ class InstallExtensionDialog extends ModalDialog.ModalDialog {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
let extension = ExtensionUtils.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER);
|
let extension = ExtensionUtils.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER);
|
||||||
ExtensionSystem.loadExtension(extension);
|
Main.extensionManager.loadExtension(extension);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
uninstallExtension(uuid);
|
uninstallExtension(uuid);
|
||||||
errback('LoadExtensionError', e);
|
errback('LoadExtensionError', e);
|
||||||
|
@ -8,28 +8,23 @@ const Main = imports.ui.main;
|
|||||||
|
|
||||||
const { ExtensionState } = ExtensionUtils;
|
const { ExtensionState } = ExtensionUtils;
|
||||||
|
|
||||||
// Arrays of uuids
|
|
||||||
var enabledExtensions;
|
|
||||||
// Contains the order that extensions were enabled in.
|
|
||||||
var extensionOrder = [];
|
|
||||||
|
|
||||||
// We don't really have a class to add signals on. So, create
|
|
||||||
// a simple dummy object, add the signal methods, and export those
|
|
||||||
// publically.
|
|
||||||
var _signals = {};
|
|
||||||
Signals.addSignalMethods(_signals);
|
|
||||||
|
|
||||||
var connect = _signals.connect.bind(_signals);
|
|
||||||
var disconnect = _signals.disconnect.bind(_signals);
|
|
||||||
|
|
||||||
const ENABLED_EXTENSIONS_KEY = 'enabled-extensions';
|
const ENABLED_EXTENSIONS_KEY = 'enabled-extensions';
|
||||||
const DISABLE_USER_EXTENSIONS_KEY = 'disable-user-extensions';
|
const DISABLE_USER_EXTENSIONS_KEY = 'disable-user-extensions';
|
||||||
const EXTENSION_DISABLE_VERSION_CHECK_KEY = 'disable-extension-version-validation';
|
const EXTENSION_DISABLE_VERSION_CHECK_KEY = 'disable-extension-version-validation';
|
||||||
|
|
||||||
var initted = false;
|
var ExtensionManager = class {
|
||||||
var enabled;
|
constructor() {
|
||||||
|
this._initted = false;
|
||||||
|
this._enabled = false;
|
||||||
|
|
||||||
function disableExtension(uuid) {
|
this._enabledExtensions = [];
|
||||||
|
this._extensionOrder = [];
|
||||||
|
|
||||||
|
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
|
||||||
|
this._sessionUpdated();
|
||||||
|
}
|
||||||
|
|
||||||
|
disableExtension(uuid) {
|
||||||
let extension = ExtensionUtils.extensions[uuid];
|
let extension = ExtensionUtils.extensions[uuid];
|
||||||
if (!extension)
|
if (!extension)
|
||||||
return;
|
return;
|
||||||
@ -45,8 +40,8 @@ function disableExtension(uuid) {
|
|||||||
// user disables C
|
// user disables C
|
||||||
// this should: disable E, disable D, disable C, enable D, enable E
|
// this should: disable E, disable D, disable C, enable D, enable E
|
||||||
|
|
||||||
let orderIdx = extensionOrder.indexOf(uuid);
|
let orderIdx = this._extensionOrder.indexOf(uuid);
|
||||||
let order = extensionOrder.slice(orderIdx + 1);
|
let order = this._extensionOrder.slice(orderIdx + 1);
|
||||||
let orderReversed = order.slice().reverse();
|
let orderReversed = order.slice().reverse();
|
||||||
|
|
||||||
for (let i = 0; i < orderReversed.length; i++) {
|
for (let i = 0; i < orderReversed.length; i++) {
|
||||||
@ -54,7 +49,7 @@ function disableExtension(uuid) {
|
|||||||
try {
|
try {
|
||||||
ExtensionUtils.extensions[uuid].stateObj.disable();
|
ExtensionUtils.extensions[uuid].stateObj.disable();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logExtensionError(uuid, e);
|
this.logExtensionError(uuid, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +62,7 @@ function disableExtension(uuid) {
|
|||||||
try {
|
try {
|
||||||
extension.stateObj.disable();
|
extension.stateObj.disable();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logExtensionError(uuid, e);
|
this.logExtensionError(uuid, e);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < order.length; i++) {
|
for (let i = 0; i < order.length; i++) {
|
||||||
@ -75,30 +70,30 @@ function disableExtension(uuid) {
|
|||||||
try {
|
try {
|
||||||
ExtensionUtils.extensions[uuid].stateObj.enable();
|
ExtensionUtils.extensions[uuid].stateObj.enable();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logExtensionError(uuid, e);
|
this.logExtensionError(uuid, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
extensionOrder.splice(orderIdx, 1);
|
this._extensionOrder.splice(orderIdx, 1);
|
||||||
|
|
||||||
if ( extension.state != ExtensionState.ERROR ) {
|
if (extension.state != ExtensionState.ERROR) {
|
||||||
extension.state = ExtensionState.DISABLED;
|
extension.state = ExtensionState.DISABLED;
|
||||||
_signals.emit('extension-state-changed', extension);
|
this.emit('extension-state-changed', extension);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function enableExtension(uuid) {
|
enableExtension(uuid) {
|
||||||
let extension = ExtensionUtils.extensions[uuid];
|
let extension = ExtensionUtils.extensions[uuid];
|
||||||
if (!extension)
|
if (!extension)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (extension.state == ExtensionState.INITIALIZED)
|
if (extension.state == ExtensionState.INITIALIZED)
|
||||||
initExtension(uuid);
|
this.initExtension(uuid);
|
||||||
|
|
||||||
if (extension.state != ExtensionState.DISABLED)
|
if (extension.state != ExtensionState.DISABLED)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
extensionOrder.push(uuid);
|
this._extensionOrder.push(uuid);
|
||||||
|
|
||||||
let stylesheetNames = [`${global.session_mode}.css`, 'stylesheet.css'];
|
let stylesheetNames = [`${global.session_mode}.css`, 'stylesheet.css'];
|
||||||
let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
|
let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
|
||||||
@ -119,19 +114,19 @@ function enableExtension(uuid) {
|
|||||||
try {
|
try {
|
||||||
extension.stateObj.enable();
|
extension.stateObj.enable();
|
||||||
extension.state = ExtensionState.ENABLED;
|
extension.state = ExtensionState.ENABLED;
|
||||||
_signals.emit('extension-state-changed', extension);
|
this.emit('extension-state-changed', extension);
|
||||||
return;
|
return;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (extension.stylesheet) {
|
if (extension.stylesheet) {
|
||||||
theme.unload_stylesheet(extension.stylesheet);
|
theme.unload_stylesheet(extension.stylesheet);
|
||||||
delete extension.stylesheet;
|
delete extension.stylesheet;
|
||||||
}
|
}
|
||||||
logExtensionError(uuid, e);
|
this.logExtensionError(uuid, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function logExtensionError(uuid, error) {
|
logExtensionError(uuid, error) {
|
||||||
let extension = ExtensionUtils.extensions[uuid];
|
let extension = ExtensionUtils.extensions[uuid];
|
||||||
if (!extension)
|
if (!extension)
|
||||||
return;
|
return;
|
||||||
@ -144,12 +139,12 @@ function logExtensionError(uuid, error) {
|
|||||||
extension.errors.push(message);
|
extension.errors.push(message);
|
||||||
|
|
||||||
log('Extension "%s" had error: %s'.format(uuid, message));
|
log('Extension "%s" had error: %s'.format(uuid, message));
|
||||||
_signals.emit('extension-state-changed', { uuid: uuid,
|
this.emit('extension-state-changed', { uuid: uuid,
|
||||||
error: message,
|
error: message,
|
||||||
state: extension.state });
|
state: extension.state });
|
||||||
}
|
}
|
||||||
|
|
||||||
function loadExtension(extension) {
|
loadExtension(extension) {
|
||||||
// Default to error, we set success as the last step
|
// Default to error, we set success as the last step
|
||||||
extension.state = ExtensionState.ERROR;
|
extension.state = ExtensionState.ERROR;
|
||||||
|
|
||||||
@ -158,54 +153,54 @@ function loadExtension(extension) {
|
|||||||
if (checkVersion && ExtensionUtils.isOutOfDate(extension)) {
|
if (checkVersion && ExtensionUtils.isOutOfDate(extension)) {
|
||||||
extension.state = ExtensionState.OUT_OF_DATE;
|
extension.state = ExtensionState.OUT_OF_DATE;
|
||||||
} else {
|
} else {
|
||||||
let enabled = enabledExtensions.includes(extension.uuid);
|
let enabled = this._enabledExtensions.includes(extension.uuid);
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
if (!initExtension(extension.uuid))
|
if (!this.initExtension(extension.uuid))
|
||||||
return;
|
return;
|
||||||
if (extension.state == ExtensionState.DISABLED)
|
if (extension.state == ExtensionState.DISABLED)
|
||||||
enableExtension(extension.uuid);
|
this.enableExtension(extension.uuid);
|
||||||
} else {
|
} else {
|
||||||
extension.state = ExtensionState.INITIALIZED;
|
extension.state = ExtensionState.INITIALIZED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
_signals.emit('extension-state-changed', extension);
|
this.emit('extension-state-changed', extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
function unloadExtension(extension) {
|
unloadExtension(extension) {
|
||||||
// Try to disable it -- if it's ERROR'd, we can't guarantee that,
|
// Try to disable it -- if it's ERROR'd, we can't guarantee that,
|
||||||
// but it will be removed on next reboot, and hopefully nothing
|
// but it will be removed on next reboot, and hopefully nothing
|
||||||
// broke too much.
|
// broke too much.
|
||||||
disableExtension(extension.uuid);
|
this.disableExtension(extension.uuid);
|
||||||
|
|
||||||
extension.state = ExtensionState.UNINSTALLED;
|
extension.state = ExtensionState.UNINSTALLED;
|
||||||
_signals.emit('extension-state-changed', extension);
|
this.emit('extension-state-changed', extension);
|
||||||
|
|
||||||
delete ExtensionUtils.extensions[extension.uuid];
|
delete ExtensionUtils.extensions[extension.uuid];
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function reloadExtension(oldExtension) {
|
reloadExtension(oldExtension) {
|
||||||
// Grab the things we'll need to pass to createExtensionObject
|
// Grab the things we'll need to pass to createExtensionObject
|
||||||
// to reload it.
|
// to reload it.
|
||||||
let { uuid: uuid, dir: dir, type: type } = oldExtension;
|
let { uuid: uuid, dir: dir, type: type } = oldExtension;
|
||||||
|
|
||||||
// Then unload the old extension.
|
// Then unload the old extension.
|
||||||
unloadExtension(oldExtension);
|
this.unloadExtension(oldExtension);
|
||||||
|
|
||||||
// Now, recreate the extension and load it.
|
// Now, recreate the extension and load it.
|
||||||
let newExtension;
|
let newExtension;
|
||||||
try {
|
try {
|
||||||
newExtension = ExtensionUtils.createExtensionObject(uuid, dir, type);
|
newExtension = ExtensionUtils.createExtensionObject(uuid, dir, type);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logExtensionError(uuid, e);
|
this.logExtensionError(uuid, e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadExtension(newExtension);
|
this.loadExtension(newExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
function initExtension(uuid) {
|
initExtension(uuid) {
|
||||||
let extension = ExtensionUtils.extensions[uuid];
|
let extension = ExtensionUtils.extensions[uuid];
|
||||||
let dir = extension.dir;
|
let dir = extension.dir;
|
||||||
|
|
||||||
@ -214,7 +209,7 @@ function initExtension(uuid) {
|
|||||||
|
|
||||||
let extensionJs = dir.get_child('extension.js');
|
let extensionJs = dir.get_child('extension.js');
|
||||||
if (!extensionJs.query_exists(null)) {
|
if (!extensionJs.query_exists(null)) {
|
||||||
logExtensionError(uuid, new Error('Missing extension.js'));
|
this.logExtensionError(uuid, new Error('Missing extension.js'));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -225,7 +220,7 @@ function initExtension(uuid) {
|
|||||||
try {
|
try {
|
||||||
extensionModule = extension.imports.extension;
|
extensionModule = extension.imports.extension;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logExtensionError(uuid, e);
|
this.logExtensionError(uuid, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,7 +228,7 @@ function initExtension(uuid) {
|
|||||||
try {
|
try {
|
||||||
extensionState = extensionModule.init(extension);
|
extensionState = extensionModule.init(extension);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logExtensionError(uuid, e);
|
this.logExtensionError(uuid, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -243,11 +238,11 @@ function initExtension(uuid) {
|
|||||||
extension.stateObj = extensionState;
|
extension.stateObj = extensionState;
|
||||||
|
|
||||||
extension.state = ExtensionState.DISABLED;
|
extension.state = ExtensionState.DISABLED;
|
||||||
_signals.emit('extension-loaded', uuid);
|
this.emit('extension-loaded', uuid);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEnabledExtensions() {
|
_getEnabledExtensions() {
|
||||||
let extensions;
|
let extensions;
|
||||||
if (Array.isArray(Main.sessionMode.enabledExtensions))
|
if (Array.isArray(Main.sessionMode.enabledExtensions))
|
||||||
extensions = Main.sessionMode.enabledExtensions;
|
extensions = Main.sessionMode.enabledExtensions;
|
||||||
@ -258,106 +253,106 @@ function getEnabledExtensions() {
|
|||||||
return extensions;
|
return extensions;
|
||||||
|
|
||||||
return extensions.concat(global.settings.get_strv(ENABLED_EXTENSIONS_KEY));
|
return extensions.concat(global.settings.get_strv(ENABLED_EXTENSIONS_KEY));
|
||||||
}
|
}
|
||||||
|
|
||||||
function onEnabledExtensionsChanged() {
|
_onEnabledExtensionsChanged() {
|
||||||
let newEnabledExtensions = getEnabledExtensions();
|
let newEnabledExtensions = this._getEnabledExtensions();
|
||||||
|
|
||||||
if (!enabled)
|
if (!this._enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Find and enable all the newly enabled extensions: UUIDs found in the
|
// Find and enable all the newly enabled extensions: UUIDs found in the
|
||||||
// new setting, but not in the old one.
|
// new setting, but not in the old one.
|
||||||
newEnabledExtensions.filter(
|
newEnabledExtensions.filter(
|
||||||
uuid => !enabledExtensions.includes(uuid)
|
uuid => !this._enabledExtensions.includes(uuid)
|
||||||
).forEach(uuid => {
|
).forEach(uuid => {
|
||||||
enableExtension(uuid);
|
this.enableExtension(uuid);
|
||||||
});
|
});
|
||||||
|
|
||||||
// Find and disable all the newly disabled extensions: UUIDs found in the
|
// Find and disable all the newly disabled extensions: UUIDs found in the
|
||||||
// old setting, but not in the new one.
|
// old setting, but not in the new one.
|
||||||
enabledExtensions.filter(
|
this._enabledExtensions.filter(
|
||||||
item => !newEnabledExtensions.includes(item)
|
item => !newEnabledExtensions.includes(item)
|
||||||
).forEach(uuid => {
|
).forEach(uuid => {
|
||||||
disableExtension(uuid);
|
this.disableExtension(uuid);
|
||||||
});
|
});
|
||||||
|
|
||||||
enabledExtensions = newEnabledExtensions;
|
this._enabledExtensions = newEnabledExtensions;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _onVersionValidationChanged() {
|
_onVersionValidationChanged() {
|
||||||
// we want to reload all extensions, but only enable
|
// we want to reload all extensions, but only enable
|
||||||
// extensions when allowed by the sessionMode, so
|
// extensions when allowed by the sessionMode, so
|
||||||
// temporarily disable them all
|
// temporarily disable them all
|
||||||
enabledExtensions = [];
|
this._enabledExtensions = [];
|
||||||
for (let uuid in ExtensionUtils.extensions)
|
for (let uuid in ExtensionUtils.extensions)
|
||||||
reloadExtension(ExtensionUtils.extensions[uuid]);
|
this.reloadExtension(ExtensionUtils.extensions[uuid]);
|
||||||
enabledExtensions = getEnabledExtensions();
|
this._enabledExtensions = this._getEnabledExtensions();
|
||||||
|
|
||||||
if (Main.sessionMode.allowExtensions) {
|
if (Main.sessionMode.allowExtensions) {
|
||||||
enabledExtensions.forEach(uuid => {
|
this._enabledExtensions.forEach(uuid => {
|
||||||
enableExtension(uuid);
|
this.enableExtension(uuid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function _loadExtensions() {
|
_loadExtensions() {
|
||||||
global.settings.connect(`changed::${ENABLED_EXTENSIONS_KEY}`, onEnabledExtensionsChanged);
|
global.settings.connect(`changed::${ENABLED_EXTENSIONS_KEY}`,
|
||||||
global.settings.connect(`changed::${DISABLE_USER_EXTENSIONS_KEY}`, onEnabledExtensionsChanged);
|
this._onEnabledExtensionsChanged.bind(this));
|
||||||
global.settings.connect(`changed::${EXTENSION_DISABLE_VERSION_CHECK_KEY}`, _onVersionValidationChanged);
|
global.settings.connect(`changed::${DISABLE_USER_EXTENSIONS_KEY}`,
|
||||||
|
this._onEnabledExtensionsChanged.bind(this));
|
||||||
|
global.settings.connect(`changed::${EXTENSION_DISABLE_VERSION_CHECK_KEY}`,
|
||||||
|
this._onVersionValidationChanged.bind(this));
|
||||||
|
|
||||||
enabledExtensions = getEnabledExtensions();
|
this._enabledExtensions = this._getEnabledExtensions();
|
||||||
|
|
||||||
let finder = new ExtensionUtils.ExtensionFinder();
|
let finder = new ExtensionUtils.ExtensionFinder();
|
||||||
finder.connect('extension-found', (finder, extension) => {
|
finder.connect('extension-found', (finder, extension) => {
|
||||||
loadExtension(extension);
|
this.loadExtension(extension);
|
||||||
});
|
});
|
||||||
finder.scanExtensions();
|
finder.scanExtensions();
|
||||||
}
|
}
|
||||||
|
|
||||||
function enableAllExtensions() {
|
enableAllExtensions() {
|
||||||
if (enabled)
|
if (this._enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (!initted) {
|
if (!this._initted) {
|
||||||
_loadExtensions();
|
this._loadExtensions();
|
||||||
initted = true;
|
this._initted = true;
|
||||||
} else {
|
} else {
|
||||||
enabledExtensions.forEach(uuid => {
|
this._enabledExtensions.forEach(uuid => {
|
||||||
enableExtension(uuid);
|
this.enableExtension(uuid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
enabled = true;
|
this._enabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
function disableAllExtensions() {
|
disableAllExtensions() {
|
||||||
if (!enabled)
|
if (!this._enabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (initted) {
|
if (this._initted) {
|
||||||
extensionOrder.slice().reverse().forEach(uuid => {
|
this._extensionOrder.slice().reverse().forEach(uuid => {
|
||||||
disableExtension(uuid);
|
this.disableExtension(uuid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
enabled = false;
|
this._enabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function _sessionUpdated() {
|
_sessionUpdated() {
|
||||||
// For now sessionMode.allowExtensions controls extensions from both the
|
// For now sessionMode.allowExtensions controls extensions from both the
|
||||||
// 'enabled-extensions' preference and the sessionMode.enabledExtensions
|
// 'enabled-extensions' preference and the sessionMode.enabledExtensions
|
||||||
// property; it might make sense to make enabledExtensions independent
|
// property; it might make sense to make enabledExtensions independent
|
||||||
// from allowExtensions in the future
|
// from allowExtensions in the future
|
||||||
if (Main.sessionMode.allowExtensions) {
|
if (Main.sessionMode.allowExtensions) {
|
||||||
if (initted)
|
if (this._initted)
|
||||||
enabledExtensions = getEnabledExtensions();
|
this._enabledExtensions = this._getEnabledExtensions();
|
||||||
enableAllExtensions();
|
this.enableAllExtensions();
|
||||||
} else {
|
} else {
|
||||||
disableAllExtensions();
|
this.disableAllExtensions();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
function init() {
|
Signals.addSignalMethods(ExtensionManager.prototype);
|
||||||
Main.sessionMode.connect('updated', _sessionUpdated);
|
|
||||||
_sessionUpdated();
|
|
||||||
}
|
|
||||||
|
@ -7,7 +7,6 @@ const Signals = imports.signals;
|
|||||||
const System = imports.system;
|
const System = imports.system;
|
||||||
|
|
||||||
const History = imports.misc.history;
|
const History = imports.misc.history;
|
||||||
const ExtensionSystem = imports.ui.extensionSystem;
|
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
const ShellEntry = imports.ui.shellEntry;
|
const ShellEntry = imports.ui.shellEntry;
|
||||||
const Tweener = imports.ui.tweener;
|
const Tweener = imports.ui.tweener;
|
||||||
@ -628,7 +627,7 @@ var Extensions = class Extensions {
|
|||||||
for (let uuid in ExtensionUtils.extensions)
|
for (let uuid in ExtensionUtils.extensions)
|
||||||
this._loadExtension(null, uuid);
|
this._loadExtension(null, uuid);
|
||||||
|
|
||||||
ExtensionSystem.connect('extension-loaded',
|
Main.extensionManager.connect('extension-loaded',
|
||||||
this._loadExtension.bind(this));
|
this._loadExtension.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@ const LOG_DOMAIN = 'GNOME Shell';
|
|||||||
const GNOMESHELL_STARTED_MESSAGE_ID = 'f3ea493c22934e26811cd62abe8e203a';
|
const GNOMESHELL_STARTED_MESSAGE_ID = 'f3ea493c22934e26811cd62abe8e203a';
|
||||||
|
|
||||||
var componentManager = null;
|
var componentManager = null;
|
||||||
|
var extensionManager = null;
|
||||||
var panel = null;
|
var panel = null;
|
||||||
var overview = null;
|
var overview = null;
|
||||||
var runDialog = null;
|
var runDialog = null;
|
||||||
@ -226,7 +227,7 @@ function _initializeUI() {
|
|||||||
_startDate = new Date();
|
_startDate = new Date();
|
||||||
|
|
||||||
ExtensionDownloader.init();
|
ExtensionDownloader.init();
|
||||||
ExtensionSystem.init();
|
extensionManager = new ExtensionSystem.ExtensionManager();
|
||||||
|
|
||||||
if (sessionMode.isGreeter && screenShield) {
|
if (sessionMode.isGreeter && screenShield) {
|
||||||
layoutManager.connect('startup-prepared', () => {
|
layoutManager.connect('startup-prepared', () => {
|
||||||
|
@ -4,7 +4,6 @@ const { Gio, GLib, Meta, Shell } = imports.gi;
|
|||||||
const Lang = imports.lang;
|
const Lang = imports.lang;
|
||||||
|
|
||||||
const Config = imports.misc.config;
|
const Config = imports.misc.config;
|
||||||
const ExtensionSystem = imports.ui.extensionSystem;
|
|
||||||
const ExtensionDownloader = imports.ui.extensionDownloader;
|
const ExtensionDownloader = imports.ui.extensionDownloader;
|
||||||
const ExtensionUtils = imports.misc.extensionUtils;
|
const ExtensionUtils = imports.misc.extensionUtils;
|
||||||
const Main = imports.ui.main;
|
const Main = imports.ui.main;
|
||||||
@ -251,7 +250,7 @@ var GnomeShellExtensions = class {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this);
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this);
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell');
|
||||||
ExtensionSystem.connect('extension-state-changed',
|
Main.extensionManager.connect('extension-state-changed',
|
||||||
this._extensionStateChanged.bind(this));
|
this._extensionStateChanged.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +334,7 @@ var GnomeShellExtensions = class {
|
|||||||
if (!extension)
|
if (!extension)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
ExtensionSystem.reloadExtension(extension);
|
Main.extensionManager.reloadExtension(extension);
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckForUpdates() {
|
CheckForUpdates() {
|
||||||
|
Loading…
Reference in New Issue
Block a user