unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* (W32) Select a directory using the file selection dialog
@ 2003-04-08  9:08 David PONCE
  2003-04-08 22:29 ` Jason Rumney
  0 siblings, 1 reply; 2+ messages in thread
From: David PONCE @ 2003-04-08  9:08 UTC (permalink / raw)


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  <david@dponce.com>

	* 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);

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: (W32) Select a directory using the file selection dialog
  2003-04-08  9:08 (W32) Select a directory using the file selection dialog David PONCE
@ 2003-04-08 22:29 ` Jason Rumney
  0 siblings, 0 replies; 2+ messages in thread
From: Jason Rumney @ 2003-04-08 22:29 UTC (permalink / raw)
  Cc: emacs-devel

David PONCE <david.ponce@wanadoo.fr> writes:

> Hi All,
> 
> For now, it is impossible to select a directory using the file
> selection dialog.

No, it is not impossible. It is a bit of a hack though, and your
patch looks like it might be better if it works.

FYI there is a "Filter" dropdown on the Open File dialog, which has
"All Files (*.*)" and "Directories" as its options. If you select
"Directories", then the current directory will be opened when you
press OK.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2003-04-08 22:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-04-08  9:08 (W32) Select a directory using the file selection dialog David PONCE
2003-04-08 22:29 ` Jason Rumney

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).