From: Luca Bacci Date: Fri, 7 Oct 2022 17:06:09 +0000 (+0200) Subject: GtkFileChooserNativeWin32: Add some option flags X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~9^2~183^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=8bfc19e7f775c5eceacc61c7288175e034fb6ef7;p=gtk4.git 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 --- 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 + #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));