GtkNotificationDaemon: Add ActionInvoked signal
For the notification portal we need to provide the option to use unexported actions. Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3382>
This commit is contained in:
parent
1a12bd4f30
commit
6e0227ac3d
@ -9,5 +9,12 @@
|
|||||||
<arg name="app_id" type="s" direction="in"/>
|
<arg name="app_id" type="s" direction="in"/>
|
||||||
<arg name="id" type="s" direction="in"/>
|
<arg name="id" type="s" direction="in"/>
|
||||||
</method>
|
</method>
|
||||||
|
<signal name="ActionInvoked">
|
||||||
|
<arg name="app_id" type="s"/>
|
||||||
|
<arg name="id" type="s"/>
|
||||||
|
<arg name="action" type="s"/>
|
||||||
|
<arg name="parameter" type="av"/>
|
||||||
|
<arg name="platform_data" type="a{sv}"/>
|
||||||
|
</signal>
|
||||||
</interface>
|
</interface>
|
||||||
</node>
|
</node>
|
||||||
|
@ -456,15 +456,11 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
_activateAction(namespacedActionId, target) {
|
_activateAction(actionId, target) {
|
||||||
if (namespacedActionId) {
|
if (actionId.startsWith('app.'))
|
||||||
if (namespacedActionId.startsWith('app.')) {
|
this.source.activateAction(actionId.slice('app.'.length), target);
|
||||||
let actionId = namespacedActionId.slice('app.'.length);
|
else
|
||||||
this.source.activateAction(actionId, target);
|
this.source.emitActionInvoked(this.id, actionId, target);
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.source.open();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_onButtonClicked(button) {
|
_onButtonClicked(button) {
|
||||||
@ -473,7 +469,11 @@ class GtkNotificationDaemonNotification extends MessageTray.Notification {
|
|||||||
}
|
}
|
||||||
|
|
||||||
activate() {
|
activate() {
|
||||||
this._activateAction(this._defaultAction, this._defaultActionTarget);
|
if (this._defaultAction)
|
||||||
|
this._activateAction(this._defaultAction, this._defaultActionTarget);
|
||||||
|
else
|
||||||
|
this.source.open();
|
||||||
|
|
||||||
super.activate();
|
super.activate();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -486,7 +486,7 @@ 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, dbusImpl) {
|
||||||
if (!Gio.Application.id_is_valid(appId))
|
if (!Gio.Application.id_is_valid(appId))
|
||||||
throw new InvalidAppError();
|
throw new InvalidAppError();
|
||||||
|
|
||||||
@ -502,6 +502,7 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
|||||||
|
|
||||||
this._appId = appId;
|
this._appId = appId;
|
||||||
this._app = app;
|
this._app = app;
|
||||||
|
this._dbusImpl = dbusImpl;
|
||||||
|
|
||||||
this._notifications = {};
|
this._notifications = {};
|
||||||
this._notificationPending = false;
|
this._notificationPending = false;
|
||||||
@ -517,6 +518,22 @@ class GtkNotificationDaemonAppSource extends MessageTray.Source {
|
|||||||
Main.panel.closeCalendar();
|
Main.panel.closeCalendar();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
emitActionInvoked(notificationId, actionId, target) {
|
||||||
|
const context = global.create_app_launch_context(0, -1);
|
||||||
|
const info = this._app.get_app_info();
|
||||||
|
const token = context.get_startup_notify_id(info, []);
|
||||||
|
|
||||||
|
this._dbusImpl.emit_signal('ActionInvoked',
|
||||||
|
GLib.Variant.new('(sssava{sv})', [
|
||||||
|
this._appId,
|
||||||
|
notificationId,
|
||||||
|
actionId,
|
||||||
|
target ? [target] : [],
|
||||||
|
{'activation-token': GLib.Variant.new_string(token)},
|
||||||
|
])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
open() {
|
open() {
|
||||||
this._app.activate();
|
this._app.activate();
|
||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
@ -566,11 +583,11 @@ class GtkNotificationDaemon {
|
|||||||
constructor() {
|
constructor() {
|
||||||
this._sources = {};
|
this._sources = {};
|
||||||
|
|
||||||
this._loadNotifications();
|
|
||||||
|
|
||||||
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GtkNotificationsIface, this);
|
this._dbusImpl = Gio.DBusExportedObject.wrapJSObject(GtkNotificationsIface, this);
|
||||||
this._dbusImpl.export(Gio.DBus.session, '/org/gtk/Notifications');
|
this._dbusImpl.export(Gio.DBus.session, '/org/gtk/Notifications');
|
||||||
|
|
||||||
|
this._loadNotifications();
|
||||||
|
|
||||||
Gio.DBus.session.own_name('org.gtk.Notifications', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
Gio.DBus.session.own_name('org.gtk.Notifications', Gio.BusNameOwnerFlags.REPLACE, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -578,7 +595,7 @@ class GtkNotificationDaemon {
|
|||||||
if (this._sources[appId])
|
if (this._sources[appId])
|
||||||
return this._sources[appId];
|
return this._sources[appId];
|
||||||
|
|
||||||
let source = new GtkNotificationDaemonAppSource(appId);
|
const source = new GtkNotificationDaemonAppSource(appId, this._dbusImpl);
|
||||||
|
|
||||||
source.connect('destroy', () => {
|
source.connect('destroy', () => {
|
||||||
delete this._sources[appId];
|
delete this._sources[appId];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user