aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Rumney2005-06-12 19:23:28 +0000
committerJason Rumney2005-06-12 19:23:28 +0000
commit7f2b4738d9c69b3e4ca564d53c01493c0af9b247 (patch)
treec53e218d7673e4fdfc03db871aff17a2faf60181 /src
parent5a77c8e23c98b04eb8cd6161fe2363cb7cf987fc (diff)
downloademacs-7f2b4738d9c69b3e4ca564d53c01493c0af9b247.tar.gz
emacs-7f2b4738d9c69b3e4ca564d53c01493c0af9b247.zip
(NEWOPENFILENAME): New struct.
(Fx_file_dialog): Use it to trick the system into giving us up to date dialogs on systems that are documented to support it. Do not set OFN_FILEMUSTEXIST flag if looking for a directory.
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog7
-rw-r--r--src/w32fns.c59
2 files changed, 50 insertions, 16 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index a2c70f13109..76cdc9893ba 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,10 @@
12005-06-12 Jason Rumney <jasonr@gnu.org>
2
3 * w32fns.c (NEWOPENFILENAME): New struct.
4 (Fx_file_dialog): Use it to trick the system into giving us up to
5 date dialogs on systems that are documented to support it.
6 Do not set OFN_FILEMUSTEXIST flag if looking for a directory.
7
12005-06-12 Eli Zaretskii <eliz@gnu.org> 82005-06-12 Eli Zaretskii <eliz@gnu.org>
2 9
3 * w32fns.c (w32_abort): Use the MB_YESNO dialog instead of 10 * w32fns.c (w32_abort): Use the MB_YESNO dialog instead of
diff --git a/src/w32fns.c b/src/w32fns.c
index 7f625916926..6a2f98c4c7d 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -7759,6 +7759,19 @@ file_dialog_callback (hwnd, msg, wParam, lParam)
7759 return 0; 7759 return 0;
7760} 7760}
7761 7761
7762/* Since we compile with _WIN32_WINNT set to 0x0400 (for NT4 compatibility)
7763 we end up with the old file dialogs. Define a big enough struct for the
7764 new dialog to trick GetOpenFileName into giving us the new dialogs on
7765 Windows 2000 and XP. */
7766typedef struct
7767{
7768 OPENFILENAME real_details;
7769 void * pReserved;
7770 DWORD dwReserved;
7771 DWORD FlagsEx;
7772} NEWOPENFILENAME;
7773
7774
7762DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, 7775DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
7763 doc: /* Read file name, prompting with PROMPT in directory DIR. 7776 doc: /* Read file name, prompting with PROMPT in directory DIR.
7764Use a file selection dialog. 7777Use a file selection dialog.
@@ -7807,44 +7820,58 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */)
7807 filename[0] = '\0'; 7820 filename[0] = '\0';
7808 7821
7809 { 7822 {
7810 OPENFILENAME file_details; 7823 NEWOPENFILENAME new_file_details;
7811 BOOL file_opened = FALSE; 7824 BOOL file_opened = FALSE;
7812 7825 OPENFILENAME * file_details = &new_file_details.real_details;
7826
7813 /* Prevent redisplay. */ 7827 /* Prevent redisplay. */
7814 specbind (Qinhibit_redisplay, Qt); 7828 specbind (Qinhibit_redisplay, Qt);
7815 BLOCK_INPUT; 7829 BLOCK_INPUT;
7816 7830
7817 bzero (&file_details, sizeof (file_details)); 7831 bzero (&new_file_details, sizeof (new_file_details));
7818 file_details.lStructSize = sizeof (file_details); 7832 /* Apparently NT4 crashes if you give it an unexpected size.
7819 file_details.hwndOwner = FRAME_W32_WINDOW (f); 7833 I'm not sure about Windows 9x, so play it safe. */
7834 if (w32_major_version > 4 && w32_major_version < 95)
7835 file_details->lStructSize = sizeof (new_file_details);
7836 else
7837 file_details->lStructSize = sizeof (file_details);
7838
7839 file_details->hwndOwner = FRAME_W32_WINDOW (f);
7820 /* Undocumented Bug in Common File Dialog: 7840 /* Undocumented Bug in Common File Dialog:
7821 If a filter is not specified, shell links are not resolved. */ 7841 If a filter is not specified, shell links are not resolved. */
7822 file_details.lpstrFilter = "All Files (*.*)\0*.*\0Directories\0*|*\0\0"; 7842 file_details->lpstrFilter = "All Files (*.*)\0*.*\0Directories\0*|*\0\0";
7823 file_details.lpstrFile = filename; 7843 file_details->lpstrFile = filename;
7824 file_details.nMaxFile = sizeof (filename); 7844 file_details->nMaxFile = sizeof (filename);
7825 file_details.lpstrInitialDir = init_dir; 7845 file_details->lpstrInitialDir = init_dir;
7826 file_details.lpstrTitle = SDATA (prompt); 7846 file_details->lpstrTitle = SDATA (prompt);
7827 7847
7828 if (! NILP (only_dir_p)) 7848 if (! NILP (only_dir_p))
7829 default_filter_index = 2; 7849 default_filter_index = 2;
7830 7850
7831 file_details.nFilterIndex = default_filter_index; 7851 file_details->nFilterIndex = default_filter_index;
7832 7852
7833 file_details.Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR 7853 file_details->Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR
7834 | OFN_EXPLORER | OFN_ENABLEHOOK); 7854 | OFN_EXPLORER | OFN_ENABLEHOOK);
7835 if (!NILP (mustmatch)) 7855 if (!NILP (mustmatch))
7836 file_details.Flags |= OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST; 7856 {
7857 /* Require that the path to the parent directory exists. */
7858 file_details->Flags |= OFN_PATHMUSTEXIST;
7859 /* If we are looking for a file, require that it exists. */
7860 if (NILP (only_dir_p))
7861 file_details->Flags |= OFN_FILEMUSTEXIST;
7862 }
7837 7863
7838 file_details.lpfnHook = (LPOFNHOOKPROC) file_dialog_callback; 7864 file_details->lpfnHook = (LPOFNHOOKPROC) file_dialog_callback;
7839 7865
7840 file_opened = GetOpenFileName (&file_details); 7866 file_opened = GetOpenFileName (file_details);
7841 7867
7842 UNBLOCK_INPUT; 7868 UNBLOCK_INPUT;
7843 7869
7844 if (file_opened) 7870 if (file_opened)
7845 { 7871 {
7846 dostounix_filename (filename); 7872 dostounix_filename (filename);
7847 if (file_details.nFilterIndex == 2) 7873
7874 if (file_details->nFilterIndex == 2)
7848 { 7875 {
7849 /* "Directories" selected - strip dummy file name. */ 7876 /* "Directories" selected - strip dummy file name. */
7850 char * last = strrchr (filename, '/'); 7877 char * last = strrchr (filename, '/');