summaryrefslogtreecommitdiff
path: root/0001-extensions-app-Add-compatibility-with-GNOME-3.34.patch
blob: 173bcf5102e59e0cf6ca39d1b145818eac1eefea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
From 42d5ff3ec2d18d7239eac8a6ce0544d4f69efab3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Florian=20M=C3=BCllner?= <fmuellner@gnome.org>
Date: Tue, 31 Mar 2020 19:53:50 +0200
Subject: [PATCH] extensions-app: Add compatibility with GNOME 3.34

We are currently relying on 3.36 changes:

 - the addition of the UserExtensionsEnabled property

 - the separate org.gnome.Shell.Extensions name to expose
   the interface

In order to work with the previous stable release as well, we can
fall back to connecting to gnome-shell itself and changing the
underlying GSettings directly.
---
 subprojects/extensions-app/data/meson.build   |  2 +
 .../data/org.gnome.Extensions.gschema.xml     | 12 +++++
 subprojects/extensions-app/js/main.js         | 47 +++++++++++++++----
 subprojects/extensions-app/meson.build        |  1 +
 4 files changed, 54 insertions(+), 8 deletions(-)
 create mode 100644 subprojects/extensions-app/data/org.gnome.Extensions.gschema.xml

diff --git a/subprojects/extensions-app/data/meson.build b/subprojects/extensions-app/data/meson.build
index 0568fafc8..e9399e3b6 100644
--- a/subprojects/extensions-app/data/meson.build
+++ b/subprojects/extensions-app/data/meson.build
@@ -33,5 +33,7 @@ configure_file(
   install_dir: servicedir,
 )
 
+install_data(app_id + '.gschema.xml', install_dir: schemadir)
+
 subdir('icons')
 subdir('metainfo')
diff --git a/subprojects/extensions-app/data/org.gnome.Extensions.gschema.xml b/subprojects/extensions-app/data/org.gnome.Extensions.gschema.xml
new file mode 100644
index 000000000..d70d4bd4c
--- /dev/null
+++ b/subprojects/extensions-app/data/org.gnome.Extensions.gschema.xml
@@ -0,0 +1,12 @@
+<schemalist>
+  <schema id="org.gnome.shell" path="/org/gnome/shell/">
+    <key name="disable-user-extensions" type="b">
+      <default>false</default>
+      <summary>Disable user extensions</summary>
+      <description>
+        Disable all extensions the user has enabled without affecting
+        the “enabled-extension” setting.
+      </description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/subprojects/extensions-app/js/main.js b/subprojects/extensions-app/js/main.js
index d25df9c57..f5ac2e564 100644
--- a/subprojects/extensions-app/js/main.js
+++ b/subprojects/extensions-app/js/main.js
@@ -47,6 +47,10 @@ class Application extends Gtk.Application {
         return this._shellProxy;
     }
 
+    get legacyMode() {
+        return this._legacyMode;
+    }
+
     vfunc_activate() {
         this._shellProxy.CheckForUpdatesRemote();
         this._window.present();
@@ -69,6 +73,13 @@ class Application extends Gtk.Application {
         this._shellProxy = new GnomeShellProxy(Gio.DBus.session,
             'org.gnome.Shell.Extensions', '/org/gnome/Shell/Extensions');
 
+        this._legacyMode = this._shellProxy.g_name_owner === null;
+
+        if (this._legacyMode) {
+            this._shellProxy = new GnomeShellProxy(Gio.DBus.session,
+                'org.gnome.Shell', '/org/gnome/Shell');
+        }
+
         this._window = new ExtensionsWindow({ application: this });
     }
 });
@@ -89,6 +100,10 @@ var ExtensionsWindow = GObject.registerClass({
     _init(params) {
         super._init(params);
 
+        this._settings = this.application.legacyMode
+            ? new Gio.Settings({ schema_id: 'org.gnome.shell' })
+            : null;
+
         this._updatesCheckId = 0;
 
         this._exporter = new Shew.WindowExporter({ window: this });
@@ -111,7 +126,12 @@ var ExtensionsWindow = GObject.registerClass({
         });
         action.connect('activate', toggleState);
         action.connect('change-state', (a, state) => {
-            this._shellProxy.UserExtensionsEnabled = state.get_boolean();
+            const value = state.get_boolean();
+
+            if (this._settings)
+                this._settings.set_boolean('disable-user-extensions', !value);
+            else
+                this._shellProxy.UserExtensionsEnabled = value;
         });
         this.add_action(action);
 
@@ -124,8 +144,13 @@ var ExtensionsWindow = GObject.registerClass({
         this._shellProxy.connectSignal('ExtensionStateChanged',
             this._onExtensionStateChanged.bind(this));
 
-        this._shellProxy.connect('g-properties-changed',
-            this._onUserExtensionsEnabledChanged.bind(this));
+        if (this._settings) {
+            this._settings.connect('changed::disable-user-extensions',
+                this._onUserExtensionsEnabledChanged.bind(this));
+        } else {
+            this._shellProxy.connect('g-properties-changed',
+                this._onUserExtensionsEnabledChanged.bind(this));
+        }
         this._onUserExtensionsEnabledChanged();
 
         this._scanExtensions();
@@ -166,9 +191,13 @@ var ExtensionsWindow = GObject.registerClass({
             }
         }
 
-        this._shellProxy.OpenExtensionPrefsRemote(uuid,
-            this._exportedHandle,
-            { modal: new GLib.Variant('b', true) });
+        if (this.application.legacyMode) {
+            this._shellProxy.LaunchExtensionPrefsRemote(uuid);
+        } else {
+            this._shellProxy.OpenExtensionPrefsRemote(uuid,
+                this._exportedHandle,
+                { modal: new GLib.Variant('b', true) });
+        }
     }
 
     _showAbout() {
@@ -228,8 +257,10 @@ var ExtensionsWindow = GObject.registerClass({
 
     _onUserExtensionsEnabledChanged() {
         let action = this.lookup_action('user-extensions-enabled');
-        action.set_state(
-            new GLib.Variant('b', this._shellProxy.UserExtensionsEnabled));
+        const newState = this._settings
+            ? !this._settings.get_boolean('disable-user-extensions')
+            : this._shellProxy.UserExtensionsEnabled;
+        action.set_state(new GLib.Variant('b', newState));
     }
 
     _onExtensionStateChanged(proxy, senderName, [uuid, newState]) {
diff --git a/subprojects/extensions-app/meson.build b/subprojects/extensions-app/meson.build
index 88536236a..ebf3da942 100644
--- a/subprojects/extensions-app/meson.build
+++ b/subprojects/extensions-app/meson.build
@@ -34,6 +34,7 @@ icondir = join_paths(datadir, 'icons')
 localedir = join_paths(datadir, 'locale')
 metainfodir = join_paths(datadir, 'metainfo')
 servicedir = join_paths(datadir, 'dbus-1', 'services')
+schemadir = join_paths(datadir, 'glib-2.0', 'schemas')
 
 gjs = find_program('gjs')
 appstream_util = find_program('appstream-util', required: false)
-- 
2.25.1