Skip to content

Remember save-directory based on actual file URI

When a FileChooser portal is being used, the directory of the previously saved file was not properly preselected in the save dialog, since GtkFileChooser's get_current_folder_file() method does not return the actually selected directory in this case.

This merge request makes that case work.

Steps to reproduce the issue with current master branch (as of commit b69611ab) :

  1. make sure that xdg-desktop-portal and xdg-desktop-portal-gnome (for GNOME desktop) or xdg-desktop-portal-kde (for KDE Plasma desktop) are installed

  2. start simple-scan with environment variable GTK_USE_PORTAL=1 set (or use via Flatpak,...):

    GTK_USE_PORTAL=1 simple-scan test

  3. Scan

  4. Save the file as /tmp/foo/bar/baz/test.pdf

  5. Click "Start again", then "Scan" to scan another image

  6. Click the "Save Document to a File" button to open the save dialog

Result: The the directory that the file was saved to in step 3 (/tmp/foo/bar/baz) is not preselected.

Expected result: The directory that the file was saved to in step 3 (/tmp/foo/bar/baz) should be preselected.

Notes

This works as expected when not using a portal, i.e. GTK_USE_PORTAL=0 (and the directory is navigated to in the file chooser before saving). A similar behaviour is shown when not using portal, but entering the whole path of the file in the "Name" input field in the Gtk file chooser, since that does not set the "current folder".

Merge request reports