/[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.46 by tamm, Wed Dec 29 17:25:02 2004 UTC revision 1.47 by tamm, Thu Jan 6 02:53:39 2005 UTC
# Line 55  static unsigned char gray_bits[] = { Line 55  static unsigned char gray_bits[] = {
55  #include <ctype.h>  #include <ctype.h>
56  #include <sys/types.h>  #include <sys/types.h>
57  #include <sys/stat.h>  #include <sys/stat.h>
58    #include <sys/param.h>
59    
60  #include <stdlib.h>  #include <stdlib.h>
61  #include <string.h>  #include <string.h>
# Line 4237  Value is t if tooltip was open, nil othe Line 4238  Value is t if tooltip was open, nil othe
4238                          File selection dialog                          File selection dialog
4239   ***********************************************************************/   ***********************************************************************/
4240    
4241    static pascal void mac_nav_event_callback P_ ((NavEventCallbackMessage,
4242                                                   NavCBRecPtr, void *));
4243    
4244  /**  /**
4245     There is a relatively standard way to do this using applescript to run     There is a relatively standard way to do this using applescript to run
4246     a (choose file) method.  However, this doesn't do "the right thing"     a (choose file) method.  However, this doesn't do "the right thing"
# Line 4261  If ONLY-DIR-P is non-nil, the user can o Line 4265  If ONLY-DIR-P is non-nil, the user can o
4265    Lisp_Object file = Qnil;    Lisp_Object file = Qnil;
4266    int count = SPECPDL_INDEX ();    int count = SPECPDL_INDEX ();
4267    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;    struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5, gcpro6;
4268    char filename[1001];    char filename[MAXPATHLEN];
4269    int default_filter_index = 1; /* 1: All Files, 2: Directories only  */    int default_filter_index = 1; /* 1: All Files, 2: Directories only  */
4270      static NavEventUPP mac_nav_event_callbackUPP = NULL;
4271    
4272    GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p);    GCPRO6 (prompt, dir, default_filename, mustmatch, file, only_dir_p);
4273    CHECK_STRING (prompt);    CHECK_STRING (prompt);
# Line 4290  If ONLY-DIR-P is non-nil, the user can o Line 4295  If ONLY-DIR-P is non-nil, the user can o
4295      options.optionFlags |= kNavSelectAllReadableItem;      options.optionFlags |= kNavSelectAllReadableItem;
4296      if (!NILP(prompt))      if (!NILP(prompt))
4297        {        {
4298          message = cfstring_create_with_utf8_cstring (SDATA (prompt));          message =
4299              cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8 (prompt)));
4300          options.message = message;          options.message = message;
4301        }        }
4302      /* Don't set the application, let it use default.      /* Don't set the application, let it use default.
4303      options.clientName = CFSTR ("Emacs");      options.clientName = CFSTR ("Emacs");
4304      */      */
4305    
4306        if (mac_nav_event_callbackUPP == NULL)
4307          mac_nav_event_callbackUPP = NewNavEventUPP (mac_nav_event_callback);
4308    
4309      if (!NILP (only_dir_p))      if (!NILP (only_dir_p))
4310        status = NavCreateChooseFolderDialog(&options, NULL, NULL, NULL,        status = NavCreateChooseFolderDialog(&options, mac_nav_event_callbackUPP,
4311                                             &dialogRef);                                             NULL, NULL, &dialogRef);
4312      else if (NILP (mustmatch))      else if (NILP (mustmatch))
4313        {        {
4314          /* This is a save dialog */          /* This is a save dialog */
# Line 4310  If ONLY-DIR-P is non-nil, the user can o Line 4319  If ONLY-DIR-P is non-nil, the user can o
4319          if (!NILP(default_filename))          if (!NILP(default_filename))
4320            {            {
4321              saveName =              saveName =
4322                cfstring_create_with_utf8_cstring (SDATA (default_filename));                cfstring_create_with_utf8_cstring (SDATA (ENCODE_UTF_8
4323                                                            (default_filename)));
4324              options.saveFileName = saveName;              options.saveFileName = saveName;
4325              options.optionFlags |= kNavSelectDefaultLocation;              options.optionFlags |= kNavSelectDefaultLocation;
4326            }            }
4327            status = NavCreatePutFileDialog(&options,            status = NavCreatePutFileDialog(&options,
4328                                            'TEXT', kNavGenericSignature,                                            'TEXT', kNavGenericSignature,
4329                                            NULL, NULL, &dialogRef);                                            mac_nav_event_callbackUPP, NULL,
4330                                              &dialogRef);
4331          }          }
4332      else      else
4333        {        {
4334          /* This is an open dialog*/          /* This is an open dialog*/
4335          status = NavCreateChooseFileDialog(&options, fileTypes,          status = NavCreateChooseFileDialog(&options, fileTypes,
4336                                             NULL, NULL, NULL, NULL,                                             mac_nav_event_callbackUPP, NULL,
4337                                             &dialogRef);                                             NULL, NULL, &dialogRef);
4338        }        }
4339            
4340      /* Set the default location and continue*/      /* Set the default location and continue*/
# Line 4331  If ONLY-DIR-P is non-nil, the user can o Line 4342  If ONLY-DIR-P is non-nil, the user can o
4342        if (!NILP(dir)) {        if (!NILP(dir)) {
4343          FSRef defLoc;          FSRef defLoc;
4344          AEDesc defLocAed;          AEDesc defLocAed;
4345          status = FSPathMakeRef(SDATA(dir), &defLoc, NULL);          status = FSPathMakeRef(SDATA(ENCODE_FILE(dir)), &defLoc, NULL);
4346          if (status == noErr)          if (status == noErr)
4347            {            {
4348              AECreateDesc(typeFSRef, &defLoc, sizeof(FSRef), &defLocAed);              AECreateDesc(typeFSRef, &defLoc, sizeof(FSRef), &defLocAed);
4349              NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed);              NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed);
4350                AEDisposeDesc(&defLocAed);
4351            }            }
         AEDisposeDesc(&defLocAed);  
