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:
parent
8176d6b51c
commit
0f30bfdd53
@ -38,7 +38,7 @@ export const ExtensionPrefsDialog = GObject.registerClass({
|
|||||||
const prefsObj = new prefsModule.default({...metadata, dir, path});
|
const prefsObj = new prefsModule.default({...metadata, dir, path});
|
||||||
this._extension.stateObj = prefsObj;
|
this._extension.stateObj = prefsObj;
|
||||||
|
|
||||||
prefsObj.fillPreferencesWindow(this);
|
await prefsObj.fillPreferencesWindow(this);
|
||||||
|
|
||||||
if (!this.visible_page)
|
if (!this.visible_page)
|
||||||
throw new Error('Extension did not provide any UI');
|
throw new Error('Extension did not provide any UI');
|
||||||
|
@ -18,7 +18,7 @@ export class ExtensionPreferences extends ExtensionBase {
|
|||||||
* Get the single widget that implements
|
* Get the single widget that implements
|
||||||
* the extension's preferences.
|
* the extension's preferences.
|
||||||
*
|
*
|
||||||
* @returns {Gtk.Widget}
|
* @returns {Gtk.Widget|Promise<Gtk.Widget>}
|
||||||
*/
|
*/
|
||||||
getPreferencesWidget() {
|
getPreferencesWidget() {
|
||||||
throw new GObject.NotImplementedError();
|
throw new GObject.NotImplementedError();
|
||||||
@ -31,9 +31,10 @@ export class ExtensionPreferences extends ExtensionBase {
|
|||||||
* returned by getPreferencesWidget().
|
* returned by getPreferencesWidget().
|
||||||
*
|
*
|
||||||
* @param {Adw.PreferencesWindow} window - the preferences window
|
* @param {Adw.PreferencesWindow} window - the preferences window
|
||||||
|
* @returns {Promise<void>}
|
||||||
*/
|
*/
|
||||||
fillPreferencesWindow(window) {
|
async fillPreferencesWindow(window) {
|
||||||
const widget = this.getPreferencesWidget();
|
const widget = await this.getPreferencesWidget();
|
||||||
const page = this._wrapWidget(widget);
|
const page = this._wrapWidget(widget);
|
||||||
window.add(page);
|
window.add(page);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user