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
This commit is contained in:
Luca Bacci
2022-10-07 19:06:09 +02:00
parent d6f7449636
commit 8bfc19e7f7

View File

@@ -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));