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
This commit is contained in:
parent
96e534796f
commit
4340260c49
@ -0,0 +1 @@
|
||||
../../../../data/dbus-interfaces/org.gnome.Shell.Extensions.xml
|
@ -3,6 +3,8 @@
|
||||
<gresource prefix="/org/gnome/Extensions">
|
||||
<file>css/application.css</file>
|
||||
|
||||
<file>dbus-interfaces/org.gnome.Shell.Extensions.xml</file>
|
||||
|
||||
<file>ui/extension-row.ui</file>
|
||||
<file>ui/extensions-window.ui</file>
|
||||
</gresource>
|
||||
|
@ -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);
|
||||
|
@ -5,6 +5,5 @@
|
||||
|
||||
<file>misc/config.js</file>
|
||||
<file>misc/extensionUtils.js</file>
|
||||
<file>misc/fileUtils.js</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
|
Loading…
Reference in New Issue
Block a user