[gnome-shell/benzea/systemd-user-units: 1/7] 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: 1/7] extensionPrefs: Allow disabling extensions when globally disabled
- Date: Fri, 26 Apr 2019 10:07:20 +0000 (UTC)
commit 28b89354ef9c137003dad465c8f9d6a752733bc1
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 | 37 +++++++++++++++++++++++--------------
1 file changed, 23 insertions(+), 14 deletions(-)
---
diff --git a/js/extensionPrefs/main.js b/js/extensionPrefs/main.js
index 43efa95e9..4bf098565 100644
--- a/js/extensionPrefs/main.js
+++ b/js/extensionPrefs/main.js
@@ -510,21 +510,24 @@ 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.state = this._isLoaded();
+ this._switch.active = this._isEnabled();
+ this._switch.thaw_notify();
+ this._switch.sensitive = this._canEnable();
+ }
+
_buildUI() {
let extension = ExtensionUtils.extensions[this.uuid];
@@ -559,9 +562,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 +578,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 +586,14 @@ class ExtensionRow extends Gtk.ListBoxRow {
return extensions.indexOf(this.uuid) != -1;
}
+ _canLoad() {
+ return this._canEnable() && !this._settings.get_boolean('disable-user-extensions');
+ }
+
+ _isLoaded() {
+ 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]