From 6c83f4b5ce59fee638b8513e9fbca89195e9fc4e Mon Sep 17 00:00:00 2001 From: Julian Sparber Date: Sun, 3 Mar 2024 01:18:23 +0100 Subject: [PATCH] notification: Get the activation-token form ActionInvoked when using portal Since [1] the xdg-desktop-portal-gtk adds the activation-token to the ActionInvoked signal. We can store it and let apps use it like the activation-token we get from FDO. [1] https://github.com/flatpak/xdg-desktop-portal-gtk/pull/468/ --- libnotify/notification.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/libnotify/notification.c b/libnotify/notification.c index 50dccfe..f7c2229 100644 --- a/libnotify/notification.c +++ b/libnotify/notification.c @@ -817,8 +817,29 @@ proxy_g_signal_cb (GDBusProxy *proxy, const char *id; const char *action; GVariant *parameter; + int i; g_variant_get (parameters, "(&s&s@av)", &id, &action, ¶meter); + + for (i = 0; i < g_variant_n_children (parameter); i++) { + g_autoptr (GVariant) data = NULL; + g_variant_get_child (parameter, i, "v", &data); + + if (g_variant_is_of_type (data, G_VARIANT_TYPE_VARDICT)) { + const char *key = NULL; + g_autoptr (GVariant) pdata = NULL; + + g_variant_get (data, "{&sv}", &key, &pdata); + + if (strcmp (key, "activation-token") == 0 && + g_variant_is_of_type (data, G_VARIANT_TYPE_STRING)) { + g_free (notification->priv->activation_token); + notification->priv->activation_token = g_variant_dup_string (pdata, NULL); + break; + } + } + } + g_variant_unref (parameter); notification_id = get_portal_notification_id (notification);