From 80f66fec9a05c2cb0208675a64964104b55d80d1 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Fri, 25 Oct 2024 17:55:58 +0200 Subject: [PATCH] notification: Add the desktop-file-id key for portal backends This makes it possible for portal impl to properly look up a localized name of the app. The app id that is sent as the first argument can sometimes be mapped to the desktop file but this isn't generally true and snap app ids for example cannot be used for this. --- data/org.freedesktop.impl.portal.Notification.xml | 7 +++++++ src/notification.c | 5 +++++ 2 files changed, 12 insertions(+) diff --git a/data/org.freedesktop.impl.portal.Notification.xml b/data/org.freedesktop.impl.portal.Notification.xml index cea66de55..abd153b9a 100644 --- a/data/org.freedesktop.impl.portal.Notification.xml +++ b/data/org.freedesktop.impl.portal.Notification.xml @@ -47,6 +47,13 @@ The format of the @notification is the same as for :ref:`org.freedesktop.portal.Notification.AddNotification`. + It additionally can contain the following keys: + + * ``desktop-file-id`` (``s``) + + The desktop file ID of the app adding the notification. A desktop + file ID is the basename of the desktop file, including the + .desktop extension. Since version 2, the icon property never uses the ``bytes`` option. --> diff --git a/src/notification.c b/src/notification.c index 38494dad8..fa9b20c1c 100644 --- a/src/notification.c +++ b/src/notification.c @@ -1046,6 +1046,7 @@ handle_add_in_thread_func (GTask *task, { CallData *call_data = task_data; GVariantBuilder builder; + const char *desktop_file_id; g_autoptr(GError) error = NULL; CALL_DATA_AUTOLOCK (call_data); @@ -1077,6 +1078,10 @@ handle_add_in_thread_func (GTask *task, return; } + desktop_file_id = xdp_app_info_get_desktop_file_id (call_data->app_info); + if (desktop_file_id) + g_variant_builder_add (&builder, "{ss}", "desktop-file-id", desktop_file_id); + xdp_dbus_impl_notification_call_add_notification (impl, xdp_app_info_get_id (call_data->app_info), call_data->id,