loginManager: Make API promise-based

The LoginManager abstraction is still mostly callback-based, not
least because the methods are thin wrappers around logind D-Bus
calls.

However as gjs' dbus wrapper now generates promised-based wrappers
as well, we can implement a proper async API just as naturally.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2344>
This commit is contained in:
Florian Müllner
2022-06-23 15:45:44 +02:00
committed by Marge Bot
parent db3916434e
commit a3db909383
5 changed files with 127 additions and 126 deletions

View File

@ -347,13 +347,11 @@ const SystemActions = GObject.registerClass({
this.notify('can-restart');
}
_updateHaveSuspend() {
this._loginManager.canSuspend(
(canSuspend, needsAuth) => {
this._canHaveSuspend = canSuspend;
this._suspendNeedsAuth = needsAuth;
this._updateSuspend();
});
async _updateHaveSuspend() {
const [canSuspend, needsAuth] = await this._loginManager.canSuspend();
this._canHaveSuspend = canSuspend;
this._suspendNeedsAuth = needsAuth;
this._updateSuspend();
}
_updateSuspend() {