bilelmoussaoui / ashpd

A Rust wrapper around XDG portals DBus interfaces
https://bilelmoussaoui.github.io/ashpd/ashpd/
MIT License
240 stars 44 forks source link

file_chooser: Make choices optional #222

Closed apricotbucket28 closed 3 months ago

apricotbucket28 commented 3 months ago

While investigating why the open directory dialogs in Zed weren't the same as other GTK programs and Chromium, I noticed that the dbus message ashpd sent had an empty choices array (even though Zed didn't set any choices itself). Making the choices optional so ashpd wouldn't send them fixed the problem.

This is probably a KDE quirk; but the file chooser portal documentation states:

As a special case, passing an empty array for the list of choices indicates a boolean choice that is typically displayed as a check button, using “true” and “false” as the choices.

So it's probably a good idea to make them optional.

To clarify, this is what dialogs looked like before: image

And this is how they look now: image

bilelmoussaoui commented 3 months ago

This is actually an annoying limitation of the SerializeDict macro that doesn't provide a way to skip a field if it is empty... For the time being, this looks good enough for me. Thanks!