js: Port dbusUtils to ESM

The module is shared between the various D-Bus services and the
main gnome-shell process, so it was originally left out to allow
porting different bits at their own speed.

Now that everything has been ported to ESM, there is no reason
to not move that particular module as well.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2868>
This commit is contained in:
Florian Müllner 2023-08-07 17:13:48 +02:00 committed by Marge Bot
parent 3f80470e26
commit 477011a364
8 changed files with 10 additions and 16 deletions

View File

@ -7,7 +7,7 @@ import {ExtensionPrefsDialog} from './extensionPrefsDialog.js';
import {ServiceImplementation} from './dbusService.js'; import {ServiceImplementation} from './dbusService.js';
import {deserializeExtension} from './misc/extensionUtils.js'; import {deserializeExtension} from './misc/extensionUtils.js';
const {loadInterfaceXML} = imports.misc.dbusUtils; import {loadInterfaceXML} from './misc/dbusUtils.js';
const ExtensionsIface = loadInterfaceXML('org.gnome.Shell.Extensions'); const ExtensionsIface = loadInterfaceXML('org.gnome.Shell.Extensions');
const ExtensionsProxy = Gio.DBusProxy.makeProxyWrapper(ExtensionsIface); const ExtensionsProxy = Gio.DBusProxy.makeProxyWrapper(ExtensionsIface);

View File

@ -4,7 +4,7 @@ import GLib from 'gi://GLib';
import {ServiceImplementation} from './dbusService.js'; import {ServiceImplementation} from './dbusService.js';
const {loadInterfaceXML} = imports.misc.dbusUtils; import {loadInterfaceXML} from './misc/dbusUtils.js';
const NotificationsIface = loadInterfaceXML('org.freedesktop.Notifications'); const NotificationsIface = loadInterfaceXML('org.freedesktop.Notifications');
const NotificationsProxy = Gio.DBusProxy.makeProxyWrapper(NotificationsIface); const NotificationsProxy = Gio.DBusProxy.makeProxyWrapper(NotificationsIface);

View File

@ -6,7 +6,7 @@ import Gtk from 'gi://Gtk?version=4.0';
import {ServiceImplementation} from './dbusService.js'; import {ServiceImplementation} from './dbusService.js';
const {loadInterfaceXML, loadSubInterfaceXML} = imports.misc.dbusUtils; import {loadInterfaceXML, loadSubInterfaceXML} from './misc/dbusUtils.js';
import * as Signals from './misc/signals.js'; import * as Signals from './misc/signals.js';
const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast'); const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast');

View File

@ -4,7 +4,7 @@ import GLib from 'gi://GLib';
import {ServiceImplementation} from './dbusService.js'; import {ServiceImplementation} from './dbusService.js';
const {loadInterfaceXML} = imports.misc.dbusUtils; import {loadInterfaceXML} from './misc/dbusUtils.js';
const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver'); const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver');
const ScreenSaverProxy = Gio.DBusProxy.makeProxyWrapper(ScreenSaverIface); const ScreenSaverProxy = Gio.DBusProxy.makeProxyWrapper(ScreenSaverIface);

View File

@ -1,5 +0,0 @@
overrides:
- files:
- dbusUtils.js
parserOptions:
sourceType: script

View File

@ -1,8 +1,7 @@
/* exported loadInterfaceXML, loadSubInterfaceXML */ import Gio from 'gi://Gio';
import GLib from 'gi://GLib';
const Config = imports.misc.config; const Config = imports.misc.config;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
let _ifaceResource = null; let _ifaceResource = null;
@ -24,7 +23,7 @@ function _ensureIfaceResource() {
* @param {string} iface the interface name * @param {string} iface the interface name
* @returns {string | null} the XML string or null if it is not found * @returns {string | null} the XML string or null if it is not found
*/ */
function loadInterfaceXML(iface) { export function loadInterfaceXML(iface) {
_ensureIfaceResource(); _ensureIfaceResource();
let uri = `resource:///org/gnome/shell/dbus-interfaces/${iface}.xml`; let uri = `resource:///org/gnome/shell/dbus-interfaces/${iface}.xml`;
@ -45,7 +44,7 @@ function loadInterfaceXML(iface) {
* @param {string} ifaceFile the interface filename * @param {string} ifaceFile the interface filename
* @returns {string | null} the XML string or null if it is not found * @returns {string | null} the XML string or null if it is not found
*/ */
function loadSubInterfaceXML(iface, ifaceFile) { export function loadSubInterfaceXML(iface, ifaceFile) {
let xml = loadInterfaceXML(ifaceFile); let xml = loadInterfaceXML(ifaceFile);
if (!xml) if (!xml)
return null; return null;

View File

@ -3,7 +3,7 @@
import GLib from 'gi://GLib'; import GLib from 'gi://GLib';
import Gio from 'gi://Gio'; import Gio from 'gi://Gio';
export const {loadInterfaceXML} = imports.misc.dbusUtils; export {loadInterfaceXML} from './dbusUtils.js';
/** /**
* @typedef {object} SubdirInfo * @typedef {object} SubdirInfo

View File

@ -11,7 +11,7 @@ import * as Util from '../../misc/util.js';
import {Spinner} from '../animation.js'; import {Spinner} from '../animation.js';
import {QuickToggle, SystemIndicator} from '../quickSettings.js'; import {QuickToggle, SystemIndicator} from '../quickSettings.js';
const {loadInterfaceXML} = imports.misc.dbusUtils; import {loadInterfaceXML} from '../../misc/dbusUtils.js';
const DBUS_NAME = 'org.freedesktop.background.Monitor'; const DBUS_NAME = 'org.freedesktop.background.Monitor';
const DBUS_OBJECT_PATH = '/org/freedesktop/background/monitor'; const DBUS_OBJECT_PATH = '/org/freedesktop/background/monitor';