dialog: Add more xdg portal fields for saving #13007
Open
+62
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This reduces the likelyhood of the user saving a file without an extension.
Description
One goal of flatpak is to restrict access to the filesystem, as such a portal SaveFile dialog returns a virtual path for the file chosen by the user. The name of this file cannot be changed (e.g. to fix the extension), therefore it is important to pass enough hints to the portal so the dialog that is created guides the user to name the file something sensible.
In this branch I add the following from the xdg-desktop-portal File Chooser spec:
current_filter
: Index of the filter to show on dialog creationcurrent_name
: Placeholder for a save file operationcurrent_file
: Path to an existing file to save overI've only implement these
SDL_PROP
s for the portal backend, however they presumably can apply to other platforms.In main...ColinKinloch:SDL:save_dialog_location_hack I attempted to populate the values from
SDL_PROP_FILE_DIALOG_LOCATION_STRING
, this may be a preferable approach. The wiki describes it as "the default folder or file to start the dialog at" however currently it is mapped directly tocurrent_folder
which is described as "Suggested folder in which the file should be saved".Unfortunately not all portal implementations act exactly the same.
Bellow are some examples of the behaviours of the different portals tested in gnome by forcing the portal:
GNOME (nautilus)
Screencast.From.2025-05-11.18-47-44.mp4
KDE
Screencast.From.2025-05-11.18-44-39.mp4
Using
current_file
with the kde portal to save over an existing file removes the extension, settingcurrent_filter
hides this issue as the kde file chooser with automatically add the extension.I've reported this bug to kde.
GTK
Screencast.From.2025-05-11.18-50-16.mp4
Existing Issue(s)