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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2837>
This commit is contained in:
Florian Müllner 2023-07-09 12:47:05 +02:00
parent 3006c05ea5
commit 1354d2cf56
4 changed files with 8 additions and 9 deletions

View File

@ -5,7 +5,6 @@ import Shew from 'gi://Shew';
import {ExtensionPrefsDialog} from './extensionPrefsDialog.js'; import {ExtensionPrefsDialog} from './extensionPrefsDialog.js';
import {ServiceImplementation} from './dbusService.js'; import {ServiceImplementation} from './dbusService.js';
import {setExtensionManager} from './extensions/sharedInternals.js';
const {deserializeExtension} = imports.misc.extensionUtils; const {deserializeExtension} = imports.misc.extensionUtils;
const {loadInterfaceXML} = imports.misc.dbusUtils; const {loadInterfaceXML} = imports.misc.dbusUtils;
@ -27,8 +26,7 @@ class ExtensionManager {
} }
} }
const extensionManager = new ExtensionManager(); export const extensionManager = new ExtensionManager();
setExtensionManager(extensionManager);
export const ExtensionsService = class extends ServiceImplementation { export const ExtensionsService = class extends ServiceImplementation {
constructor() { constructor() {

View File

@ -1,4 +1,4 @@
import {getCurrentExtension} from './sharedInternals.js'; import {getCurrentExtension, setExtensionManager} from './sharedInternals.js';
export { export {
getSettings, getSettings,
@ -9,6 +9,7 @@ export {
} from './sharedInternals.js'; } from './sharedInternals.js';
const {extensionManager} = imports.ui.main; const {extensionManager} = imports.ui.main;
setExtensionManager(extensionManager);
/** /**
* Open the preference dialog of the current extension * Open the preference dialog of the current extension

View File

@ -1,3 +1,8 @@
import {setExtensionManager} from './sharedInternals.js';
import {extensionManager} from '../extensionsService.js';
setExtensionManager(extensionManager);
export { export {
getSettings, getSettings,
initTranslations, initTranslations,

View File

@ -35,11 +35,6 @@ export function getCurrentExtension() {
if (!extensionLine) if (!extensionLine)
return null; 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 // The exact stack line differs depending on where the function
// was called (function or module scope), and whether it's called // was called (function or module scope), and whether it's called
// from a module or legacy import (file:// URI vs. plain path). // from a module or legacy import (file:// URI vs. plain path).