dbusServices/extensions: Await prefs.fillPreferencesWindow

There are cases where it makes sense to have fillPreferencesWindow be
async, so await it. One such case is when using .ui files from resources
with (GTK) templates. When extension developers load the resource in
`fillPreferencesWindow` and then import the js file that registers the
classes, there will be an error at the moment that there is no UI
provided. Similarly, make getPreferencesWidget async optionally.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3348>
This commit is contained in:
Leleat 2024-05-28 13:56:49 +02:00 committed by Marge Bot
parent 8176d6b51c
commit 0f30bfdd53
2 changed files with 5 additions and 4 deletions

View File

@ -38,7 +38,7 @@ export const ExtensionPrefsDialog = GObject.registerClass({
const prefsObj = new prefsModule.default({...metadata, dir, path});
this._extension.stateObj = prefsObj;
prefsObj.fillPreferencesWindow(this);
await prefsObj.fillPreferencesWindow(this);
if (!this.visible_page)
throw new Error('Extension did not provide any UI');

View File

@ -18,7 +18,7 @@ export class ExtensionPreferences extends ExtensionBase {
* Get the single widget that implements
* the extension's preferences.
*
* @returns {Gtk.Widget}
* @returns {Gtk.Widget|Promise<Gtk.Widget>}
*/
getPreferencesWidget() {
throw new GObject.NotImplementedError();
@ -31,9 +31,10 @@ export class ExtensionPreferences extends ExtensionBase {
* returned by getPreferencesWidget().
*
* @param {Adw.PreferencesWindow} window - the preferences window
* @returns {Promise<void>}
*/
fillPreferencesWindow(window) {
const widget = this.getPreferencesWidget();
async fillPreferencesWindow(window) {
const widget = await this.getPreferencesWidget();
const page = this._wrapWidget(widget);
window.add(page);
}