From 477011a364c29c9e235212a2547b71f8e23a0f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Mon, 7 Aug 2023 17:13:48 +0200 Subject: [PATCH] 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: --- js/dbusServices/extensions/extensionsService.js | 2 +- js/dbusServices/notifications/notificationDaemon.js | 2 +- js/dbusServices/screencast/screencastService.js | 2 +- js/dbusServices/screensaver/screenSaverService.js | 2 +- js/misc/.eslintrc.yml | 5 ----- js/misc/dbusUtils.js | 9 ++++----- js/misc/fileUtils.js | 2 +- js/ui/status/backgroundApps.js | 2 +- 8 files changed, 10 insertions(+), 16 deletions(-) delete mode 100644 js/misc/.eslintrc.yml diff --git a/js/dbusServices/extensions/extensionsService.js b/js/dbusServices/extensions/extensionsService.js index 180696458..0d60fb60e 100644 --- a/js/dbusServices/extensions/extensionsService.js +++ b/js/dbusServices/extensions/extensionsService.js @@ -7,7 +7,7 @@ import {ExtensionPrefsDialog} from './extensionPrefsDialog.js'; import {ServiceImplementation} from './dbusService.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 ExtensionsProxy = Gio.DBusProxy.makeProxyWrapper(ExtensionsIface); diff --git a/js/dbusServices/notifications/notificationDaemon.js b/js/dbusServices/notifications/notificationDaemon.js index 7bb5b7bf0..f824f813d 100644 --- a/js/dbusServices/notifications/notificationDaemon.js +++ b/js/dbusServices/notifications/notificationDaemon.js @@ -4,7 +4,7 @@ import GLib from 'gi://GLib'; import {ServiceImplementation} from './dbusService.js'; -const {loadInterfaceXML} = imports.misc.dbusUtils; +import {loadInterfaceXML} from './misc/dbusUtils.js'; const NotificationsIface = loadInterfaceXML('org.freedesktop.Notifications'); const NotificationsProxy = Gio.DBusProxy.makeProxyWrapper(NotificationsIface); diff --git a/js/dbusServices/screencast/screencastService.js b/js/dbusServices/screencast/screencastService.js index 60b0afd08..9c69af9cf 100644 --- a/js/dbusServices/screencast/screencastService.js +++ b/js/dbusServices/screencast/screencastService.js @@ -6,7 +6,7 @@ import Gtk from 'gi://Gtk?version=4.0'; 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'; const ScreencastIface = loadInterfaceXML('org.gnome.Shell.Screencast'); diff --git a/js/dbusServices/screensaver/screenSaverService.js b/js/dbusServices/screensaver/screenSaverService.js index d0f0db6e3..5771b7065 100644 --- a/js/dbusServices/screensaver/screenSaverService.js +++ b/js/dbusServices/screensaver/screenSaverService.js @@ -4,7 +4,7 @@ import GLib from 'gi://GLib'; import {ServiceImplementation} from './dbusService.js'; -const {loadInterfaceXML} = imports.misc.dbusUtils; +import {loadInterfaceXML} from './misc/dbusUtils.js'; const ScreenSaverIface = loadInterfaceXML('org.gnome.ScreenSaver'); const ScreenSaverProxy = Gio.DBusProxy.makeProxyWrapper(ScreenSaverIface); diff --git a/js/misc/.eslintrc.yml b/js/misc/.eslintrc.yml deleted file mode 100644 index 4526a5cf4..000000000 --- a/js/misc/.eslintrc.yml +++ /dev/null @@ -1,5 +0,0 @@ -overrides: - - files: - - dbusUtils.js - parserOptions: - sourceType: script \ No newline at end of file diff --git a/js/misc/dbusUtils.js b/js/misc/dbusUtils.js index 686c63f20..ae7e2c952 100644 --- a/js/misc/dbusUtils.js +++ b/js/misc/dbusUtils.js @@ -1,8 +1,7 @@ -/* exported loadInterfaceXML, loadSubInterfaceXML */ +import Gio from 'gi://Gio'; +import GLib from 'gi://GLib'; const Config = imports.misc.config; -const Gio = imports.gi.Gio; -const GLib = imports.gi.GLib; let _ifaceResource = null; @@ -24,7 +23,7 @@ function _ensureIfaceResource() { * @param {string} iface the interface name * @returns {string | null} the XML string or null if it is not found */ -function loadInterfaceXML(iface) { +export function loadInterfaceXML(iface) { _ensureIfaceResource(); let uri = `resource:///org/gnome/shell/dbus-interfaces/${iface}.xml`; @@ -45,7 +44,7 @@ function loadInterfaceXML(iface) { * @param {string} ifaceFile the interface filename * @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); if (!xml) return null; diff --git a/js/misc/fileUtils.js b/js/misc/fileUtils.js index b5e355bbe..a885a08ef 100644 --- a/js/misc/fileUtils.js +++ b/js/misc/fileUtils.js @@ -3,7 +3,7 @@ import GLib from 'gi://GLib'; import Gio from 'gi://Gio'; -export const {loadInterfaceXML} = imports.misc.dbusUtils; +export {loadInterfaceXML} from './dbusUtils.js'; /** * @typedef {object} SubdirInfo diff --git a/js/ui/status/backgroundApps.js b/js/ui/status/backgroundApps.js index c2d84424a..ad7ea7d65 100644 --- a/js/ui/status/backgroundApps.js +++ b/js/ui/status/backgroundApps.js @@ -11,7 +11,7 @@ import * as Util from '../../misc/util.js'; import {Spinner} from '../animation.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_OBJECT_PATH = '/org/freedesktop/background/monitor';