[xdg-desktop-portal-gnome/gbsneto/filechooser-current-file] filechooser: Make current file override name and folder




commit fffa8902db44209fdd47657a43a56c96f6db86d8
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date:   Tue Apr 19 19:45:32 2022 -0300

    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", &current_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", &current_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)
     {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]