status/backgroundApps: Use ShellApp.activate_action() to quit apps

`ShellApp` gained the ability to activated actions, therefore drop the current
implementation in favor for it.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3198>
This commit is contained in:
Julian Sparber 2024-02-19 09:43:56 +01:00
parent d6779f34da
commit 3abf7e4662

View File

@ -111,8 +111,6 @@ const BackgroundAppMenuItem = GObject.registerClass({
}
async _quitApp() {
const appId = this.app.get_id().replace(/\.desktop$/, '');
this._spinner.play();
this._spinnerTimeoutId =
GLib.timeout_add_seconds(GLib.PRIORITY_DEFAULT, SPINNER_TIMEOUT,
@ -124,18 +122,10 @@ const BackgroundAppMenuItem = GObject.registerClass({
});
try {
await Gio.DBus.session.call(
appId,
`/${appId.replaceAll('.', '/')}`,
'org.freedesktop.Application',
'ActivateAction',
new GLib.Variant('(sava{sv})', ['quit', [], {}]),
null,
Gio.DBusCallFlags.NONE,
-1,
null);
await this.app.activate_action('quit', null, 0, -1, null);
} catch (_error) {
try {
const appId = this.app.get_id().replace(/\.desktop$/, '');
Util.trySpawn(['flatpak', 'kill', appId]);
} catch (pidError) {
logError(pidError, 'Failed to kill application');