extensionPrefs: Add switches to enable/disable extensions
Bring the extension-prefs tool in line with the mockup by adding switches to enable/disable extensions, similar to the extension page in gnome-tweak-tool. https://bugzilla.gnome.org/show_bug.cgi?id=730829
This commit is contained in:
parent
e1b30b2924
commit
521f5f2b6b
@ -259,6 +259,12 @@ const ExtensionRow = new Lang.Class({
|
|||||||
|
|
||||||
this.uuid = uuid;
|
this.uuid = uuid;
|
||||||
|
|
||||||
|
this._settings = new Gio.Settings({ schema: 'org.gnome.shell' });
|
||||||
|
this._settings.connect('changed::enabled-extensions', Lang.bind(this,
|
||||||
|
function() {
|
||||||
|
this._switch.state = this._isEnabled();
|
||||||
|
}));
|
||||||
|
|
||||||
this._buildUI();
|
this._buildUI();
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -294,6 +300,44 @@ const ExtensionRow = new Lang.Class({
|
|||||||
hbox.add(button);
|
hbox.add(button);
|
||||||
|
|
||||||
this.prefsButton = button;
|
this.prefsButton = button;
|
||||||
|
|
||||||
|
this._switch = new Gtk.Switch({ valign: Gtk.Align.CENTER,
|
||||||
|
state: this._isEnabled() });
|
||||||
|
this._switch.connect('notify::active', Lang.bind(this,
|
||||||
|
function() {
|
||||||
|
if (this._switch.active)
|
||||||
|
this._enable();
|
||||||
|
else
|
||||||
|
this._disable();
|
||||||
|
}));
|
||||||
|
this._switch.connect('state-set', function() { return true; });
|
||||||
|
hbox.add(this._switch);
|
||||||
|
},
|
||||||
|
|
||||||
|
_isEnabled: function() {
|
||||||
|
let extensions = this._settings.get_strv('enabled-extensions');
|
||||||
|
return extensions.indexOf(this.uuid) != -1;
|
||||||
|
},
|
||||||
|
|
||||||
|
_enable: function() {
|
||||||
|
let extensions = this._settings.get_strv('enabled-extensions');
|
||||||
|
if (extensions.indexOf(this.uuid) != -1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
extensions.push(this.uuid);
|
||||||
|
this._settings.set_strv('enabled-extensions', extensions);
|
||||||
|
},
|
||||||
|
|
||||||
|
_disable: function() {
|
||||||
|
let extensions = this._settings.get_strv('enabled-extensions');
|
||||||
|
let pos = extensions.indexOf(this.uuid);
|
||||||
|
if (pos == -1)
|
||||||
|
return;
|
||||||
|
do {
|
||||||
|
extensions.splice(pos, 1);
|
||||||
|
pos = extensions.indexOf(this.uuid);
|
||||||
|
} while (pos != -1);
|
||||||
|
this._settings.set_strv('enabled-extensions', extensions);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user