extensionSystem: Load/unload stylesheets on enable/disable
I'm not entirely sure why this wasn't caught earlier. https://bugzilla.gnome.org/show_bug.cgi?id=677586
This commit is contained in:
parent
86de6f5861
commit
11278a0814
@ -67,6 +67,11 @@ function disableExtension(uuid) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (extension.stylesheet) {
|
||||||
|
let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
|
||||||
|
theme.unload_stylesheet(extension.stylesheet.get_path());
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
extension.stateObj.disable();
|
extension.stateObj.disable();
|
||||||
} catch(e) {
|
} catch(e) {
|
||||||
@ -109,6 +114,17 @@ function enableExtension(uuid) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let stylesheetFile = extension.dir.get_child('stylesheet.css');
|
||||||
|
if (stylesheetFile.query_exists(null)) {
|
||||||
|
let theme = St.ThemeContext.get_for_stage(global.stage).get_theme();
|
||||||
|
try {
|
||||||
|
theme.load_stylesheet(stylesheetFile.get_path());
|
||||||
|
extension.stylesheet = stylesheetFile;
|
||||||
|
} catch (e) {
|
||||||
|
logExtensionError(uuid, 'Stylesheet parse error: ' + e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension.state = ExtensionState.ENABLED;
|
extension.state = ExtensionState.ENABLED;
|
||||||
_signals.emit('extension-state-changed', extension);
|
_signals.emit('extension-state-changed', extension);
|
||||||
}
|
}
|
||||||
@ -163,18 +179,6 @@ function initExtension(uuid) {
|
|||||||
logExtensionError(uuid, 'Missing extension.js');
|
logExtensionError(uuid, 'Missing extension.js');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let stylesheetPath = null;
|
|
||||||
let themeContext = St.ThemeContext.get_for_stage(global.stage);
|
|
||||||
let theme = themeContext.get_theme();
|
|
||||||
let stylesheetFile = dir.get_child('stylesheet.css');
|
|
||||||
if (stylesheetFile.query_exists(null)) {
|
|
||||||
try {
|
|
||||||
theme.load_stylesheet(stylesheetFile.get_path());
|
|
||||||
} catch (e) {
|
|
||||||
logExtensionError(uuid, 'Stylesheet parse error: ' + e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
let extensionModule;
|
let extensionModule;
|
||||||
let extensionState = null;
|
let extensionState = null;
|
||||||
@ -182,8 +186,6 @@ function initExtension(uuid) {
|
|||||||
ExtensionUtils.installImporter(extension);
|
ExtensionUtils.installImporter(extension);
|
||||||
extensionModule = extension.imports.extension;
|
extensionModule = extension.imports.extension;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (stylesheetPath != null)
|
|
||||||
theme.unload_stylesheet(stylesheetPath);
|
|
||||||
logExtensionError(uuid, '' + e);
|
logExtensionError(uuid, '' + e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -196,8 +198,6 @@ function initExtension(uuid) {
|
|||||||
try {
|
try {
|
||||||
extensionState = extensionModule.init(extension);
|
extensionState = extensionModule.init(extension);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (stylesheetPath != null)
|
|
||||||
theme.unload_stylesheet(stylesheetPath);
|
|
||||||
logExtensionError(uuid, 'Failed to evaluate init function:' + e);
|
logExtensionError(uuid, 'Failed to evaluate init function:' + e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user