From 4340260c49b577e81c8b9ef914180ee4e46c5775 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sat, 7 Mar 2020 19:26:06 +0100 Subject: [PATCH] extensionPrefs: Load D-Bus interface from own resource Using the "regular" loadInterfaceXML() helper means less code duplication, but it also ties us to the resource used by gnome-shell. In order to untangle the extension app from core gnome-shell, change that to load the interface from the existing data resource instead. While that does involve reimplementing loadInterfaceXML(), it's not too bad actually with the resource-loading code stripped (as the data resource is already loaded by the package module). https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1081 --- .../org.gnome.Shell.Extensions.xml | 1 + .../data/org.gnome.Extensions.data.gresource.xml | 2 ++ js/extensionPrefs/js/main.js | 15 ++++++++++++++- .../js/org.gnome.Extensions.src.gresource.xml | 1 - 4 files changed, 17 insertions(+), 2 deletions(-) create mode 120000 js/extensionPrefs/data/dbus-interfaces/org.gnome.Shell.Extensions.xml diff --git a/js/extensionPrefs/data/dbus-interfaces/org.gnome.Shell.Extensions.xml b/js/extensionPrefs/data/dbus-interfaces/org.gnome.Shell.Extensions.xml new file mode 120000 index 000000000..defde797b --- /dev/null +++ b/js/extensionPrefs/data/dbus-interfaces/org.gnome.Shell.Extensions.xml @@ -0,0 +1 @@ +../../../../data/dbus-interfaces/org.gnome.Shell.Extensions.xml \ No newline at end of file diff --git a/js/extensionPrefs/data/org.gnome.Extensions.data.gresource.xml b/js/extensionPrefs/data/org.gnome.Extensions.data.gresource.xml index f6fc66b72..659c03ffc 100644 --- a/js/extensionPrefs/data/org.gnome.Extensions.data.gresource.xml +++ b/js/extensionPrefs/data/org.gnome.Extensions.data.gresource.xml @@ -3,6 +3,8 @@ css/application.css + dbus-interfaces/org.gnome.Shell.Extensions.xml + ui/extension-row.ui ui/extensions-window.ui diff --git a/js/extensionPrefs/js/main.js b/js/extensionPrefs/js/main.js index 936598c05..e4e2328c6 100644 --- a/js/extensionPrefs/js/main.js +++ b/js/extensionPrefs/js/main.js @@ -10,13 +10,26 @@ const { Gdk, GLib, Gio, GObject, Gtk } = imports.gi; const _ = Gettext.gettext; const ExtensionUtils = imports.misc.extensionUtils; -const { loadInterfaceXML } = imports.misc.fileUtils; const { ExtensionState, ExtensionType } = ExtensionUtils; const GnomeShellIface = loadInterfaceXML('org.gnome.Shell.Extensions'); const GnomeShellProxy = Gio.DBusProxy.makeProxyWrapper(GnomeShellIface); +function loadInterfaceXML(iface) { + const uri = 'resource:///org/gnome/Extensions/dbus-interfaces/%s.xml'.format(iface); + const f = Gio.File.new_for_uri(uri); + + try { + let [ok_, bytes] = f.load_contents(null); + return imports.byteArray.toString(bytes); + } catch (e) { + log('Failed to load D-Bus interface %s'.format(iface)); + } + + return null; +} + function stripPrefix(string, prefix) { if (string.slice(0, prefix.length) == prefix) return string.slice(prefix.length); diff --git a/js/extensionPrefs/js/org.gnome.Extensions.src.gresource.xml b/js/extensionPrefs/js/org.gnome.Extensions.src.gresource.xml index 9b0fa09ac..8cda0f91a 100644 --- a/js/extensionPrefs/js/org.gnome.Extensions.src.gresource.xml +++ b/js/extensionPrefs/js/org.gnome.Extensions.src.gresource.xml @@ -5,6 +5,5 @@ misc/config.js misc/extensionUtils.js - misc/fileUtils.js