From c1aec7f100f4d83ee22d84bde4f8ba4c3cf6c144 Mon Sep 17 00:00:00 2001 From: robxnano <91250-robxnano@users.noreply.gitlab.gnome.org> Date: Sat, 26 Nov 2022 14:09:40 +0000 Subject: [PATCH] filechoosernativewin32: Set default extension Setting the default extension before a filter is selected allows the IFileDialog to automatically change the extension when the filter is changed. See: https://learn.microsoft.com/en-us/windows/win32/api/shobjidl_core/nf-shobjidl_core-ifiledialog-setdefaultextension --- gtk/gtkfilechoosernativewin32.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gtk/gtkfilechoosernativewin32.c b/gtk/gtkfilechoosernativewin32.c index bec7ca4be3..d2f1769210 100644 --- a/gtk/gtkfilechoosernativewin32.c +++ b/gtk/gtkfilechoosernativewin32.c @@ -610,6 +610,10 @@ filechooser_win32_thread (gpointer _data) if (FAILED (hr)) g_warning_hr ("Can't set file types", hr); + hr = IFileDialog_SetDefaultExtension (pfd, L""); + if (FAILED (hr)) + g_warning_hr ("Can't set default extension", hr); + if (data->self->current_filter) { GSList *filters = gtk_file_chooser_list_filters (GTK_FILE_CHOOSER (data->self));