Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

notification: Add the desktop-file-id key for portal backends #1488

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

swick
Copy link
Contributor

@swick swick commented Oct 25, 2024

To fix #916, we need to get the application name from a org.freedesktop.impl.portal.Notification.AddNotification call which is currently not possible because we only get an app id which does not always map to a dekstop file (https://github.com/flatpak/xdg-desktop-portal-gtk/blob/366d3349041c2e06658c7c5a8b5bfd5f345d8157/src/fdonotification.c#L348).

This PR adds the desktop-file-id key to AddNotification impl calls to make it possible for backends to show an app name.

Copy link
Contributor

@jsparber jsparber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. This improves the situation but doesn't resolve the issue when a flatpak exports multiple desktop-files, but this does move in the correct direction so I'm fine with this changes.

We probably can do some clean up e.g. remove xdp_get_app_id_from_desktop_id() and replace fallback of "" for host apps with NULL .The clean ups should probably happen in a different MR.

src/xdp-app-info.c Outdated Show resolved Hide resolved
g_autoptr(GDesktopAppInfo) desktop_appinfo = NULL;

desktop_appinfo = g_desktop_app_info_new (desktop_file);
if (desktop_appinfo)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we actually need this dance of assigning the value first to desktop_appinfo?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The casts don't like getting NULL and there is no guarantee that we'll be able to find the desktop file that we "detected" so I don't see how.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, i didn't know that.

@@ -1077,6 +1078,10 @@ handle_add_in_thread_func (GTask *task,
return;
}

desktop_file = xdp_app_info_get_desktop_file (call_data->app_info);
if (desktop_file)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably we should check here whether desktop_file == "". Or maybe a follow up MR could make sure that the desktop_file is never set to "".

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed it so we never get an empty string or ".desktop" as desktop_file_id but in general, it needs to handle not finding the file anyway so this doesn't really change anything.

data/org.freedesktop.impl.portal.Notification.xml Outdated Show resolved Hide resolved
This allows clients to access either the GAppInfo or the desktop file
when needed.
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.
@swick swick force-pushed the wip/notification-impl-desktop-file branch from 027de6a to 80f66fe Compare October 25, 2024 19:55
@jadahl
Copy link
Collaborator

jadahl commented Oct 25, 2024

It was decided against this last time the same thing was proposed, as it is many places assumed the app ID resolves to a desktop file. See #904.

@swick
Copy link
Contributor Author

swick commented Oct 25, 2024

This is in the backend i.e. the impl only and also only added as additional data.

@jadahl
Copy link
Collaborator

jadahl commented Oct 25, 2024

This is in the backend i.e. the impl only.

That is what was proposed last time too.

@swick
Copy link
Contributor Author

swick commented Oct 25, 2024

Sorry, but assuming that an app id maps to a desktop file is just plain wrong. Not sending the desktop file is wrong. Nothing will change for impls which currently get away with assuming the app id maps to a desktop file.

@jadahl
Copy link
Collaborator

jadahl commented Oct 25, 2024

Resolving an app id that is derived in xdg-desktop-portal to a desktop file is assumed to work in the multiple portal backends, I don't know why you are claiming it's "plain wrong", it's how it's designed to work. It's not only a notification portal thing.

@swick
Copy link
Contributor Author

swick commented Oct 25, 2024

There are literally two choices here:

  1. Accept that an app id and desktop files can be different and start fixing up things in the stack
  2. Force app ids and desktop files to be identical

What we currently have is that desktop files and app ids can be different but the stack assumes that they are not. If we're not going for 1. then I want to know what the plan for 2. is.

@swick
Copy link
Contributor Author

swick commented Oct 25, 2024

And it's a fact that you can not generally resolve app ids to desktop files because there is at least one case where it doesn't work. Trying to do so anyway is therefor wrong. You can argue that it shouldn't be this way, but the facts here are simple.

@jadahl
Copy link
Collaborator

jadahl commented Oct 25, 2024

For flatpak, the only time it doesn't work fully as expected is apps with multiple "apps" inside, where the sub-app are distinguished by a suffix, while sharing the same app id (that still resolves to a desktop file) as the prefix. But that is a different story to what is done here.

@swick
Copy link
Contributor Author

swick commented Oct 25, 2024

Portals are used not only by flatpak.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Needs Triage
Development

Successfully merging this pull request may close these issues.

[Bug]: App Name is not available when using Portal Notifications
3 participants