extensions: Simplify openPrefs()

The module is now only used inside the gnome-shell process, so
we don't have to handle the case where it is used from prefs,
and we can use regular imports for shell modules.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2837>
This commit is contained in:
Florian Müllner 2023-07-10 05:12:30 +02:00
parent 6a46d338e7
commit 3006c05ea5

View File

@ -8,6 +8,8 @@ export {
pgettext
} from './sharedInternals.js';
const {extensionManager} = imports.ui.main;
/**
* Open the preference dialog of the current extension
*/
@ -17,12 +19,5 @@ export function openPrefs() {
if (!extension)
throw new Error('openPrefs() can only be called from extensions');
try {
const extensionManager = imports.ui.main.extensionManager;
extensionManager.openExtensionPrefs(extension.uuid, '', {});
} catch (e) {
if (e.name === 'ImportError')
throw new Error('openPrefs() cannot be called from preferences');
logError(e, 'Failed to open extension preferences');
}
extensionManager.openExtensionPrefs(extension.uuid, '', {});
}