[gtk: 3/4] GtkFileChooserNativeWin32: Add some option flags




commit 8bfc19e7f775c5eceacc61c7288175e034fb6ef7
Author: Luca Bacci <luca bacci982 gmail com>
Date:   Fri Oct 7 19:06:09 2022 +0200

    GtkFileChooserNativeWin32: Add some option flags
    
    Avoid changing the current directory.
    Also avoid creating a sample file to test if the target file
    can be created.
    
    References:
    
    * "Why does the common file dialog change the current directory?"
     -> https://devblogs.microsoft.com/oldnewthing/20101112-00/?p=12293
    
    * "Why does the common file save dialog create a temporary file and then delete it?"
     -> https://devblogs.microsoft.com/oldnewthing/20140429-00/?p=1123

 gtk/gtkfilechoosernativewin32.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtkfilechoosernativewin32.c b/gtk/gtkfilechoosernativewin32.c
index 1f449c96f6..97150e650d 100644
--- a/gtk/gtkfilechoosernativewin32.c
+++ b/gtk/gtkfilechoosernativewin32.c
@@ -21,8 +21,8 @@
 
 /* Vista or newer */
 #define _WIN32_WINNT 0x0600
-#define WINVER _WIN32_WINNT
-#define NTDDI_VERSION NTDDI_VISTA
+#include <sdkddkver.h>
+
 #define COBJMACROS
 
 #include "gtkfilechoosernativeprivate.h"
@@ -469,7 +469,7 @@ filechooser_win32_thread (gpointer _data)
   HRESULT hr;
   IFileDialog *pfd = NULL;
   IFileDialog2 *pfd2 = NULL;
-  DWORD flags;
+  DWORD flags = 0;
   DWORD cookie;
   guint j, n_items;
 
@@ -491,7 +491,10 @@ filechooser_win32_thread (gpointer _data)
   if (FAILED (hr))
     g_error ("Can't get FileDialog options: %s", g_win32_error_message (hr));
 
-  flags |= FOS_FORCEFILESYSTEM;
+  flags |= FOS_FORCEFILESYSTEM |
+           FOS_OVERWRITEPROMPT |
+           FOS_NOTESTFILECREATE |
+           FOS_NOCHANGEDIR;
 
   if (data->folder)
     flags |= FOS_PICKFOLDERS;
@@ -502,8 +505,6 @@ filechooser_win32_thread (gpointer _data)
   if (data->select_multiple)
     flags |= FOS_ALLOWMULTISELECT;
 
-  flags |= FOS_OVERWRITEPROMPT;
-
   hr = IFileDialog_SetOptions (pfd, flags);
   if (FAILED (hr))
     g_error ("Can't set FileDialog options: %s", g_win32_error_message (hr));


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