[gnome-shell/benzea/systemd-user-units-with-extension-warning: 1/6] extensionSystem: Add isRequested property for extensions
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/benzea/systemd-user-units-with-extension-warning: 1/6] extensionSystem: Add isRequested property for extensions
- Date: Fri, 30 Aug 2019 15:22:44 +0000 (UTC)
commit afefc88e024e906b107d1a9a4e642c8f489793e8
Author: Benjamin Berg <bberg redhat com>
Date: Thu Aug 1 16:32:57 2019 +0200
extensionSystem: Add isRequested property for extensions
The property reflects whether the extension is enabled in the setting.
This does not mean that the extension is actually loaded, the API user
must check the state property for this information.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/695
js/misc/extensionUtils.js | 2 +-
js/ui/extensionSystem.js | 26 +++++++++++++++++++++++++-
2 files changed, 26 insertions(+), 2 deletions(-)
---
diff --git a/js/misc/extensionUtils.js b/js/misc/extensionUtils.js
index a05a884181..f3437fe931 100644
--- a/js/misc/extensionUtils.js
+++ b/js/misc/extensionUtils.js
@@ -31,7 +31,7 @@ var ExtensionState = {
UNINSTALLED: 99
};
-const SERIALIZED_PROPERTIES = ['type', 'state', 'path', 'error', 'hasPrefs', 'canChange'];
+const SERIALIZED_PROPERTIES = ['type', 'state', 'path', 'error', 'hasPrefs', 'canChange', 'isRequested'];
/**
* getCurrentExtension:
diff --git a/js/ui/extensionSystem.js b/js/ui/extensionSystem.js
index fd7196972d..e9934cc5c8 100644
--- a/js/ui/extensionSystem.js
+++ b/js/ui/extensionSystem.js
@@ -22,6 +22,7 @@ var ExtensionManager = class {
this._extensions = new Map();
this._enabledExtensions = [];
+ this._requestedExtensions = [];
this._extensionOrder = [];
Main.sessionMode.connect('updated', this._sessionUpdated.bind(this));
@@ -250,6 +251,9 @@ var ExtensionManager = class {
// Default to error, we set success as the last step
extension.state = ExtensionState.ERROR;
+ let requested = this._requestedExtensions.includes(extension.uuid);
+ extension.isRequested = requested;
+
let checkVersion = !global.settings.get_boolean(EXTENSION_DISABLE_VERSION_CHECK_KEY);
if (checkVersion && ExtensionUtils.isOutOfDate(extension)) {
@@ -380,6 +384,14 @@ var ExtensionManager = class {
return extensions.filter(item => !disabledExtensions.includes(item));
}
+ _getRequestedExtensions() {
+ let extensions = global.settings.get_strv(ENABLED_EXTENSIONS_KEY);
+
+ // filter out 'disabled-extensions' which takes precedence
+ let disabledExtensions = global.settings.get_strv(DISABLED_EXTENSIONS_KEY);
+ return extensions.filter(item => !disabledExtensions.includes(item));
+ }
+
_onUserExtensionsEnabledChanged() {
this._onEnabledExtensionsChanged();
this._onSettingsWritableChanged();
@@ -391,6 +403,16 @@ var ExtensionManager = class {
if (!this._enabled)
return;
+ // Updated requested state and emit change notifications
+ this._requestedExtensions = this._getRequestedExtensions();
+ for (let extension of this._extensions.values()) {
+ let requested = this._requestedExtensions.includes(extension.uuid);
+ if (extension.isRequested == requested)
+ continue;
+ extension.isRequested = requested;
+ this.emit('extension-state-changed', extension);
+ }
+
// Find and enable all the newly enabled extensions: UUIDs found in the
// new setting, but not in the old one.
newEnabledExtensions.filter(
@@ -451,6 +473,7 @@ var ExtensionManager = class {
this._onSettingsWritableChanged.bind(this));
this._enabledExtensions = this._getEnabledExtensions();
+ this._requestedExtensions = this._getRequestedExtensions();
let perUserDir = Gio.File.new_for_path(global.userdatadir);
FileUtils.collectFromDatadirs('extensions', true, (dir, info) => {
@@ -512,8 +535,9 @@ var ExtensionManager = class {
// property; it might make sense to make enabledExtensions independent
// from allowExtensions in the future
if (Main.sessionMode.allowExtensions) {
- if (this._initted)
+ if (this._initted) {
this._enabledExtensions = this._getEnabledExtensions();
+ }
this._enableAllExtensions();
} else {
this._disableAllExtensions();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]