/[emacs]/emacs/src/macfns.c
ViewVC logotype

Diff of /emacs/src/macfns.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3.2.13 by miles, Mon Oct 25 04:19:36 2004 UTC revision 1.3.2.14 by miles, Thu Nov 4 13:12:30 2004 UTC
# Line 4216  Value is t if tooltip was open, nil othe Line 4216  Value is t if tooltip was open, nil othe
4216    
4217  extern Lisp_Object Qfile_name_history;  extern Lisp_Object Qfile_name_history;
4218    
4219  DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 4, 0,  DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
4220         doc: /* Read file name, prompting with PROMPT in directory DIR.         doc: /* Read file name, prompting with PROMPT in directory DIR.
4221  Use a file selection dialog.  Use a file selection dialog.
4222  Select DEFAULT-FILENAME in the dialog's file selection box, if  Select DEFAULT-FILENAME in the dialog's file selection box, if
4223  specified.  Ensure that file exists if MUSTMATCH is non-nil.  */)  specified.  Ensure that file exists if MUSTMATCH is non-nil.
4224    (prompt, dir, default_filename, mustmatch)  If ONLY-DIR-P is non-nil, the user can only select directories.  */)
4225       Lisp_Object prompt, dir, default_filename, mustmatch;    (prompt, dir, default_filename, mustmatch, only_dir_p)
4226         Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
4227  {  {
4228    struct frame *f = SELECTED_FRAME ();    struct frame *f = SELECTED_FRAME ();
4229    Lisp_Object file = Qnil;    Lisp_Object file = Qnil;
4230    int count = SPECPDL_INDEX ();    int count = SPECPDL_INDEX ();
4231    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
4232    char filename[1001];    char filename[1001];
4233    int default_filter_index = 1; /* 1: All Files, 2: Directories only  */    int default_filter_index = 1; /* 1: All Files, 2: Directories only  */
4234    
4235    GCPRO5 (prompt, dir, default_filename, mustmatch, file);    GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p);
4236    CHECK_STRING (prompt);    CHECK_STRING (prompt);
4237    CHECK_STRING (dir);    CHECK_STRING (dir);
4238    
# Line 4245  specified.  Ensure that file exists if M Line 4246  specified.  Ensure that file exists if M
4246      NavDialogRef dialogRef;      NavDialogRef dialogRef;
4247      NavTypeListHandle fileTypes = NULL;      NavTypeListHandle fileTypes = NULL;
4248      NavUserAction userAction;      NavUserAction userAction;
4249      CFStringRef message=NULL, client=NULL, saveName = NULL;      CFStringRef message=NULL, client=NULL, saveName = NULL, ok = NULL;
4250        CFStringRef title = NULL;
4251            
4252      BLOCK_INPUT;      BLOCK_INPUT;
4253      /* No need for a callback function because we are modal */      /* No need for a callback function because we are modal */
# Line 4268  specified.  Ensure that file exists if M Line 4270  specified.  Ensure that file exists if M
4270      options.clientName = client;      options.clientName = client;
4271      */      */
4272    
4273      /* Do Dired hack copied from w32fns.c */      if (!NILP (only_dir_p))
     if (!NILP(prompt) && strncmp (SDATA(prompt), "Dired", 5) == 0)  
4274        status = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL,        status = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL,
4275                                             &dialogRef);                                             &dialogRef);
4276      else if (NILP (mustmatch))      else if (NILP (mustmatch))
4277        {        {
4278          /* This is a save dialog */          /* This is a save dialog */
4279            ok = CFStringCreateWithCString (NULL, "Ok", kCFStringEncodingUTF8);
4280            title = CFStringCreateWithCString (NULL, "Enter name",
4281                                               kCFStringEncodingUTF8);
4282            options.optionFlags |= kNavDontConfirmReplacement;
4283            options.actionButtonLabel = ok;
4284            options.windowTitle = title;
4285    
4286          if (!NILP(default_filename))          if (!NILP(default_filename))
4287            {            {
4288              saveName = CFStringCreateWithCString(NULL, SDATA(default_filename),              saveName = CFStringCreateWithCString(NULL, SDATA(default_filename),
# Line 4282  specified.  Ensure that file exists if M Line 4290  specified.  Ensure that file exists if M
4290              options.saveFileName = saveName;              options.saveFileName = saveName;
4291              options.optionFlags |= kNavSelectDefaultLocation;              options.optionFlags |= kNavSelectDefaultLocation;
4292            }            }
         /* MAC_TODO: Find a better way to determine if this is a save  
            or load dialog than comparing dir with default_filename */  
         if (EQ(dir, default_filename))  
           {  
             status = NavCreateChooseFileDialog(&options, fileTypes,  
                                                NULL, NULL, NULL, NULL,  
                                                &dialogRef);  
           }  
         else {  
4293            status = NavCreatePutFileDialog(&options,            status = NavCreatePutFileDialog(&options,
4294                                            'TEXT', kNavGenericSignature,                                            'TEXT', kNavGenericSignature,
4295                                            NULL, NULL, &dialogRef);                                            NULL, NULL, &dialogRef);
4296          }          }
       }  
4297      else      else
4298        {        {
4299          /* This is an open dialog*/          /* This is an open dialog*/
# Line 4324  specified.  Ensure that file exists if M Line 4322  specified.  Ensure that file exists if M
4322      if (saveName) CFRelease(saveName);      if (saveName) CFRelease(saveName);
4323      if (client) CFRelease(client);      if (client) CFRelease(client);
4324      if (message) CFRelease(message);      if (message) CFRelease(message);
4325        if (ok) CFRelease(ok);
4326        if (title) CFRelease(title);
4327    
4328      if (status == noErr) {      if (status == noErr) {
4329        userAction = NavDialogGetUserAction(dialogRef);        userAction = NavDialogGetUserAction(dialogRef);

Legend:
Removed from v.1.3.2.13  
changed lines
  Added in v.1.3.2.14

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26