dbusServices/extensions: Don't use getCurrentExtension()

The prefs dialog is created on behalf of a particular extension.
It's a bit silly to rely on getCurrentExtension() to access it,
instead of just keeping track of it ourselves.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2832>
This commit is contained in:
Florian Müllner 2023-07-09 12:47:05 +02:00 committed by Marge Bot
parent b4c2901e47
commit 9e4de6a005

View File

@ -18,20 +18,24 @@ export const ExtensionPrefsDialog = GObject.registerClass({
search_enabled: false, search_enabled: false,
}); });
this._loadPrefs(extension).catch(e => { this._extension = extension;
this._loadPrefs().catch(e => {
this._showErrorPage(e); this._showErrorPage(e);
logError(e, 'Failed to open preferences'); logError(e, 'Failed to open preferences');
}); });
} }
async _loadPrefs(extension) { async _loadPrefs() {
// give extension prefs access to their own extension object // give extension prefs access to their own extension object
ExtensionUtils.setCurrentExtension(extension); ExtensionUtils.setCurrentExtension(this._extension);
const prefsJs = extension.dir.get_child('prefs.js'); const {dir, metadata} = this._extension;
const prefsJs = dir.get_child('prefs.js');
const prefsModule = await import(prefsJs.get_uri()); const prefsModule = await import(prefsJs.get_uri());
const prefsObj = new prefsModule.default(extension.metadata); const prefsObj = new prefsModule.default(metadata);
prefsObj.fillPreferencesWindow(this); prefsObj.fillPreferencesWindow(this);
if (!this.visible_page) if (!this.visible_page)
@ -56,8 +60,7 @@ export const ExtensionPrefsDialog = GObject.registerClass({
while (this.visible_page) while (this.visible_page)
this.remove(this.visible_page); this.remove(this.visible_page);
const extension = ExtensionUtils.getCurrentExtension(); this.add(new ExtensionPrefsErrorPage(this._extension, e));
this.add(new ExtensionPrefsErrorPage(extension, e));
} }
}); });