[gnome-shell] js: Use async D-Bus wrappers
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] js: Use async D-Bus wrappers
- Date: Mon, 1 Aug 2022 18:55:46 +0000 (UTC)
commit 637ee7386e778c853e0f381e4ddb022e060eea79
Author: Florian Müllner <fmuellner gnome org>
Date: Thu Jun 23 14:53:29 2022 +0200
js: Use async D-Bus wrappers
After porting the more complex cases - in particular those that
affect a module's API - we are left with straight-forward D-Bus
method calls that can be moved to promise-based wrappers in one
go.
For consistency, this also switches from Remote to Async where
the call result is ignored.
Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2344>
js/dbusServices/extensions/extensionsService.js | 115 ++++++++--------
.../notifications/notificationDaemon.js | 49 ++++---
js/dbusServices/screensaver/screenSaverService.js | 48 +++----
js/gdm/realmd.js | 6 +-
js/gdm/util.js | 30 ++--
js/misc/modemManager.js | 71 +++++-----
js/misc/systemActions.js | 19 +--
js/misc/weather.js | 17 +--
js/ui/calendar.js | 4 +-
js/ui/components/automountManager.js | 12 +-
js/ui/endSessionDialog.js | 108 +++++++--------
js/ui/inhibitShortcutsDialog.js | 53 ++++---
js/ui/mpris.js | 21 ++-
js/ui/notificationDaemon.js | 41 +++---
js/ui/remoteSearch.js | 8 +-
js/ui/screenShield.js | 2 +-
js/ui/screenshot.js | 153 ++++++++++-----------
js/ui/scripting.js | 23 +---
js/ui/status/location.js | 39 +++---
js/ui/status/network.js | 44 +++---
js/ui/status/thunderbolt.js | 60 ++++----
js/ui/windowManager.js | 4 +-
subprojects/extensions-app/js/main.js | 35 +++--
23 files changed, 464 insertions(+), 498 deletions(-)
---
diff --git a/js/dbusServices/extensions/extensionsService.js b/js/dbusServices/extensions/extensionsService.js
index f863489a72..d8234d2acb 100644
--- a/js/dbusServices/extensions/extensionsService.js
+++ b/js/dbusServices/extensions/extensionsService.js
@@ -43,87 +43,82 @@ var ExtensionsService = class extends ServiceImplementation {
this._proxy.UserExtensionsEnabled = enable;
}
- ListExtensionsAsync(params, invocation) {
- this._proxy.ListExtensionsRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async ListExtensionsAsync(params, invocation) {
+ try {
+ const res = await this._proxy.ListExtensionsAsync(...params);
invocation.return_value(new GLib.Variant('(a{sa{sv}})', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetExtensionInfoAsync(params, invocation) {
- this._proxy.GetExtensionInfoRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetExtensionInfoAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetExtensionInfoAsync(...params);
invocation.return_value(new GLib.Variant('(a{sv})', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetExtensionErrorsAsync(params, invocation) {
- this._proxy.GetExtensionErrorsRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetExtensionErrorsAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetExtensionErrorsAsync(...params);
invocation.return_value(new GLib.Variant('(as)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- InstallRemoteExtensionAsync(params, invocation) {
- this._proxy.InstallRemoteExtensionRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async InstallRemoteExtensionAsync(params, invocation) {
+ try {
+ const res = await this._proxy.InstallRemoteExtensionAsync(...params);
invocation.return_value(new GLib.Variant('(s)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- UninstallExtensionAsync(params, invocation) {
- this._proxy.UninstallExtensionRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async UninstallExtensionAsync(params, invocation) {
+ try {
+ const res = await this._proxy.UninstallExtensionAsync(...params);
invocation.return_value(new GLib.Variant('(b)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- EnableExtensionAsync(params, invocation) {
- this._proxy.EnableExtensionRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async EnableExtensionAsync(params, invocation) {
+ try {
+ const res = await this._proxy.EnableExtensionAsync(...params);
invocation.return_value(new GLib.Variant('(b)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- DisableExtensionAsync(params, invocation) {
- this._proxy.DisableExtensionRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async DisableExtensionAsync(params, invocation) {
+ try {
+ const res = await this._proxy.DisableExtensionAsync(...params);
invocation.return_value(new GLib.Variant('(b)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
LaunchExtensionPrefsAsync([uuid], invocation) {
this.OpenExtensionPrefsAsync([uuid, '', {}], invocation);
}
- OpenExtensionPrefsAsync(params, invocation) {
+ async OpenExtensionPrefsAsync(params, invocation) {
const [uuid, parentWindow, options] = params;
- this._proxy.GetExtensionInfoRemote(uuid, (res, error) => {
- if (this._handleError(invocation, error))
- return;
+ try {
+ const [serialized] = await this._proxy.GetExtensionInfoAsync(uuid);
- if (this._prefsDialog) {
- this._handleError(invocation,
- new Error('Already showing a prefs dialog'));
- return;
- }
+ if (this._prefsDialog)
+ throw new Error('Already showing a prefs dialog');
- const [serialized] = res;
const extension = ExtensionUtils.deserializeExtension(serialized);
this._prefsDialog = new ExtensionPrefsDialog(extension);
@@ -150,15 +145,17 @@ var ExtensionsService = class extends ServiceImplementation {
this._prefsDialog.show();
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- CheckForUpdatesAsync(params, invocation) {
- this._proxy.CheckForUpdatesRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async CheckForUpdatesAsync(params, invocation) {
+ try {
+ await this._proxy.CheckForUpdatesAsync(...params);
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
};
diff --git a/js/dbusServices/notifications/notificationDaemon.js
b/js/dbusServices/notifications/notificationDaemon.js
index 10f0ddacf0..b22f4ec1e4 100644
--- a/js/dbusServices/notifications/notificationDaemon.js
+++ b/js/dbusServices/notifications/notificationDaemon.js
@@ -103,45 +103,44 @@ var NotificationDaemon = class extends ServiceImplementation {
'sender-pid': new GLib.Variant('u', pid),
};
- this._proxy.NotifyRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
- const [id] = res;
+ try {
+ const [id] = await this._proxy.NotifyAsync(...params);
this._activeNotifications.set(id, sender);
- invocation.return_value(new GLib.Variant('(u)', res));
- });
+ invocation.return_value(new GLib.Variant('(u)', [id]));
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- CloseNotificationAsync(params, invocation) {
+ async CloseNotificationAsync(params, invocation) {
const [id] = params;
if (!this._checkNotificationId(invocation, id))
return;
- this._proxy.CloseNotificationRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ try {
+ await this._proxy.CloseNotificationAsync(...params);
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetCapabilitiesAsync(params, invocation) {
- this._proxy.GetCapabilitiesRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetCapabilitiesAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetCapabilitiesAsync(...params);
invocation.return_value(new GLib.Variant('(as)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetServerInformationAsync(params, invocation) {
- this._proxy.GetServerInformationRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetServerInformationAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetServerInformationAsync(...params);
invocation.return_value(new GLib.Variant('(ssss)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
async _getSenderPid(sender) {
diff --git a/js/dbusServices/screensaver/screenSaverService.js
b/js/dbusServices/screensaver/screenSaverService.js
index dbf2a82fb9..2c1546e426 100644
--- a/js/dbusServices/screensaver/screenSaverService.js
+++ b/js/dbusServices/screensaver/screenSaverService.js
@@ -32,39 +32,39 @@ var ScreenSaverService = class extends ServiceImplementation {
() => this._dbusImpl.emit_signal('WakeUpScreen', null));
}
- LockAsync(params, invocation) {
- this._proxy.LockRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async LockAsync(params, invocation) {
+ try {
+ await this._proxy.LockAsync(...params);
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetActiveAsync(params, invocation) {
- this._proxy.GetActiveRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetActiveAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetActiveAsync(...params);
invocation.return_value(new GLib.Variant('(b)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- SetActiveAsync(params, invocation) {
- this._proxy.SetActiveRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async SetActiveAsync(params, invocation) {
+ try {
+ await this._proxy.SetActiveAsync(...params);
invocation.return_value(null);
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
- GetActiveTimeAsync(params, invocation) {
- this._proxy.GetActiveTimeRemote(...params, (res, error) => {
- if (this._handleError(invocation, error))
- return;
-
+ async GetActiveTimeAsync(params, invocation) {
+ try {
+ const res = await this._proxy.GetActiveTimeAsync(...params);
invocation.return_value(new GLib.Variant('(u)', res));
- });
+ } catch (error) {
+ this._handleError(invocation, error);
+ }
}
};
diff --git a/js/gdm/realmd.js b/js/gdm/realmd.js
index 3c16098d49..e8220462ec 100644
--- a/js/gdm/realmd.js
+++ b/js/gdm/realmd.js
@@ -100,9 +100,9 @@ var Manager = class extends Signals.EventEmitter {
release() {
Service(Gio.DBus.system,
- 'org.freedesktop.realmd',
- '/org/freedesktop/realmd',
- service => service.ReleaseRemote());
+ 'org.freedesktop.realmd',
+ '/org/freedesktop/realmd',
+ service => service.ReleaseAsync().catch(logError));
this._aggregateProvider.disconnectObject(this);
this._realms = { };
this._updateLoginFormat();
diff --git a/js/gdm/util.js b/js/gdm/util.js
index d4923f2a72..55d7c67c1d 100644
--- a/js/gdm/util.js
+++ b/js/gdm/util.js
@@ -376,7 +376,7 @@ var ShellUserVerifier = class extends Signals.EventEmitter {
this.emit('show-message', null, null, MessageType.NONE);
}
- _checkForFingerprintReader() {
+ async _checkForFingerprintReader() {
this._fingerprintReaderType = FingerprintReaderType.NONE;
if (!this._settings.get_boolean(FINGERPRINT_AUTHENTICATION_KEY) ||
@@ -385,21 +385,19 @@ var ShellUserVerifier = class extends Signals.EventEmitter {
return;
}
- this._fprintManager.GetDefaultDeviceRemote(Gio.DBusCallFlags.NONE, this._cancellable,
- (params, error) => {
- if (!error && params) {
- const [device] = params;
- const fprintDeviceProxy = new FprintDeviceProxy(Gio.DBus.system,
- 'net.reactivated.Fprint',
- device);
- const fprintDeviceType = fprintDeviceProxy['scan-type'];
-
- this._fingerprintReaderType = fprintDeviceType === 'swipe'
- ? FingerprintReaderType.SWIPE
- : FingerprintReaderType.PRESS;
- this._updateDefaultService();
- }
- });
+ try {
+ const [device] = await this._fprintManager.GetDefaultDeviceAsync(
+ Gio.DBusCallFlags.NONE, this._cancellable);
+ const fprintDeviceProxy = new FprintDeviceProxy(Gio.DBus.system,
+ 'net.reactivated.Fprint',
+ device);
+ const fprintDeviceType = fprintDeviceProxy['scan-type'];
+
+ this._fingerprintReaderType = fprintDeviceType === 'swipe'
+ ? FingerprintReaderType.SWIPE
+ : FingerprintReaderType.PRESS;
+ this._updateDefaultService();
+ } catch (e) {}
}
_onCredentialManagerAuthenticated(credentialManager, _token) {
diff --git a/js/misc/modemManager.js b/js/misc/modemManager.js
index c73c93e7fd..0325ee6b34 100644
--- a/js/misc/modemManager.js
+++ b/js/misc/modemManager.js
@@ -153,24 +153,24 @@ class ModemGsm extends ModemBase {
this._proxy.connectSignal('RegistrationInfo', (proxy, sender, [_status, code, name]) => {
this._setOperatorName(_findProviderForMccMnc(name, code));
});
- this._proxy.GetRegistrationInfoRemote(([result], err) => {
- if (err) {
- log(err);
- return;
- }
+ this._getInitialState();
+ }
- let [status_, code, name] = result;
+ async _getInitialState() {
+ try {
+ const [
+ [status_, code, name],
+ [quality],
+ ] = await Promise.all([
+ this._proxy.GetRegistrationInfoAsync(),
+ this._proxy.GetSignalQualityAsync(),
+ ]);
this._setOperatorName(_findProviderForMccMnc(name, code));
- });
- this._proxy.GetSignalQualityRemote((result, err) => {
- if (err) {
- // it will return an error if the device is not connected
- this._setSignalQuality(0);
- } else {
- let [quality] = result;
- this._setSignalQuality(quality);
- }
- });
+ this._setSignalQuality(quality);
+ } catch (err) {
+ // it will return an error if the device is not connected
+ this._setSignalQuality(0);
+ }
}
});
@@ -188,27 +188,28 @@ class ModemCdma extends ModemBase {
if (this.operator_name == null)
this._refreshServingSystem();
});
- this._proxy.GetSignalQualityRemote((result, err) => {
- if (err) {
- // it will return an error if the device is not connected
- this._setSignalQuality(0);
- } else {
- let [quality] = result;
- this._setSignalQuality(quality);
- }
- });
+ this._getSignalQuality();
}
- _refreshServingSystem() {
- this._proxy.GetServingSystemRemote(([result], err) => {
- if (err) {
- // it will return an error if the device is not connected
- this._setOperatorName(null);
- } else {
- let [bandClass_, band_, sid] = result;
- this._setOperatorName(_findProviderForSid(sid));
- }
- });
+ async _getSignalQuality() {
+ try {
+ const [quality] = await this._proxy.GetSignalQualityAsync();
+ this._setSignalQuality(quality);
+ } catch (err) {
+ // it will return an error if the device is not connected
+ this._setSignalQuality(0);
+ }
+ }
+
+ async _refreshServingSystem() {
+ try {
+ const [bandClass_, band_, sid] =
+ await this._proxy.GetServingSystemAsync();
+ this._setOperatorName(_findProviderForSid(sid));
+ } catch (err) {
+ // it will return an error if the device is not connected
+ this._setOperatorName(null);
+ }
}
});
diff --git a/js/misc/systemActions.js b/js/misc/systemActions.js
index 42bce0198a..444ab4badb 100644
--- a/js/misc/systemActions.js
+++ b/js/misc/systemActions.js
@@ -329,11 +329,14 @@ const SystemActions = GObject.registerClass({
this.notify('can-lock-screen');
}
- _updateHaveShutdown() {
- this._session.CanShutdownRemote((result, error) => {
- this._canHavePowerOff = error ? false : result[0];
- this._updatePowerOff();
- });
+ async _updateHaveShutdown() {
+ try {
+ const [canShutdown] = await this._session.CanShutdownAsync();
+ this._canHavePowerOff = canShutdown;
+ } catch (e) {
+ this._canHavePowerOff = false;
+ }
+ this._updatePowerOff();
}
_updatePowerOff() {
@@ -431,21 +434,21 @@ const SystemActions = GObject.registerClass({
throw new Error('The logout action is not available!');
Main.overview.hide();
- this._session.LogoutRemote(0);
+ this._session.LogoutAsync(0).catch(logError);
}
activatePowerOff() {
if (!this._actions.get(POWER_OFF_ACTION_ID).available)
throw new Error('The power-off action is not available!');
- this._session.ShutdownRemote(0);
+ this._session.ShutdownAsync(0).catch(logError);
}
activateRestart() {
if (!this._actions.get(RESTART_ACTION_ID).available)
throw new Error('The restart action is not available!');
- this._session.RebootRemote();
+ this._session.RebootAsync().catch(logError);
}
activateSuspend() {
diff --git a/js/misc/weather.js b/js/misc/weather.js
index 4f175b9566..3f05f21fe1 100644
--- a/js/misc/weather.js
+++ b/js/misc/weather.js
@@ -39,7 +39,7 @@ var WeatherClient = class extends Signals.EventEmitter {
this._needsAuth = true;
this._weatherAuthorized = false;
- this._permStore = new PermissionStore.PermissionStore((proxy, error) => {
+ this._permStore = new PermissionStore.PermissionStore(async (proxy, error) => {
if (error) {
log(`Failed to connect to permissionStore: ${error.message}`);
return;
@@ -53,14 +53,15 @@ var WeatherClient = class extends Signals.EventEmitter {
return;
}
- this._permStore.LookupRemote('gnome', 'geolocation', (res, err) => {
- if (err)
- log(`Error looking up permission: ${err.message}`);
+ let [perms, data] = [{}, null];
+ try {
+ [perms, data] = await this._permStore.LookupAsync('gnome', 'geolocation');
+ } catch (err) {
+ log(`Error looking up permission: ${err.message}`);
+ }
- let [perms, data] = err ? [{}, null] : res;
- let params = ['gnome', 'geolocation', false, data, perms];
- this._onPermStoreChanged(this._permStore, '', params);
- });
+ const params = ['gnome', 'geolocation', false, data, perms];
+ this._onPermStoreChanged(this._permStore, '', params);
});
this._permStore.connectSignal('Changed',
this._onPermStoreChanged.bind(this));
diff --git a/js/ui/calendar.js b/js/ui/calendar.js
index f0b8c97f53..9981a456f6 100644
--- a/js/ui/calendar.js
+++ b/js/ui/calendar.js
@@ -337,11 +337,11 @@ class DBusEventSource extends EventSourceBase {
this._events.clear();
this.emit('changed');
}
- this._dbusProxy.SetTimeRangeRemote(
+ this._dbusProxy.SetTimeRangeAsync(
this._curRequestBegin.getTime() / 1000,
this._curRequestEnd.getTime() / 1000,
forceReload,
- Gio.DBusCallFlags.NONE);
+ Gio.DBusCallFlags.NONE).catch(logError);
}
}
diff --git a/js/ui/components/automountManager.js b/js/ui/components/automountManager.js
index 85d0644937..4c0c22305b 100644
--- a/js/ui/components/automountManager.js
+++ b/js/ui/components/automountManager.js
@@ -51,12 +51,12 @@ var AutomountManager = class {
}
}
- _InhibitorsChanged(_object, _senderName, [_inhibitor]) {
- this._session.IsInhibitedRemote(GNOME_SESSION_AUTOMOUNT_INHIBIT,
- (result, error) => {
- if (!error)
- this._inhibited = result[0];
- });
+ async _InhibitorsChanged(_object, _senderName, [_inhibitor]) {
+ try {
+ const [inhibited] =
+ await this._session.IsInhibitedAsync(GNOME_SESSION_AUTOMOUNT_INHIBIT);
+ this._inhibited = inhibited;
+ } catch (e) {}
}
_startupMountAll() {
diff --git a/js/ui/endSessionDialog.js b/js/ui/endSessionDialog.js
index 1f0b6afc25..5723a221ca 100644
--- a/js/ui/endSessionDialog.js
+++ b/js/ui/endSessionDialog.js
@@ -504,89 +504,73 @@ class EndSessionDialog extends ModalDialog.ModalDialog {
this._confirm('ConfirmedReboot');
}
- _confirm(signal) {
- let callback = () => {
- this._fadeOutDialog();
- this._stopTimer();
- this._stopAltCapture();
- this._dbusImpl.emit_signal(signal, null);
- };
-
- // Offline update not available; just emit the signal
- if (!this._checkBox.visible) {
- callback();
- return;
- }
-
- // Trigger the offline update as requested
- if (this._checkBox.checked) {
- switch (signal) {
- case "ConfirmedReboot":
- this._triggerOfflineUpdateReboot(callback);
- break;
- case "ConfirmedShutdown":
- // To actually trigger the offline update, we need to
- // reboot to do the upgrade. When the upgrade is complete,
- // the computer will shut down automatically.
- signal = "ConfirmedReboot";
- this._triggerOfflineUpdateShutdown(callback);
- break;
- default:
- callback();
- break;
+ async _confirm(signal) {
+ if (this._checkBox.visible) {
+ // Trigger the offline update as requested
+ if (this._checkBox.checked) {
+ switch (signal) {
+ case 'ConfirmedReboot':
+ await this._triggerOfflineUpdateReboot();
+ break;
+ case 'ConfirmedShutdown':
+ // To actually trigger the offline update, we need to
+ // reboot to do the upgrade. When the upgrade is complete,
+ // the computer will shut down automatically.
+ signal = 'ConfirmedReboot';
+ await this._triggerOfflineUpdateShutdown();
+ break;
+ default:
+ break;
+ }
+ } else {
+ await this._triggerOfflineUpdateCancel();
}
- } else {
- this._triggerOfflineUpdateCancel(callback);
}
+
+ this._fadeOutDialog();
+ this._stopTimer();
+ this._stopAltCapture();
+ this._dbusImpl.emit_signal(signal, null);
}
_onOpened() {
this._sync();
}
- _triggerOfflineUpdateReboot(callback) {
+ async _triggerOfflineUpdateReboot() {
// Handle this gracefully if PackageKit is not available.
- if (!this._pkOfflineProxy) {
- callback();
+ if (!this._pkOfflineProxy)
return;
- }
- this._pkOfflineProxy.TriggerRemote('reboot', (result, error) => {
- if (error)
- log(error.message);
-
- callback();
- });
+ try {
+ await this._pkOfflineProxy.TriggerAsync('reboot');
+ } catch (error) {
+ log(error.message);
+ }
}
- _triggerOfflineUpdateShutdown(callback) {
+ async _triggerOfflineUpdateShutdown() {
// Handle this gracefully if PackageKit is not available.
- if (!this._pkOfflineProxy) {
- callback();
+ if (!this._pkOfflineProxy)
return;
- }
-
- this._pkOfflineProxy.TriggerRemote('power-off', (result, error) => {
- if (error)
- log(error.message);
- callback();
- });
+ try {
+ await this._pkOfflineProxy.TriggerAsync('power-off');
+ } catch (error) {
+ log(error.message);
+ }
}
- _triggerOfflineUpdateCancel(callback) {
+ async _triggerOfflineUpdateCancel() {
// Handle this gracefully if PackageKit is not available.
- if (!this._pkOfflineProxy) {
- callback();
+ if (!this._pkOfflineProxy)
return;
- }
- this._pkOfflineProxy.CancelRemote((result, error) => {
- if (error)
- log(error.message);
-
- callback();
- });
+ try {
+ await this._pkOfflineProxy.CancelAsync();
+ } catch (error) {
+ log(error.message);
+ }
}
_startTimer() {
diff --git a/js/ui/inhibitShortcutsDialog.js b/js/ui/inhibitShortcutsDialog.js
index dec522c83a..f37c1f6054 100644
--- a/js/ui/inhibitShortcutsDialog.js
+++ b/js/ui/inhibitShortcutsDialog.js
@@ -53,7 +53,7 @@ var InhibitShortcutsDialog = GObject.registerClass({
return this._app && !this._app.is_window_backed();
}
- _saveToPermissionStore(grant) {
+ async _saveToPermissionStore(grant) {
if (!this._shouldUsePermStore() || this._permStore == null)
return;
@@ -61,15 +61,15 @@ var InhibitShortcutsDialog = GObject.registerClass({
permissions[this._app.get_id()] = [grant];
let data = GLib.Variant.new('av', {});
- this._permStore.SetRemote(APP_PERMISSIONS_TABLE,
- true,
- APP_PERMISSIONS_ID,
- permissions,
- data,
- (result, error) => {
- if (error != null)
- log(error.message);
- });
+ try {
+ await this._permStore.SetAsync(APP_PERMISSIONS_TABLE,
+ true,
+ APP_PERMISSIONS_ID,
+ permissions,
+ data);
+ } catch (error) {
+ log(error.message);
+ }
}
_buildLayout() {
@@ -134,30 +134,27 @@ var InhibitShortcutsDialog = GObject.registerClass({
/* Check with the permission store */
let appId = this._app.get_id();
- this._permStore = new PermissionStore.PermissionStore((proxy, error) => {
+ this._permStore = new PermissionStore.PermissionStore(async (proxy, error) => {
if (error) {
log(error.message);
this._dialog.open();
return;
}
- this._permStore.LookupRemote(APP_PERMISSIONS_TABLE,
- APP_PERMISSIONS_ID,
- (res, err) => {
- if (err) {
- this._dialog.open();
- log(err.message);
- return;
- }
-
- let [permissions] = res;
- if (permissions[appId] === undefined) // Not found
- this._dialog.open();
- else if (permissions[appId] == GRANTED)
- this._emitResponse(DialogResponse.ALLOW);
- else
- this._emitResponse(DialogResponse.DENY);
- });
+ try {
+ const [permissions] = await this._permStore.LookupAsync(
+ APP_PERMISSIONS_TABLE, APP_PERMISSIONS_ID);
+
+ if (permissions[appId] === undefined) // Not found
+ this._dialog.open();
+ else if (permissions[appId] === GRANTED)
+ this._emitResponse(DialogResponse.ALLOW);
+ else
+ this._emitResponse(DialogResponse.DENY);
+ } catch (err) {
+ this._dialog.open();
+ log(err.message);
+ }
});
}
diff --git a/js/ui/mpris.js b/js/ui/mpris.js
index e78f2114f7..3ef8ef399d 100644
--- a/js/ui/mpris.js
+++ b/js/ui/mpris.js
@@ -121,7 +121,7 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
}
playPause() {
- this._playerProxy.PlayPauseRemote();
+ this._playerProxy.PlayPauseAsync().catch(logError);
}
get canGoNext() {
@@ -129,7 +129,7 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
}
next() {
- this._playerProxy.NextRemote();
+ this._playerProxy.NextAsync().catch(logError);
}
get canGoPrevious() {
@@ -137,7 +137,7 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
}
previous() {
- this._playerProxy.PreviousRemote();
+ this._playerProxy.PreviousAsync().catch(logError);
}
raise() {
@@ -152,7 +152,7 @@ var MprisPlayer = class MprisPlayer extends Signals.EventEmitter {
if (app)
app.activate();
else if (this._mprisProxy.CanRaise)
- this._mprisProxy.RaiseRemote();
+ this._mprisProxy.RaiseAsync().catch(logError);
}
_close() {
@@ -275,14 +275,13 @@ class MediaSection extends MessageList.MessageListSection {
this._players.set(busName, player);
}
- _onProxyReady() {
- this._proxy.ListNamesRemote(([names]) => {
- names.forEach(name => {
- if (!name.startsWith(MPRIS_PLAYER_PREFIX))
- return;
+ async _onProxyReady() {
+ const [names] = await this._proxy.ListNamesAsync();
+ names.forEach(name => {
+ if (!name.startsWith(MPRIS_PLAYER_PREFIX))
+ return;
- this._addPlayer(name);
- });
+ this._addPlayer(name);
});
this._proxy.connectSignal('NameOwnerChanged',
this._onNameOwnerChanged.bind(this));
diff --git a/js/ui/notificationDaemon.js b/js/ui/notificationDaemon.js
index b2e325f722..f5e9cee19a 100644
--- a/js/ui/notificationDaemon.js
+++ b/js/ui/notificationDaemon.js
@@ -575,32 +575,41 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
return new MessageTray.NotificationApplicationPolicy(this._appId);
}
- _createApp(callback) {
- return new FdoApplicationProxy(Gio.DBus.session, this._appId, this._objectPath, callback);
+ _createApp() {
+ return new Promise((resolve, reject) => {
+ new FdoApplicationProxy(Gio.DBus.session,
+ this._appId, this._objectPath, (proxy, err) => {
+ if (err)
+ reject(err);
+ else
+ resolve(proxy);
+ });
+ });
}
_createNotification(params) {
return new GtkNotificationDaemonNotification(this, params);
}
- activateAction(actionId, target) {
- this._createApp((app, error) => {
- if (error == null)
- app.ActivateActionRemote(actionId, target ? [target] : [], getPlatformData());
- else
- logError(error, 'Failed to activate application proxy');
- });
+ async activateAction(actionId, target) {
+ try {
+ const app = await this._createApp();
+ const params = target ? [target] : [];
+ app.ActivateActionAsync(actionId, params, getPlatformData());
+ } catch (error) {
+ logError(error, 'Failed to activate application proxy');
+ }
Main.overview.hide();
Main.panel.closeCalendar();
}
- open() {
- this._createApp((app, error) => {
- if (error == null)
- app.ActivateRemote(getPlatformData());
- else
- logError(error, 'Failed to open application proxy');
- });
+ async open() {
+ try {
+ const app = await this._createApp();
+ app.ActivateAsync(getPlatformData());
+ } catch (error) {
+ logError(error, 'Failed to open application proxy');
+ }
Main.overview.hide();
Main.panel.closeCalendar();
}
diff --git a/js/ui/remoteSearch.js b/js/ui/remoteSearch.js
index 0358b34048..ec13be673d 100644
--- a/js/ui/remoteSearch.js
+++ b/js/ui/remoteSearch.js
@@ -302,7 +302,7 @@ var RemoteSearchProvider = class {
}
activateResult(id) {
- this.proxy.ActivateResultRemote(id);
+ this.proxy.ActivateResultAsync(id).catch(logError);
}
launchSearch(_terms) {
@@ -321,10 +321,12 @@ var RemoteSearchProvider2 = class extends RemoteSearchProvider {
}
activateResult(id, terms) {
- this.proxy.ActivateResultRemote(id, terms, global.get_current_time());
+ this.proxy.ActivateResultAsync(
+ id, terms, global.get_current_time()).catch(logError);
}
launchSearch(terms) {
- this.proxy.LaunchSearchRemote(terms, global.get_current_time());
+ this.proxy.LaunchSearchAsync(
+ terms, global.get_current_time()).catch(logError);
}
};
diff --git a/js/ui/screenShield.js b/js/ui/screenShield.js
index 7148c1e623..39fb09a843 100644
--- a/js/ui/screenShield.js
+++ b/js/ui/screenShield.js
@@ -173,7 +173,7 @@ var ScreenShield = class extends Signals.EventEmitter {
this.emit('locked-changed');
if (this._loginSession)
- this._loginSession.SetLockedHintRemote(locked);
+ this._loginSession.SetLockedHintAsync(locked).catch(logError);
}
_activateDialog() {
diff --git a/js/ui/screenshot.js b/js/ui/screenshot.js
index bdbf7134fe..931f958319 100644
--- a/js/ui/screenshot.js
+++ b/js/ui/screenshot.js
@@ -1824,42 +1824,38 @@ var ScreenshotUI = GObject.registerClass({
this.close(true);
// This is a bit awkward because creating a proxy synchronously hangs Shell.
- const doStartScreencast = () => {
+ const doStartScreencast = async () => {
let method =
- this._screencastProxy.ScreencastRemote.bind(this._screencastProxy);
+ this._screencastProxy.ScreencastAsync.bind(this._screencastProxy);
if (w !== -1) {
- method = this._screencastProxy.ScreencastAreaRemote.bind(
+ method = this._screencastProxy.ScreencastAreaAsync.bind(
this._screencastProxy, x, y, w, h);
}
- method(
- GLib.build_filenamev([
- /* Translators: this is the folder where recorded
- screencasts are stored. */
- _('Screencasts'),
- /* Translators: this is a filename used for screencast
- * recording, where "%d" and "%t" date and time, e.g.
- * "Screencast from 07-17-2013 10:00:46 PM.webm" */
- /* xgettext:no-c-format */
- _('Screencast from %d %t.webm'),
- ]),
- { 'draw-cursor': new GLib.Variant('b', drawCursor) },
- ([success, path], error) => {
- if (error !== null) {
- this._setScreencastInProgress(false);
- log(`Error starting screencast: ${error.message}`);
- return;
- }
-
- if (!success) {
- this._setScreencastInProgress(false);
- log('Error starting screencast');
- return;
- }
-
- this._screencastPath = path;
- }
- );
+ try {
+ const [success, path] = await method(
+ GLib.build_filenamev([
+ /* Translators: this is the folder where recorded
+ screencasts are stored. */
+ _('Screencasts'),
+ /* Translators: this is a filename used for screencast
+ * recording, where "%d" and "%t" date and time, e.g.
+ * "Screencast from 07-17-2013 10:00:46 PM.webm" */
+ /* xgettext:no-c-format */
+ _('Screencast from %d %t.webm'),
+ ]),
+ {'draw-cursor': new GLib.Variant('b', drawCursor)});
+ if (!success)
+ throw new Error();
+ this._screencastPath = path;
+ } catch (error) {
+ this._setScreencastInProgress(false);
+ const {message} = error;
+ if (message)
+ log(`Error starting screencast: ${message}`);
+ else
+ log('Error starting screencast');
+ }
};
// Set this before calling the method as the screen recording indicator
@@ -1886,7 +1882,7 @@ var ScreenshotUI = GObject.registerClass({
}
}
- stopScreencast() {
+ async stopScreencast() {
if (!this._screencastInProgress)
return;
@@ -1894,58 +1890,59 @@ var ScreenshotUI = GObject.registerClass({
// will check it before the success callback fires.
this._setScreencastInProgress(false);
- this._screencastProxy.StopScreencastRemote((success, error) => {
- if (error !== null) {
- log(`Error stopping screencast: ${error.message}`);
- return;
- }
-
- if (!success) {
+ try {
+ const [success] = await this._screencastProxy.StopScreencastAsync();
+ if (!success)
+ throw new Error();
+ } catch (error) {
+ const {message} = error;
+ if (message)
+ log(`Error stopping screencast: ${message}`);
+ else
log('Error stopping screencast');
- return;
- }
+ return;
+ }
- // Show a notification.
- const file = Gio.file_new_for_path(this._screencastPath);
+ // Show a notification.
+ const file = Gio.file_new_for_path(this._screencastPath);
- const source = new MessageTray.Source(
- // Translators: notification source name.
- _('Screenshot'),
- 'screencast-recorded-symbolic'
- );
- const notification = new MessageTray.Notification(
- source,
- // Translators: notification title.
- _('Screencast recorded'),
- // Translators: notification body when a screencast was recorded.
- _('Click here to view the video.')
- );
- // Translators: button on the screencast notification.
- notification.addAction(_('Show in Files'), () => {
- const app =
- Gio.app_info_get_default_for_type('inode/directory', false);
-
- if (app === null) {
- // It may be null e.g. in a toolbox without nautilus.
- log('Error showing in files: no default app set for inode/directory');
- return;
- }
+ const source = new MessageTray.Source(
+ // Translators: notification source name.
+ _('Screenshot'),
+ 'screencast-recorded-symbolic'
+ );
+ const notification = new MessageTray.Notification(
+ source,
+ // Translators: notification title.
+ _('Screencast recorded'),
+ // Translators: notification body when a screencast was recorded.
+ _('Click here to view the video.')
+ );
+ // Translators: button on the screencast notification.
+ notification.addAction(_('Show in Files'), () => {
+ const app =
+ Gio.app_info_get_default_for_type('inode/directory', false);
- app.launch([file], global.create_app_launch_context(0, -1));
- });
- notification.connect('activated', () => {
- try {
- Gio.app_info_launch_default_for_uri(
- file.get_uri(), global.create_app_launch_context(0, -1));
- } catch (err) {
- logError(err, 'Error opening screencast');
- }
- });
- notification.setTransient(true);
+ if (app === null) {
+ // It may be null e.g. in a toolbox without nautilus.
+ log('Error showing in files: no default app set for inode/directory');
+ return;
+ }
- Main.messageTray.add(source);
- source.showNotification(notification);
+ app.launch([file], global.create_app_launch_context(0, -1));
+ });
+ notification.connect('activated', () => {
+ try {
+ Gio.app_info_launch_default_for_uri(
+ file.get_uri(), global.create_app_launch_context(0, -1));
+ } catch (err) {
+ logError(err, 'Error opening screencast');
+ }
});
+ notification.setTransient(true);
+
+ Main.messageTray.add(source);
+ source.showNotification(notification);
}
get screencast_in_progress() {
diff --git a/js/ui/scripting.js b/js/ui/scripting.js
index 67a2652d13..a4d80d7496 100644
--- a/js/ui/scripting.js
+++ b/js/ui/scripting.js
@@ -82,19 +82,6 @@ function _spawnPerfHelper() {
Util.trySpawnCommandLine(command);
}
-function _callRemote(obj, method, ...args) {
- return new Promise((resolve, reject) => {
- args.push((result, excp) => {
- if (excp)
- reject(excp);
- else
- resolve();
- });
-
- method.apply(obj, args);
- });
-}
-
/**
* createTestWindow:
* @param {Object} params: options for window creation.
@@ -121,9 +108,9 @@ function createTestWindow(params) {
});
let perfHelper = _getPerfHelper();
- return _callRemote(perfHelper, perfHelper.CreateWindowRemote,
- params.width, params.height,
- params.alpha, params.maximized, params.redraws);
+ perfHelper.CreateWindowAsync(
+ params.width, params.height,
+ params.alpha, params.maximized, params.redraws).catch(logError);
}
/**
@@ -135,7 +122,7 @@ function createTestWindow(params) {
*/
function waitTestWindows() {
let perfHelper = _getPerfHelper();
- return _callRemote(perfHelper, perfHelper.WaitWindowsRemote);
+ perfHelper.WaitWindowsAsync().catch(logError);
}
/**
@@ -150,7 +137,7 @@ function waitTestWindows() {
*/
function destroyTestWindows() {
let perfHelper = _getPerfHelper();
- return _callRemote(perfHelper, perfHelper.DestroyWindowsRemote);
+ perfHelper.DestroyWindowsAsync().catch(logError);
}
/**
diff --git a/js/ui/status/location.js b/js/ui/status/location.js
index 2b30431927..1d4db65ea4 100644
--- a/js/ui/status/location.js
+++ b/js/ui/status/location.js
@@ -137,7 +137,7 @@ var GeoclueAgent = GObject.registerClass({
return true;
}
- _onManagerProxyReady(proxy, error) {
+ async _onManagerProxyReady(proxy, error) {
if (error != null) {
log(error.message);
this._connecting = false;
@@ -150,15 +150,13 @@ var GeoclueAgent = GObject.registerClass({
this.notify('in-use');
- this._managerProxy.AddAgentRemote('gnome-shell', this._onAgentRegistered.bind(this));
- }
-
- _onAgentRegistered(result, error) {
- this._connecting = false;
- this._notifyMaxAccuracyLevel();
-
- if (error != null)
- log(error.message);
+ try {
+ await this._managerProxy.AddAgentAsync('gnome-shell');
+ this._connecting = false;
+ this._notifyMaxAccuracyLevel();
+ } catch (e) {
+ log(e.message);
+ }
}
_onGeoclueVanished() {
@@ -298,7 +296,7 @@ var AppAuthorizer = class {
return this._accuracyLevel;
}
- _saveToPermissionStore() {
+ async _saveToPermissionStore() {
if (this._permStoreProxy == null)
return;
@@ -308,15 +306,16 @@ var AppAuthorizer = class {
let data = GLib.Variant.new('av', {});
- this._permStoreProxy.SetRemote(APP_PERMISSIONS_TABLE,
- true,
- APP_PERMISSIONS_ID,
- this._permissions,
- data,
- (result, error) => {
- if (error != null)
- log(error.message);
- });
+ try {
+ await this._permStoreProxy.SetAsync(
+ APP_PERMISSIONS_TABLE,
+ true,
+ APP_PERMISSIONS_ID,
+ this._permissions,
+ data);
+ } catch (error) {
+ log(error.message);
+ }
}
};
diff --git a/js/ui/status/network.js b/js/ui/status/network.js
index bc6cbb7eb5..9a3a06a2f5 100644
--- a/js/ui/status/network.js
+++ b/js/ui/status/network.js
@@ -50,7 +50,7 @@ var PortalHelperResult = {
};
const PortalHelperIface = loadInterfaceXML('org.gnome.Shell.PortalHelper');
-const PortalHelperProxy = Gio.DBusProxy.makeProxyWrapper(PortalHelperIface);
+const PortalHelperInfo = Gio.DBusInterfaceInfo.new_for_xml(PortalHelperIface);
function signalToIcon(value) {
if (value < 20)
@@ -2090,7 +2090,7 @@ class Indicator extends PanelMenu.SystemIndicator {
_flushConnectivityQueue() {
if (this._portalHelperProxy) {
for (let item of this._connectivityQueue)
- this._portalHelperProxy.CloseRemote(item);
+ this._portalHelperProxy.CloseAsync(item).catch(logError);
}
this._connectivityQueue = [];
@@ -2101,7 +2101,7 @@ class Indicator extends PanelMenu.SystemIndicator {
if (index >= 0) {
if (this._portalHelperProxy)
- this._portalHelperProxy.CloseRemote(path);
+ this._portalHelperProxy.CloseAsync(path).catch(logError);
this._connectivityQueue.splice(index, 1);
}
@@ -2128,7 +2128,7 @@ class Indicator extends PanelMenu.SystemIndicator {
}
}
- _syncConnectivity() {
+ async _syncConnectivity() {
if (this._mainConnection == null ||
this._mainConnection.state != NM.ActiveConnectionState.ACTIVATED) {
this._flushConnectivityQueue();
@@ -2153,25 +2153,27 @@ class Indicator extends PanelMenu.SystemIndicator {
}
let timestamp = global.get_current_time();
- if (this._portalHelperProxy) {
- this._portalHelperProxy.AuthenticateRemote(path, '', timestamp);
- } else {
- new PortalHelperProxy(Gio.DBus.session,
- 'org.gnome.Shell.PortalHelper',
- '/org/gnome/Shell/PortalHelper',
- (proxy, error) => {
- if (error) {
- log(`Error launching the portal helper: ${error}`);
- return;
- }
-
- this._portalHelperProxy = proxy;
- proxy.connectSignal('Done', this._portalHelperDone.bind(this));
-
- proxy.AuthenticateRemote(path, '', timestamp);
- });
+ if (!this._portalHelperProxy) {
+ this._portalHelperProxy = new Gio.DBusProxy({
+ g_connection: Gio.DBus.session,
+ g_name: 'org.gnome.Shell.PortalHelper',
+ g_object_path: '/org/gnome/Shell/PortalHelper',
+ g_interface_name: PortalHelperInfo.name,
+ g_interface_info: PortalHelperInfo,
+ });
+ this._portalHelperProxy.connectSignal('Done',
+ () => this._portalHelperDone().catch(logError));
+
+ try {
+ await this._portalHelperProxy.init_async(
+ GLib.PRIORITY_DEFAULT, null);
+ } catch (e) {
+ console.error(`Error launching the portal helper: ${e.message}`);
+ }
}
+ this._portalHelperProxy?.AuthenticateAsync(path, '', timestamp).catch(logError);
+
this._connectivityQueue.push(path);
}
diff --git a/js/ui/status/thunderbolt.js b/js/ui/status/thunderbolt.js
index e9fba78ed6..56bc731c2d 100644
--- a/js/ui/status/thunderbolt.js
+++ b/js/ui/status/thunderbolt.js
@@ -109,20 +109,15 @@ var Client = class extends Signals.EventEmitter {
this._proxy = null;
}
- enrollDevice(id, policy, callback) {
- this._proxy.EnrollDeviceRemote(id, policy, AuthCtrl.NONE, (res, error) => {
- if (error) {
- Gio.DBusError.strip_remote_error(error);
- callback(null, error);
- return;
- }
-
- let [path] = res;
- let device = new BoltDeviceProxy(Gio.DBus.system,
- BOLT_DBUS_NAME,
- path);
- callback(device, null);
- });
+ async enrollDevice(id, policy) {
+ try {
+ const [path] = await this._proxy.EnrollDeviceAsync(id, policy, AuthCtrl.NONE);
+ const device = new BoltDeviceProxy(Gio.DBus.system, BOLT_DBUS_NAME, path);
+ return device;
+ } catch (error) {
+ Gio.DBusError.strip_remote_error(error);
+ throw error;
+ }
}
get authMode() {
@@ -191,32 +186,29 @@ var AuthRobot = class extends Signals.EventEmitter {
this._enrollDevicesIdle.bind(this));
}
- _onEnrollDone(device, error) {
- if (error)
- this.emit('enroll-failed', device, error);
-
- /* TODO: scan the list of devices to be authorized for children
- * of this device and remove them (and their children and
- * their children and ....) from the device queue
- */
- this._enrolling = this._devicesToEnroll.length > 0;
-
- if (this._enrolling) {
- GLib.idle_add(GLib.PRIORITY_DEFAULT,
- this._enrollDevicesIdle.bind(this));
- }
- }
-
- _enrollDevicesIdle() {
+ async _enrollDevicesIdle() {
let devices = this._devicesToEnroll;
let dev = devices.shift();
if (dev === undefined)
return GLib.SOURCE_REMOVE;
- this._client.enrollDevice(dev.Uid,
- Policy.DEFAULT,
- this._onEnrollDone.bind(this));
+ try {
+ await this._client.enrollDevice(dev.Uid, Policy.DEFAULT);
+
+ /* TODO: scan the list of devices to be authorized for children
+ * of this device and remove them (and their children and
+ * their children and ....) from the device queue
+ */
+ this._enrolling = this._devicesToEnroll.length > 0;
+
+ if (this._enrolling) {
+ GLib.idle_add(GLib.PRIORITY_DEFAULT,
+ this._enrollDevicesIdle.bind(this));
+ }
+ } catch (error) {
+ this.emit('enroll-failed', null, error);
+ }
return GLib.SOURCE_REMOVE;
}
};
diff --git a/js/ui/windowManager.js b/js/ui/windowManager.js
index 2050ff8ab5..d415412b10 100644
--- a/js/ui/windowManager.js
+++ b/js/ui/windowManager.js
@@ -894,8 +894,8 @@ var WindowManager = class {
labels.push(str ?? '');
}
- if (this._gsdWacomProxy)
- this._gsdWacomProxy.SetOLEDLabelsRemote(pad.get_device_node(), labels);
+ this._gsdWacomProxy?.SetOLEDLabelsAsync(
+ pad.get_device_node(), labels).catch(logError);
});
global.display.connect('init-xserver', (display, task) => {
diff --git a/subprojects/extensions-app/js/main.js b/subprojects/extensions-app/js/main.js
index 2d8ff1111a..792cc9ec4a 100644
--- a/subprojects/extensions-app/js/main.js
+++ b/subprojects/extensions-app/js/main.js
@@ -51,7 +51,7 @@ class Application extends Adw.Application {
}
vfunc_activate() {
- this._shellProxy.CheckForUpdatesRemote();
+ this._shellProxy.CheckForUpdatesAsync().catch(logError);
this._window.present();
}
@@ -176,7 +176,7 @@ var ExtensionsWindow = GObject.registerClass({
dialog.connect('response', (dlg, response) => {
if (response === Gtk.ResponseType.ACCEPT)
- this._shellProxy.UninstallExtensionRemote(uuid);
+ this._shellProxy.UninstallExtensionAsync(uuid).catch(logError);
dialog.destroy();
});
dialog.present();
@@ -191,9 +191,9 @@ var ExtensionsWindow = GObject.registerClass({
}
}
- this._shellProxy.OpenExtensionPrefsRemote(uuid,
+ this._shellProxy.OpenExtensionPrefsAsync(uuid,
this._exportedHandle,
- { modal: new GLib.Variant('b', true) });
+ {modal: new GLib.Variant('b', true)}).catch(logError);
}
_showAbout() {
@@ -281,24 +281,23 @@ var ExtensionsWindow = GObject.registerClass({
this._syncListVisibility();
}
- _scanExtensions() {
- this._shellProxy.ListExtensionsRemote(([extensionsMap], e) => {
- if (e) {
- if (e instanceof Gio.DBusError) {
- log(`Failed to connect to shell proxy: ${e}`);
- this._mainStack.visible_child_name = 'noshell';
- } else {
- throw e;
- }
- return;
- }
+ async _scanExtensions() {
+ try {
+ const [extensionsMap] = await this._shellProxy.ListExtensionsAsync();
for (let uuid in extensionsMap) {
let extension = ExtensionUtils.deserializeExtension(extensionsMap[uuid]);
this._addExtensionRow(extension);
}
this._extensionsLoaded();
- });
+ } catch (e) {
+ if (e instanceof Gio.DBusError) {
+ log(`Failed to connect to shell proxy: ${e}`);
+ this._mainStack.visible_child_name = 'noshell';
+ } else {
+ throw e;
+ }
+ }
}
_addExtensionRow(extension) {
@@ -407,9 +406,9 @@ var ExtensionRow = GObject.registerClass({
action.connect('activate', toggleState);
action.connect('change-state', (a, state) => {
if (state.get_boolean())
- this._app.shellProxy.EnableExtensionRemote(this.uuid);
+ this._app.shellProxy.EnableExtensionAsync(this.uuid).catch(logError);
else
- this._app.shellProxy.DisableExtensionRemote(this.uuid);
+ this._app.shellProxy.DisableExtensionAsync(this.uuid).catch(logError);
});
this._actionGroup.add_action(action);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]