From 1354d2cf56d172ceeb45221d2812e42912bc9b4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sun, 9 Jul 2023 12:47:05 +0200 Subject: [PATCH] extensions: Unify how manager is injected into shared module We unified most code paths earlier, but the common code will still import Main locally if no extension manager was injected before. Now that the old extensionUtils was split between extension and preferences, each of those modules can simply import the manager from its corresponding environment, and then inject it into the shared module. Part-of: --- js/dbusServices/extensions/extensionsService.js | 4 +--- js/extensions/extension.js | 3 ++- js/extensions/prefs.js | 5 +++++ js/extensions/sharedInternals.js | 5 ----- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/js/dbusServices/extensions/extensionsService.js b/js/dbusServices/extensions/extensionsService.js index f0c93f6cb..b8e571bf9 100644 --- a/js/dbusServices/extensions/extensionsService.js +++ b/js/dbusServices/extensions/extensionsService.js @@ -5,7 +5,6 @@ import Shew from 'gi://Shew'; import {ExtensionPrefsDialog} from './extensionPrefsDialog.js'; import {ServiceImplementation} from './dbusService.js'; -import {setExtensionManager} from './extensions/sharedInternals.js'; const {deserializeExtension} = imports.misc.extensionUtils; const {loadInterfaceXML} = imports.misc.dbusUtils; @@ -27,8 +26,7 @@ class ExtensionManager { } } -const extensionManager = new ExtensionManager(); -setExtensionManager(extensionManager); +export const extensionManager = new ExtensionManager(); export const ExtensionsService = class extends ServiceImplementation { constructor() { diff --git a/js/extensions/extension.js b/js/extensions/extension.js index b9e72584a..a2c383e00 100644 --- a/js/extensions/extension.js +++ b/js/extensions/extension.js @@ -1,4 +1,4 @@ -import {getCurrentExtension} from './sharedInternals.js'; +import {getCurrentExtension, setExtensionManager} from './sharedInternals.js'; export { getSettings, @@ -9,6 +9,7 @@ export { } from './sharedInternals.js'; const {extensionManager} = imports.ui.main; +setExtensionManager(extensionManager); /** * Open the preference dialog of the current extension diff --git a/js/extensions/prefs.js b/js/extensions/prefs.js index 405b8614e..61488e09d 100644 --- a/js/extensions/prefs.js +++ b/js/extensions/prefs.js @@ -1,3 +1,8 @@ +import {setExtensionManager} from './sharedInternals.js'; +import {extensionManager} from '../extensionsService.js'; + +setExtensionManager(extensionManager); + export { getSettings, initTranslations, diff --git a/js/extensions/sharedInternals.js b/js/extensions/sharedInternals.js index c2133936c..c8a02471d 100644 --- a/js/extensions/sharedInternals.js +++ b/js/extensions/sharedInternals.js @@ -35,11 +35,6 @@ export function getCurrentExtension() { if (!extensionLine) return null; - // local import, as the module is used from outside the gnome-shell process - // as well - if (!_extensionManager) - setExtensionManager(imports.ui.main.extensionManager); - // The exact stack line differs depending on where the function // was called (function or module scope), and whether it's called // from a module or legacy import (file:// URI vs. plain path).