changeset 60361:bd59e53ab8e8

(install_window_handler): Move extern to macterm.h. (Fx_file_dialog): Check STRINGP (default_filename) to see it is valid. Don't check !NILP (dir) because it is already checked with CHECK_STRING. (Fx_file_dialog) [!MAC_OSX]: Use FSSpec instead of FSRef for specifying the default location and obtaining the selected filename.
author YAMAMOTO Mitsuharu <mituharu@math.s.chiba-u.ac.jp>
date Fri, 04 Mar 2005 11:08:54 +0000
parents 86edfe26d552
children f69bf8238a7e
files src/macfns.c
diffstat 1 files changed, 25 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/macfns.c	Fri Mar 04 11:08:05 2005 +0000
+++ b/src/macfns.c	Fri Mar 04 11:08:54 2005 +0000
@@ -2294,8 +2294,6 @@
 
 /* Create and set up the Mac window for frame F.  */
 
-extern OSErr install_window_handler (WindowPtr);
-
 static void
 mac_window (f)
      struct frame *f;
@@ -4356,7 +4354,7 @@
 	options.actionButtonLabel = CFSTR ("Ok");
 	options.windowTitle = CFSTR ("Enter name");
 
-	if (!NILP(default_filename))
+	if (STRINGP (default_filename))
 	  {
 	    Lisp_Object utf8 = ENCODE_UTF_8 (default_filename);
 	    char *begPtr = SDATA(utf8);
@@ -4381,22 +4379,29 @@
       }
     
     /* Set the default location and continue*/
-    if (status == noErr) {
-      if (!NILP(dir)) {
+    if (status == noErr)
+      {
+	AEDesc defLocAed;
+#ifdef MAC_OSX
 	FSRef defLoc;
-	AEDesc defLocAed;
 	status = FSPathMakeRef(SDATA(ENCODE_FILE(dir)), &defLoc, NULL);
+#else
+	FSSpec defLoc;
+	status = posix_pathname_to_fsspec (SDATA (ENCODE_FILE (dir)), &defLoc);
+#endif
 	if (status == noErr) 
 	  {
+#ifdef MAC_OSX
 	    AECreateDesc(typeFSRef, &defLoc, sizeof(FSRef), &defLocAed);
+#else
+	    AECreateDesc(typeFSS, &defLoc, sizeof(FSSpec), &defLocAed);
+#endif
 	    NavCustomControl(dialogRef, kNavCtlSetLocation, (void*) &defLocAed);
 	    AEDisposeDesc(&defLocAed);
 	  }
+	status = NavDialogRun(dialogRef);
       }
 
-      status = NavDialogRun(dialogRef);
-    }
-
     if (saveName) CFRelease(saveName);
     if (message) CFRelease(message);
 
@@ -4413,11 +4418,22 @@
 	  {
 	    NavReplyRecord reply;
 	    AEDesc aed;
+#ifdef MAC_OSX
 	    FSRef fsRef;
+#else
+	    FSSpec fs;
+#endif
 	    status = NavDialogGetReply(dialogRef, &reply);
+
+#ifdef MAC_OSX
 	    AECoerceDesc(&reply.selection, typeFSRef, &aed);
 	    AEGetDescData(&aed, (void *) &fsRef, sizeof (FSRef));
 	    FSRefMakePath(&fsRef, (UInt8 *) filename, sizeof (filename));
+#else
+	    AECoerceDesc (&reply.selection, typeFSS, &aed);
+	    AEGetDescData (&aed, (void *) &fs, sizeof (FSSpec));
+	    fsspec_to_posix_pathname (&fs, filename, sizeof (filename) - 1);
+#endif
 	    AEDisposeDesc(&aed);
 	    if (reply.saveFileName)
 	      {