emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

(W32) Select a directory using the file selection dialog


From: David PONCE
Subject: (W32) Select a directory using the file selection dialog
Date: Tue, 8 Apr 2003 11:08:49 +0200 (CEST)

Hi All,

For now, it is impossible to select a directory using the file
selection dialog.  A consequence is that, for example, it is
impossible to use the menu "Tools"/"PCL-CVS"/"Examine Directory", when
it displays the file selection dialog to select a directory.

I submit you the following patch to w32fns.c to allow directory
selection through the file selection dialog.

Tested:

In GNU Emacs 21.3.50.1 (i386-mingw-nt4.0.1381)
 of 2003-04-08
configured using `configure --with-gcc (3.2)'

Important settings:
  value of $LC_ALL: nil
  value of $LC_COLLATE: nil
  value of $LC_CTYPE: nil
  value of $LC_MESSAGES: nil
  value of $LC_MONETARY: nil
  value of $LC_NUMERIC: nil
  value of $LC_TIME: nil
  value of $LANG: ENU
  locale-coding-system: iso-latin-1
  default-enable-multibyte-characters: t

Hope it will help.
Sincerely,
David

2003-04-08  David Ponce  <address@hidden>

        * w32fns.c (TYPE_FILTERS_COMBO_FIELD): New define.
        (Qfile_directory_p, Vread_file_name_predicate): Declare extern.
        (file_dialog_callback): Allow directory selection.

Index: src/w32fns.c
===================================================================
RCS file: /cvsroot/emacs/emacs/src/w32fns.c,v
retrieving revision 1.215
diff -c -r1.215 w32fns.c
*** src/w32fns.c        31 Mar 2003 21:16:55 -0000      1.215
--- src/w32fns.c        8 Apr 2003 08:33:44 -0000
***************
*** 54,59 ****
--- 54,60 ----
  
  #include <dlgs.h>
  #define FILE_NAME_TEXT_FIELD edt1
+ #define TYPE_FILTERS_COMBO_FIELD cmb1
  
  void syms_of_w32fns ();
  void globals_of_w32fns ();
***************
*** 13278,13283 ****
--- 13279,13286 ----
                        File selection dialog
   ***********************************************************************/
  extern Lisp_Object Qfile_name_history;
+ extern Lisp_Object Qfile_directory_p;
+ extern Lisp_Object Vread_file_name_predicate;
  
  /* Callback for altering the behaviour of the Open File dialog.
     Makes the Filename text field contain "Current Directory" and be
***************
*** 13294,13308 ****
    if (msg == WM_NOTIFY)
      {
        OFNOTIFY * notify = (OFNOTIFY *)lParam;
        /* Detect when the Filter dropdown is changed.  */
!       if (notify->hdr.code == CDN_TYPECHANGE)
        {
!         HWND dialog = GetParent (hwnd);
!         HWND edit_control = GetDlgItem (dialog, FILE_NAME_TEXT_FIELD);
  
          /* Directories is in index 2.  */
          if (notify->lpOFN->nFilterIndex == 2)
            {
              CommDlg_OpenSave_SetControlText (dialog, FILE_NAME_TEXT_FIELD,
                                               "Current Directory");
              EnableWindow (edit_control, FALSE);
--- 13297,13333 ----
    if (msg == WM_NOTIFY)
      {
        OFNOTIFY * notify = (OFNOTIFY *)lParam;
+       HWND dialog, edit_control;
+       if (notify->hdr.code == CDN_INITDONE)
+       {
+         /* Directory selection only.  */
+         if (EQ (Vread_file_name_predicate, Qfile_directory_p))
+           {
+             notify->lpOFN->nFilterIndex = 2;
+             strcpy (notify->lpOFN->lpstrFile, "Current Directory");
+             /* Reset the OFN_FILEMUSTEXIST flags because the dummy
+                filename "Current Directory" don't need to exist!  */
+             notify->lpOFN->Flags &= ~OFN_FILEMUSTEXIST;
+             /* Disallow change of filename and type filter.  */
+             dialog = GetParent (hwnd);
+             edit_control = GetDlgItem (dialog, FILE_NAME_TEXT_FIELD);
+             EnableWindow (edit_control, FALSE);
+             edit_control = GetDlgItem (dialog, TYPE_FILTERS_COMBO_FIELD);
+             EnableWindow (edit_control, FALSE);
+           }
+       }
        /* Detect when the Filter dropdown is changed.  */
!       else if (notify->hdr.code == CDN_TYPECHANGE)
        {
!         dialog = GetParent (hwnd);
!         edit_control = GetDlgItem (dialog, FILE_NAME_TEXT_FIELD);
  
          /* Directories is in index 2.  */
          if (notify->lpOFN->nFilterIndex == 2)
            {
+             /* Reset the OFN_FILEMUSTEXIST flags because the dummy
+                filename "Current Directory" don't need to exist!  */
+             notify->lpOFN->Flags &= ~OFN_FILEMUSTEXIST;
              CommDlg_OpenSave_SetControlText (dialog, FILE_NAME_TEXT_FIELD,
                                               "Current Directory");
              EnableWindow (edit_control, FALSE);







reply via email to

[Prev in Thread] Current Thread [Next in Thread]