[gnome-shell] extensionPrefs: Hook up kill switch to D-Bus property
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] extensionPrefs: Hook up kill switch to D-Bus property
- Date: Thu, 19 Mar 2020 14:35:20 +0000 (UTC)
commit 5c031200ce83034bb6060c4b5f6b5286e1df53e8
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Mar 5 18:46:18 2020 +0100
extensionPrefs: Hook up kill switch to D-Bus property
Now that the org.gnome.Shell.Extensions interface exposes the
disable-user-extensions setting on D-Bus, we can use that instead
of the shell's GSettings.
In a future where we distribute the app separately as flatpak, this
will require one less hole in the sandbox.
https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1081
js/extensionPrefs/data/ui/extensions-window.ui | 3 ++-
js/extensionPrefs/js/main.js | 34 +++++++++++++++++++-------
2 files changed, 27 insertions(+), 10 deletions(-)
---
diff --git a/js/extensionPrefs/data/ui/extensions-window.ui b/js/extensionPrefs/data/ui/extensions-window.ui
index c88375b1bd..619582355a 100644
--- a/js/extensionPrefs/data/ui/extensions-window.ui
+++ b/js/extensionPrefs/data/ui/extensions-window.ui
@@ -90,8 +90,9 @@
</packing>
</child>
<child>
- <object class="GtkSwitch" id="killSwitch">
+ <object class="GtkSwitch">
<property name="visible">True</property>
+ <property name="action-name">win.user-extensions-enabled</property>
</object>
<packing>
<property name="pack_type">end</property>
diff --git a/js/extensionPrefs/js/main.js b/js/extensionPrefs/js/main.js
index e4e2328c61..aa325ea92e 100644
--- a/js/extensionPrefs/js/main.js
+++ b/js/extensionPrefs/js/main.js
@@ -36,6 +36,11 @@ function stripPrefix(string, prefix) {
return string;
}
+function toggleState(action) {
+ let state = action.get_state();
+ action.change_state(new GLib.Variant('b', !state.get_boolean()));
+}
+
var Application = GObject.registerClass(
class Application extends Gtk.Application {
_init() {
@@ -94,7 +99,6 @@ var ExtensionsWindow = GObject.registerClass({
InternalChildren: [
'userList',
'systemList',
- 'killSwitch',
'mainBox',
'mainStack',
'scrolledWindow',
@@ -121,10 +125,15 @@ var ExtensionsWindow = GObject.registerClass({
action.connect('activate', this._logout.bind(this));
this.add_action(action);
- this._settings = new Gio.Settings({ schema_id: 'org.gnome.shell' });
- this._settings.bind('disable-user-extensions',
- this._killSwitch, 'active',
- Gio.SettingsBindFlags.DEFAULT | Gio.SettingsBindFlags.INVERT_BOOLEAN);
+ action = new Gio.SimpleAction({
+ name: 'user-extensions-enabled',
+ state: new GLib.Variant('b', false),
+ });
+ action.connect('activate', toggleState);
+ action.connect('change-state', (a, state) => {
+ this._shellProxy.UserExtensionsEnabled = state.get_boolean();
+ });
+ this.add_action(action);
this._userList.set_sort_func(this._sortList.bind(this));
this._userList.set_header_func(this._updateHeader.bind(this));
@@ -135,6 +144,10 @@ var ExtensionsWindow = GObject.registerClass({
this._shellProxy.connectSignal('ExtensionStateChanged',
this._onExtensionStateChanged.bind(this));
+ this._shellProxy.connect('g-properties-changed',
+ this._onUserExtensionsEnabledChanged.bind(this));
+ this._onUserExtensionsEnabledChanged();
+
this._scanExtensions();
}
@@ -388,6 +401,12 @@ var ExtensionsWindow = GObject.registerClass({
].find(c => c.uuid === uuid);
}
+ _onUserExtensionsEnabledChanged() {
+ let action = this.lookup_action('user-extensions-enabled');
+ action.set_state(
+ new GLib.Variant('b', this._shellProxy.UserExtensionsEnabled));
+ }
+
_onExtensionStateChanged(proxy, senderName, [uuid, newState]) {
let extension = ExtensionUtils.deserializeExtension(newState);
let row = this._findExtensionRow(uuid);
@@ -632,10 +651,7 @@ var ExtensionRow = GObject.registerClass({
name: 'enabled',
state: new GLib.Variant('b', false),
});
- action.connect('activate', () => {
- let state = action.get_state();
- action.change_state(new GLib.Variant('b', !state.get_boolean()));
- });
+ action.connect('activate', toggleState);
action.connect('change-state', (a, state) => {
if (state.get_boolean())
this._app.shellProxy.EnableExtensionRemote(this.uuid);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]