loginDialog: Update banner asynchronously

We will soon allow reading the banner text from a file. Prepare
for that by making the method asynchronous.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3558>
This commit is contained in:
Florian Müllner 2024-11-22 19:36:42 +01:00
parent f328eee88c
commit 5f92c12c72

View File

@ -505,9 +505,9 @@ export const LoginDialog = GObject.registerClass({
this._settings = new Gio.Settings({schema_id: GdmUtil.LOGIN_SCREEN_SCHEMA}); this._settings = new Gio.Settings({schema_id: GdmUtil.LOGIN_SCREEN_SCHEMA});
this._settings.connect(`changed::${GdmUtil.BANNER_MESSAGE_KEY}`, this._settings.connect(`changed::${GdmUtil.BANNER_MESSAGE_KEY}`,
this._updateBanner.bind(this)); () => this._updateBanner().catch(logError));
this._settings.connect(`changed::${GdmUtil.BANNER_MESSAGE_TEXT_KEY}`, this._settings.connect(`changed::${GdmUtil.BANNER_MESSAGE_TEXT_KEY}`,
this._updateBanner.bind(this)); () => this._updateBanner().catch(logError));
this._settings.connect(`changed::${GdmUtil.DISABLE_USER_LIST_KEY}`, this._settings.connect(`changed::${GdmUtil.DISABLE_USER_LIST_KEY}`,
this._updateDisableUserList.bind(this)); this._updateDisableUserList.bind(this));
this._settings.connect(`changed::${GdmUtil.LOGO_KEY}`, this._settings.connect(`changed::${GdmUtil.LOGO_KEY}`,
@ -576,7 +576,7 @@ export const LoginDialog = GObject.registerClass({
this._bannerLabel.clutter_text.line_wrap = true; this._bannerLabel.clutter_text.line_wrap = true;
this._bannerLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE; this._bannerLabel.clutter_text.ellipsize = Pango.EllipsizeMode.NONE;
bannerBox.add_child(this._bannerLabel); bannerBox.add_child(this._bannerLabel);
this._updateBanner(); this._updateBanner().catch(logError);
this._sessionMenuButton = new SessionMenuButton(); this._sessionMenuButton = new SessionMenuButton();
this._sessionMenuButton.connect('session-activated', this._sessionMenuButton.connect('session-activated',
@ -873,16 +873,19 @@ export const LoginDialog = GObject.registerClass({
this._authPrompt.cancelButton.visible = cancelVisible; this._authPrompt.cancelButton.visible = cancelVisible;
} }
_getBannerText() { async _getBannerText() {
const enabled = this._settings.get_boolean(GdmUtil.BANNER_MESSAGE_KEY); const enabled = this._settings.get_boolean(GdmUtil.BANNER_MESSAGE_KEY);
if (!enabled) if (!enabled)
return null; return null;
// placeholder
await false;
return this._settings.get_string(GdmUtil.BANNER_MESSAGE_TEXT_KEY); return this._settings.get_string(GdmUtil.BANNER_MESSAGE_TEXT_KEY);
} }
_updateBanner() { async _updateBanner() {
const text = this._getBannerText(); const text = await this._getBannerText();
if (text) { if (text) {
this._bannerLabel.set_text(text); this._bannerLabel.set_text(text);