[simple-scan] Remember save-directory based on actual file URI
- From: Bartosz <bkosiorek src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [simple-scan] Remember save-directory based on actual file URI
- Date: Mon, 4 May 2020 23:17:56 +0000 (UTC)
commit 0a7e83860db231c0867ceab8ac923b3c8a2a7a14
Author: Michael Weghorn <m weghorn posteo de>
Date: Fri May 1 10:47:39 2020 +0200
Remember save-directory based on actual file URI
Derive the "save-directory" setting to save from the
file URI instead of using the
'Gtk.FileChooser.get_current_folder_file()' method in order
to reliably remember the directory that the file was actually
saved to.
This also makes the actual URI be stored instead of the file
path.
In particular, 'Gtk.FileChooser.get_current_folder_file()' does
not return the actual directory when GtkFileChooserNative is used
with a FileChooser portal (as can be tested e.g. with the
'GTK_USE_PORTAL=1' environment setting).
src/app-window.vala | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
---
diff --git a/src/app-window.vala b/src/app-window.vala
index c316bb0..4ef2d6c 100644
--- a/src/app-window.vala
+++ b/src/app-window.vala
@@ -451,7 +451,7 @@ public class AppWindow : Gtk.ApplicationWindow
directory = settings.get_string ("save-directory");
if (directory == null || directory == "")
- directory = Environment.get_user_special_dir (UserDirectory.DOCUMENTS);
+ directory = GLib.Filename.to_uri(Environment.get_user_special_dir (UserDirectory.DOCUMENTS));
var save_dialog = new Gtk.FileChooserNative (/* Save dialog: Dialog title */
_("Save As…"),
@@ -465,7 +465,7 @@ public class AppWindow : Gtk.ApplicationWindow
if (book_uri != null)
save_dialog.set_uri (book_uri);
else {
- save_dialog.set_current_folder (directory);
+ save_dialog.set_current_folder_uri (directory);
/* Default filename to use when saving document. */
/* To that filename the extension will be added, eg. "Scanned Document.pdf" */
save_dialog.set_current_name (_("Scanned Document") + "." + mime_type_to_extension
(save_format));
@@ -618,7 +618,8 @@ public class AppWindow : Gtk.ApplicationWindow
if (check_overwrite (save_dialog.transient_for, files))
{
- settings.set_string ("save-directory", save_dialog.get_current_folder ());
+ var directory_uri = uri.substring (0, uri.last_index_of ("/") + 1);
+ settings.set_string ("save-directory", directory_uri);
save_dialog.destroy ();
return uri;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]