Skip to content

Commit

Permalink
notification: Add the desktop-file-id key for portal backends
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
swick committed Oct 25, 2024
1 parent fb4b7a5 commit 80f66fe
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions data/org.freedesktop.impl.portal.Notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
-->
Expand Down
5 changes: 5 additions & 0 deletions src/notification.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 80f66fe

Please sign in to comment.