4352        }        }
4353    
4354        status = NavDialogRun(dialogRef);        status = NavDialogRun(dialogRef);
# Line 4363  If ONLY-DIR-P is non-nil, the user can o Line 4374  If ONLY-DIR-P is non-nil, the user can o
4374              status = NavDialogGetReply(dialogRef, &reply);              status = NavDialogGetReply(dialogRef, &reply);
4375              AECoerceDesc(&reply.selection, typeFSRef, &aed);              AECoerceDesc(&reply.selection, typeFSRef, &aed);
4376              AEGetDescData(&aed, (void *) &fsRef, sizeof (FSRef));              AEGetDescData(&aed, (void *) &fsRef, sizeof (FSRef));
4377              FSRefMakePath(&fsRef, (UInt8 *) filename, 1000);              FSRefMakePath(&fsRef, (UInt8 *) filename, sizeof (filename));
4378              AEDisposeDesc(&aed);              AEDisposeDesc(&aed);
4379              if (reply.saveFileName)              if (reply.saveFileName)
4380                {                {
# Line 4372  If ONLY-DIR-P is non-nil, the user can o Line 4383  If ONLY-DIR-P is non-nil, the user can o
4383                  if (len && filename[len-1] != '/')                  if (len && filename[len-1] != '/')
4384                    filename[len++] = '/';                    filename[len++] = '/';
4385                  CFStringGetCString(reply.saveFileName, filename+len,                  CFStringGetCString(reply.saveFileName, filename+len,
4386                                     1000-len, kCFStringEncodingUTF8);                                     sizeof (filename) - len,
4387                                       kCFStringEncodingUTF8);
4388                }                }
4389              file = DECODE_FILE(build_string (filename));              file = DECODE_FILE (make_unibyte_string (filename,
4390                                                         strlen (filename)));
4391              NavDisposeReply(&reply);              NavDisposeReply(&reply);
4392            }            }
4393            break;            break;
# Line 4400  If ONLY-DIR-P is non-nil, the user can o Line 4413  If ONLY-DIR-P is non-nil, the user can o
4413  }  }
4414    
4415    
4416    /* Need to register some event callback function for enabling drag and
4417       drop in Navigation Service dialogs.  */
4418    static pascal void
4419    mac_nav_event_callback (selector, parms, data)
4420         NavEventCallbackMessage selector;
4421         NavCBRecPtr parms;
4422         void *data ;
4423    {
4424    }
4425  #endif  #endif
4426    
4427  /***********************************************************************  /***********************************************************************

Legend:
Removed from v.1.46  
changed lines
  Added in v.1.47

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