diff options
Diffstat (limited to 'src/w32fns.c')
| -rw-r--r-- | src/w32fns.c | 82 |
1 files changed, 57 insertions, 25 deletions
diff --git a/src/w32fns.c b/src/w32fns.c index b7115601553..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. */ | ||
| 7766 | typedef struct | ||
| 7767 | { | ||
| 7768 | OPENFILENAME real_details; | ||
| 7769 | void * pReserved; | ||
| 7770 | DWORD dwReserved; | ||
| 7771 | DWORD FlagsEx; | ||
| 7772 | } NEWOPENFILENAME; | ||
| 7773 | |||
| 7774 | |||
| 7762 | DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0, | 7775 | DEFUN ("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. |
| 7764 | Use a file selection dialog. | 7777 | Use a file selection dialog. |
| @@ -7807,39 +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 | 7824 | BOOL file_opened = FALSE; | |
| 7825 | OPENFILENAME * file_details = &new_file_details.real_details; | ||
| 7826 | |||
| 7812 | /* Prevent redisplay. */ | 7827 | /* Prevent redisplay. */ |
| 7813 | specbind (Qinhibit_redisplay, Qt); | 7828 | specbind (Qinhibit_redisplay, Qt); |
| 7814 | BLOCK_INPUT; | 7829 | BLOCK_INPUT; |
| 7815 | 7830 | ||
| 7816 | bzero (&file_details, sizeof (file_details)); | 7831 | bzero (&new_file_details, sizeof (new_file_details)); |
| 7817 | file_details.lStructSize = sizeof (file_details); | 7832 | /* Apparently NT4 crashes if you give it an unexpected size. |
| 7818 | 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); | ||
| 7819 | /* Undocumented Bug in Common File Dialog: | 7840 | /* Undocumented Bug in Common File Dialog: |
| 7820 | If a filter is not specified, shell links are not resolved. */ | 7841 | If a filter is not specified, shell links are not resolved. */ |
| 7821 | file_details.lpstrFilter = "All Files (*.*)\0*.*\0Directories\0*|*\0\0"; | 7842 | file_details->lpstrFilter = "All Files (*.*)\0*.*\0Directories\0*|*\0\0"; |
| 7822 | file_details.lpstrFile = filename; | 7843 | file_details->lpstrFile = filename; |
| 7823 | file_details.nMaxFile = sizeof (filename); | 7844 | file_details->nMaxFile = sizeof (filename); |
| 7824 | file_details.lpstrInitialDir = init_dir; | 7845 | file_details->lpstrInitialDir = init_dir; |
| 7825 | file_details.lpstrTitle = SDATA (prompt); | 7846 | file_details->lpstrTitle = SDATA (prompt); |
| 7826 | 7847 | ||
| 7827 | if (! NILP (only_dir_p)) | 7848 | if (! NILP (only_dir_p)) |
| 7828 | default_filter_index = 2; | 7849 | default_filter_index = 2; |
| 7829 | 7850 | ||
| 7830 | file_details.nFilterIndex = default_filter_index; | 7851 | file_details->nFilterIndex = default_filter_index; |
| 7831 | 7852 | ||
| 7832 | file_details.Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR | 7853 | file_details->Flags = (OFN_HIDEREADONLY | OFN_NOCHANGEDIR |
| 7833 | | OFN_EXPLORER | OFN_ENABLEHOOK); | 7854 | | OFN_EXPLORER | OFN_ENABLEHOOK); |
| 7834 | if (!NILP (mustmatch)) | 7855 | if (!NILP (mustmatch)) |
| 7835 | 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 | } | ||
| 7863 | |||
| 7864 | file_details->lpfnHook = (LPOFNHOOKPROC) file_dialog_callback; | ||
| 7836 | 7865 | ||
| 7837 | file_details.lpfnHook = (LPOFNHOOKPROC) file_dialog_callback; | 7866 | file_opened = GetOpenFileName (file_details); |
| 7838 | 7867 | ||
| 7839 | if (GetOpenFileName (&file_details)) | 7868 | UNBLOCK_INPUT; |
| 7869 | |||
| 7870 | if (file_opened) | ||
| 7840 | { | 7871 | { |
| 7841 | dostounix_filename (filename); | 7872 | dostounix_filename (filename); |
| 7842 | if (file_details.nFilterIndex == 2) | 7873 | |
| 7874 | if (file_details->nFilterIndex == 2) | ||
| 7843 | { | 7875 | { |
| 7844 | /* "Directories" selected - strip dummy file name. */ | 7876 | /* "Directories" selected - strip dummy file name. */ |
| 7845 | char * last = strrchr (filename, '/'); | 7877 | char * last = strrchr (filename, '/'); |
| @@ -7857,7 +7889,6 @@ If ONLY-DIR-P is non-nil, the user can only select directories. */) | |||
| 7857 | dir, mustmatch, dir, Qfile_name_history, | 7889 | dir, mustmatch, dir, Qfile_name_history, |
| 7858 | default_filename, Qnil); | 7890 | default_filename, Qnil); |
| 7859 | 7891 | ||
| 7860 | UNBLOCK_INPUT; | ||
| 7861 | file = unbind_to (count, file); | 7892 | file = unbind_to (count, file); |
| 7862 | } | 7893 | } |
| 7863 | 7894 | ||
| @@ -8698,7 +8729,7 @@ fontsets are automatically created. */); | |||
| 8698 | DEFVAR_BOOL ("w32-strict-painting", | 8729 | DEFVAR_BOOL ("w32-strict-painting", |
| 8699 | &w32_strict_painting, | 8730 | &w32_strict_painting, |
| 8700 | doc: /* Non-nil means use strict rules for repainting frames. | 8731 | doc: /* Non-nil means use strict rules for repainting frames. |
| 8701 | Set this to nil to get the old behaviour for repainting; this should | 8732 | Set this to nil to get the old behavior for repainting; this should |
| 8702 | only be necessary if the default setting causes problems. */); | 8733 | only be necessary if the default setting causes problems. */); |
| 8703 | w32_strict_painting = 1; | 8734 | w32_strict_painting = 1; |
| 8704 | 8735 | ||
| @@ -8890,24 +8921,25 @@ void globals_of_w32fns () | |||
| 8890 | 8921 | ||
| 8891 | #undef abort | 8922 | #undef abort |
| 8892 | 8923 | ||
| 8924 | void w32_abort (void) NO_RETURN; | ||
| 8925 | |||
| 8893 | void | 8926 | void |
| 8894 | w32_abort() | 8927 | w32_abort() |
| 8895 | { | 8928 | { |
| 8896 | int button; | 8929 | int button; |
| 8897 | button = MessageBox (NULL, | 8930 | button = MessageBox (NULL, |
| 8898 | "A fatal error has occurred!\n\n" | 8931 | "A fatal error has occurred!\n\n" |
| 8899 | "Select Abort to exit, Retry to debug, Ignore to continue", | 8932 | "Would you like to attach a debugger?\n\n" |
| 8933 | "Select YES to debug, NO to abort Emacs", | ||
| 8900 | "Emacs Abort Dialog", | 8934 | "Emacs Abort Dialog", |
| 8901 | MB_ICONEXCLAMATION | MB_TASKMODAL | 8935 | MB_ICONEXCLAMATION | MB_TASKMODAL |
| 8902 | | MB_SETFOREGROUND | MB_ABORTRETRYIGNORE); | 8936 | | MB_SETFOREGROUND | MB_YESNO); |
| 8903 | switch (button) | 8937 | switch (button) |
| 8904 | { | 8938 | { |
| 8905 | case IDRETRY: | 8939 | case IDYES: |
| 8906 | DebugBreak (); | 8940 | DebugBreak (); |
| 8907 | break; | 8941 | exit (2); /* tell the compiler we will never return */ |
| 8908 | case IDIGNORE: | 8942 | case IDNO: |
| 8909 | break; | ||
| 8910 | case IDABORT: | ||
| 8911 | default: | 8943 | default: |
| 8912 | abort (); | 8944 | abort (); |
| 8913 | break; | 8945 | break; |