GTKNotificationDaemon: Use ShellApp methods to activate apps
`ShellApp` gained the ability to activated actions and it sets the correct platform data. Therefore drop the current implementation in favor for it. Closes: https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/7409 Closes: https://gitlab.gnome.org/GNOME/gtk/-/issues/5239 Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3198>
This commit is contained in:
parent
3abf7e4662
commit
7d6f465a47
@ -472,28 +472,12 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const FdoApplicationIface = loadInterfaceXML('org.freedesktop.Application');
|
|
||||||
const FdoApplicationProxy = Gio.DBusProxy.makeProxyWrapper(FdoApplicationIface);
|
|
||||||
|
|
||||||
function objectPathFromAppId(appId) {
|
|
||||||
return `/${appId.replace(/\./g, '/').replace(/-/g, '_')}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @returns {{ 'desktop-startup-id': string }}
|
|
||||||
*/
|
|
||||||
function getPlatformData() {
|
|
||||||
let startupId = GLib.Variant.new('s', `_TIME${global.get_current_time()}`);
|
|
||||||
return {'desktop-startup-id': startupId};
|
|
||||||
}
|
|
||||||
|
|
||||||
function InvalidAppError() {}
|
function InvalidAppError() {}
|
||||||
|
|
||||||
export const GtkNotificationDaemonAppSource = GObject.registerClass(
|
export const GtkNotificationDaemonAppSource = GObject.registerClass(
|
||||||
class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
||||||
constructor(appId) {
|
constructor(appId) {
|
||||||
const objectPath = objectPathFromAppId(appId);
|
if (!Gio.Application.id_is_valid(appId))
|
||||||
if (!GLib.Variant.is_object_path(objectPath))
|
|
||||||
throw new InvalidAppError();
|
throw new InvalidAppError();
|
||||||
|
|
||||||
const app = Shell.AppSystem.get_default().lookup_app(`${appId}.desktop`);
|
const app = Shell.AppSystem.get_default().lookup_app(`${appId}.desktop`);
|
||||||
@ -508,47 +492,26 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
|||||||
|
|
||||||
this._appId = appId;
|
this._appId = appId;
|
||||||
this._app = app;
|
this._app = app;
|
||||||
this._objectPath = objectPath;
|
|
||||||
|
|
||||||
this._notifications = {};
|
this._notifications = {};
|
||||||
this._notificationPending = false;
|
this._notificationPending = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
_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) {
|
_createNotification(params) {
|
||||||
return new GtkNotificationDaemonNotification(this, params);
|
return new GtkNotificationDaemonNotification(this, params);
|
||||||
}
|
}
|
||||||
|
|
||||||
async activateAction(actionId, target) {
|
activateAction(actionId, target) {
|
||||||
try {
|
const params = target ? GLib.Variant.new('av', [target]) : null;
|
||||||
const app = await this._createApp();
|
this._app.activate_action(actionId, params, 0, -1, null).catch(error => {
|
||||||
const params = target ? [target] : [];
|
logError(error, `Failed to activate action for ${this._appId}`);
|
||||||
app.ActivateActionAsync(actionId, params, getPlatformData());
|
});
|
||||||
} catch (error) {
|
|
||||||
logError(error, 'Failed to activate app proxy');
|
|
||||||
}
|
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
Main.panel.closeCalendar();
|
Main.panel.closeCalendar();
|
||||||
}
|
}
|
||||||
|
|
||||||
async open() {
|
open() {
|
||||||
try {
|
this._app.activate();
|
||||||
const app = await this._createApp();
|
|
||||||
app.ActivateAsync(getPlatformData());
|
|
||||||
} catch (error) {
|
|
||||||
logError(error, 'Failed to open app proxy');
|
|
||||||
}
|
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
Main.panel.closeCalendar();
|
Main.panel.closeCalendar();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user