[gnome-shell/benzea/systemd-user-units: 22/28] extensionPrefs: Allow disabling extensions when globally disabled
- From: Benjamin Berg <bberg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/benzea/systemd-user-units: 22/28] extensionPrefs: Allow disabling extensions when globally disabled
- Date: Fri, 10 May 2019 14:46:23 +0000 (UTC)
commit 518c83c1b42f06d76b2e8bd6c04881300ab99274
Author: Benjamin Berg <bberg redhat com>
Date: Mon Apr 15 11:59:27 2019 +0200
extensionPrefs: Allow disabling extensions when globally disabled
If we disabled extensions because one of them caused a gnome-shell
crash, then the user will be presented with the dialog. In this case the
user should be able to disable the problematic extensions before
enabling extensions again globally.
Change the logic so that the switches are sensitive and also show the
correct configuration state and whether the extension is indeed active.
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/507
js/extensionPrefs/main.js | 39 +++++++++++++++++++++++++--------------
1 file changed, 25 insertions(+), 14 deletions(-)
---
diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js
index 43efa95e9..acd4c8afb 100644
--- a/js/extensionPrefs/main.js
+++ b/js/extensionPrefs/main.js
@@ -510,21 +510,26 @@ class ExtensionRow extends Gtk.ListBoxRow {
this.uuid = uuid;
this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell' });
- this._settings.connect('changed::enabled-extensions', () => {
- this._switch.state = this._isEnabled();
- });
+ this._settings.connect('changed::enabled-extensions',
+ this._updateSwitch.bind(this));
this._settings.connect('changed::disable-extension-version-validation',
- () => {
- this._switch.sensitive = this._canEnable();
- });
+ this._updateSwitch.bind(this));
this._settings.connect('changed::disable-user-extensions',
- () => {
- this._switch.sensitive = this._canEnable();
- });
+ this._updateSwitch.bind(this));
this._buildUI();
}
+ _updateSwitch() {
+ this._switch.freeze_notify();
+ this._switch.set({
+ state: this._isInUse(),
+ active: this._isEnabled(),
+ sensitive: this._canEnable()
+ });
+ this._switch.thaw_notify();
+ }
+
_buildUI() {
let extension = ExtensionUtils.extensions[this.uuid];
@@ -559,9 +564,8 @@ class ExtensionRow extends Gtk.ListBoxRow {
this.prefsButton = button;
- this._switch = new Gtk.Switch({ valign: Gtk.Align.CENTER,
- sensitive: this._canEnable(),
- state: this._isEnabled() });
+ this._switch = new Gtk.Switch({ valign: Gtk.Align.CENTER });
+ this._updateSwitch();
this._switch.connect('notify::active', () => {
if (this._switch.active)
this._enable();
@@ -576,8 +580,7 @@ class ExtensionRow extends Gtk.ListBoxRow {
let extension = ExtensionUtils.extensions[this.uuid];
let checkVersion = !this._settings.get_boolean('disable-extension-version-validation');
- return !this._settings.get_boolean('disable-user-extensions') &&
- !(checkVersion && ExtensionUtils.isOutOfDate(extension));
+ return !(checkVersion && ExtensionUtils.isOutOfDate(extension));
}
_isEnabled() {
@@ -585,6 +588,14 @@ class ExtensionRow extends Gtk.ListBoxRow {
return extensions.indexOf(this.uuid) != -1;
}
+ _canLoad() {
+ return this._canEnable() && !this._settings.get_boolean('disable-user-extensions');
+ }
+
+ _isInUse() {
+ return this._isEnabled() && this._canLoad();
+ }
+
_enable() {
let extensions = this._settings.get_strv('enabled-extensions');
if (extensions.indexOf(this.uuid) != -1)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]