| |
@@ -0,0 +1,55 @@
|
| |
+ From fffa8902db44209fdd47657a43a56c96f6db86d8 Mon Sep 17 00:00:00 2001
|
| |
+ From: Georges Basile Stavracas Neto <georges.stavracas@gmail.com>
|
| |
+ Date: Tue, 19 Apr 2022 19:45:32 -0300
|
| |
+ Subject: [PATCH] filechooser: Make current file override name and folder
|
| |
+
|
| |
+ In the SaveFile call, apps can pass all 3 options (current name, file,
|
| |
+ and folder), but that's not really how the API is expected to be used.
|
| |
+
|
| |
+ When current file is passed, ignore current name and folder.
|
| |
+
|
| |
+ Fixes https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/issues/29
|
| |
+ ---
|
| |
+ src/filechooser.c | 17 ++++++++++-------
|
| |
+ 1 file changed, 10 insertions(+), 7 deletions(-)
|
| |
+
|
| |
+ diff --git a/src/filechooser.c b/src/filechooser.c
|
| |
+ index c76169b..b4e89e1 100644
|
| |
+ --- a/src/filechooser.c
|
| |
+ +++ b/src/filechooser.c
|
| |
+ @@ -566,22 +566,25 @@ handle_open (XdpImplFileChooser *object,
|
| |
+
|
| |
+ if (strcmp (method_name, "SaveFile") == 0)
|
| |
+ {
|
| |
+ - if (g_variant_lookup (arg_options, "current_name", "&s", ¤t_name))
|
| |
+ - gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), current_name);
|
| |
+ /* TODO: is this useful ?
|
| |
+ * In a sandboxed situation, the current folder and current file
|
| |
+ * are likely in the fuse filesystem
|
| |
+ */
|
| |
+ - if (g_variant_lookup (arg_options, "current_folder", "^&ay", &path))
|
| |
+ - {
|
| |
+ - g_autoptr(GFile) file = g_file_new_for_path (path);
|
| |
+ - gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), file, NULL);
|
| |
+ - }
|
| |
+ if (g_variant_lookup (arg_options, "current_file", "^&ay", &path))
|
| |
+ {
|
| |
+ g_autoptr(GFile) file = g_file_new_for_path (path);
|
| |
+ gtk_file_chooser_set_file (GTK_FILE_CHOOSER (dialog), file, NULL);
|
| |
+ }
|
| |
+ + else
|
| |
+ + {
|
| |
+ + if (g_variant_lookup (arg_options, "current_name", "&s", ¤t_name))
|
| |
+ + gtk_file_chooser_set_current_name (GTK_FILE_CHOOSER (dialog), current_name);
|
| |
+ + if (g_variant_lookup (arg_options, "current_folder", "^&ay", &path))
|
| |
+ + {
|
| |
+ + g_autoptr(GFile) file = g_file_new_for_path (path);
|
| |
+ + gtk_file_chooser_set_current_folder (GTK_FILE_CHOOSER (dialog), file, NULL);
|
| |
+ + }
|
| |
+ + }
|
| |
+ }
|
| |
+ else if (strcmp (method_name, "SaveFiles") == 0)
|
| |
+ {
|
| |
+ --
|
| |
+ GitLab
|
| |
+
|
| |
Untested yet, will report back.