dbusServices/extensions: Give extensions access to the prefs window

The current preference API - buildPrefsWidget() - predates client-side
decorations. While extension authors have been finding ways around
the limitation of not having access to the window/titlebar, the change
to the new Adwaita API seems like a good time for an updated API that
officially provides that access (as far as allowed by libadwaita).

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2012>
This commit is contained in:
Florian Müllner 2021-07-30 10:12:11 +02:00 committed by Marge Bot
parent 285ebe020c
commit e07bc62fbd

View File

@ -23,9 +23,16 @@ var ExtensionPrefsDialog = GObject.registerClass({
const prefsModule = extension.imports.prefs;
prefsModule.init(extension.metadata);
const widget = prefsModule.buildPrefsWidget();
const page = this._wrapWidget(widget);
this.add(page);
if (prefsModule.fillPreferencesWindow) {
prefsModule.fillPreferencesWindow(this);
if (!this.visible_page)
throw new Error('Extension did not provide any UI');
} else {
const widget = prefsModule.buildPrefsWidget();
const page = this._wrapWidget(widget);
this.add(page);
}
} catch (e) {
this._showErrorPage(e);
logError(e, 'Failed to open preferences');