From 3a39fb5ab889972e822c0a8101f5b5298483425a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Thu, 5 Mar 2020 18:15:37 +0100 Subject: [PATCH] shellDBus: Add UserExtensionsEnabled property The 'disable-user-extensions' GSettings key is the last extensions-related setting that isn't exposed over D-Bus, and therefore requires consumers to access the GSettings directly. Expose the setting as UserExtensionsEnabled readwrite property in the org.gnome.Shell.Extensions interface to allow consumers to manage extensions purely via D-Bus. The 'disable-user-extensions' setting is the last extension-related bit from the org.gnome.shell GSettings schema that is not exposed via D-Bus. https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1074 --- .../org.gnome.Shell.Extensions.xml | 6 ++++++ js/ui/shellDBus.js | 19 +++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/data/dbus-interfaces/org.gnome.Shell.Extensions.xml b/data/dbus-interfaces/org.gnome.Shell.Extensions.xml index 61c898e3d..eb7be8f1a 100644 --- a/data/dbus-interfaces/org.gnome.Shell.Extensions.xml +++ b/data/dbus-interfaces/org.gnome.Shell.Extensions.xml @@ -234,5 +234,11 @@ --> + + + diff --git a/js/ui/shellDBus.js b/js/ui/shellDBus.js index 05b7aca60..691019b42 100644 --- a/js/ui/shellDBus.js +++ b/js/ui/shellDBus.js @@ -255,6 +255,17 @@ var GnomeShellExtensions = class { constructor() { this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GnomeShellExtensionsIface, this); this._dbusImpl.export(Gio.DBus.session, '/org/gnome/Shell'); + + this._userExtensionsEnabled = this.UserExtensionsEnabled; + global.settings.connect('changed::disable-user-extensions', () => { + if (this._userExtensionsEnabled === this.UserExtensionsEnabled) + return; + + this._userExtensionsEnabled = this.UserExtensionsEnabled; + this._dbusImpl.emit_property_changed('UserExtensionsEnabled', + new GLib.Variant('b', this._userExtensionsEnabled)); + }); + Main.extensionManager.connect('extension-state-changed', this._extensionStateChanged.bind(this)); } @@ -325,6 +336,14 @@ var GnomeShellExtensions = class { return Config.PACKAGE_VERSION; } + get UserExtensionsEnabled() { + return !global.settings.get_boolean('disable-user-extensions'); + } + + set UserExtensionsEnabled(enable) { + global.settings.set_boolean('disable-user-extensions', !enable); + } + _extensionStateChanged(_, newState) { let state = ExtensionUtils.serializeExtension(newState); this._dbusImpl.emit_signal('ExtensionStateChanged',