unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: David PONCE <david.ponce@wanadoo.fr>
Subject: (W32) Select a directory using the file selection dialog
Date: Tue,  8 Apr 2003 11:08:49 +0200 (CEST)	[thread overview]
Message-ID: <16097356.1049792929727.JavaMail.www@wwinf9802> (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);

             reply	other threads:[~2003-04-08  9:08 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-04-08  9:08 David PONCE [this message]
2003-04-08 22:29 ` (W32) Select a directory using the file selection dialog Jason Rumney

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=16097356.1049792929727.JavaMail.www@wwinf9802 \
    --to=david.ponce@wanadoo.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).