|
From: <cre...@us...> - 2006-09-09 19:57:26
|
Revision: 1502
http://svn.sourceforge.net/frontierkernel/?rev=1502&view=rev
Author: creecode
Date: 2006-09-09 12:57:23 -0700 (Sat, 09 Sep 2006)
Log Message:
-----------
for Mac, in save dialogs add file extension when appropiate
Modified Paths:
--------------
Frontier/branches/FSRef_Migration/Common/headers/file.h
Frontier/branches/FSRef_Migration/Common/source/filedialog.c
Modified: Frontier/branches/FSRef_Migration/Common/headers/file.h
===================================================================
--- Frontier/branches/FSRef_Migration/Common/headers/file.h 2006-09-09 19:29:11 UTC (rev 1501)
+++ Frontier/branches/FSRef_Migration/Common/headers/file.h 2006-09-09 19:57:23 UTC (rev 1502)
@@ -478,7 +478,8 @@
//Code change by Timothy Paustian Tuesday, June 20, 2000 2:22:02 PM
//Nav services code for Frontier.
- extern OSErr TimsPutFile(bigstring prompt, Str255 fileName, StandardFileReply * outReply);
+
+ extern OSErr TimsPutFile( bigstring, Str255, StandardFileReply *, OSType );
extern OSErr TimsGetFolderOrVolume(bigstring prompt, SInt16 dialogType, StandardFileReply * outReply);
Modified: Frontier/branches/FSRef_Migration/Common/source/filedialog.c
===================================================================
--- Frontier/branches/FSRef_Migration/Common/source/filedialog.c 2006-09-09 19:29:11 UTC (rev 1501)
+++ Frontier/branches/FSRef_Migration/Common/source/filedialog.c 2006-09-09 19:57:23 UTC (rev 1502)
@@ -538,9 +538,14 @@
tysfdata sfdata;
FSSpec *fs = &sfdata.sfreply.sfFile, fspect;
OSErr err = noErr;
+ OSType filetype = NULL;
clearbytes ( &fspect, sizeof ( fspect ) );
+ // move the switch statement to below because it's smarter to call it there when using the new routines for Nav services.
+
+ clearbytes (&sfdata, sizeof (sfdata));
+
if ( extendfilespec ( fspec, fspec ) ) {
if ( ( *fspec ).path == NULL )
@@ -559,11 +564,10 @@
else
if ( ( *fspec ).path != NULL )
CFStringRefToStr255 ( ( *fspec ).path, fspect.name );
+
+ if ( filetypes != NULL )
+ filetype = ( *filetypes ).types [ 0 ];
- // move the switch statement to below because it's smarter to call it there when using the new routines for Nav services.
-
- clearbytes (&sfdata, sizeof (sfdata));
-
copystring (bsprompt, sfdata.sfprompt);
sfdata.sftypes = filetypes;
@@ -592,7 +596,7 @@
case sfputfileverb:
if(gCanUseNavServ) {
- err = TimsPutFile(bsprompt, (*fs).name, &sfdata.sfreply);
+ err = TimsPutFile ( bsprompt, ( *fs ).name, &sfdata.sfreply, filetype );
}
break;
@@ -998,58 +1002,57 @@
} /*initfile*/
- //Code change by Timothy Paustian Tuesday, June 20, 2000 2:55:17 PM
- //New routine to use Nav services for this instead of CustomPutFile.
- OSErr
- TimsPutFile(bigstring prompt, Str255 fileName, StandardFileReply * outReply)
- {
+ OSErr TimsPutFile ( bigstring prompt, Str255 fileName, StandardFileReply *outReply, OSType filetype ) {
+
+ // Code change by Timothy Paustian Tuesday, June 20, 2000 2:55:17 PM. New routine to use Nav services for this
+ // instead of CustomPutFile.
+
+ OSErr err = noErr;
+ NavReplyRecord reply;
+ NavDialogOptions dialogOptions;
+ NavEventUPP eventProc = NewNavEventUPP ( NavEventProc );
+
+ if ( filetype == NULL )
+ filetype = 'TEXT';
+
+ err = NavGetDefaultDialogOptions ( &dialogOptions );
+ copystring ( fileName, dialogOptions.savedFileName );
+ copystring (prompt, dialogOptions.message );
+ dialogOptions.dialogOptionFlags |= kNavNoTypePopup; // 2000-08-25 AR
+
+ if (err == noErr) {
+
+ err = NavPutFile ( nil, &reply, &dialogOptions, eventProc, filetype, 'LAND', nil );
+
+ if ( err == noErr && reply.validRecord ) {
+
+ AEKeyword theKeyword;
+ DescType actualType;
+ Size actualSize;
+ FSSpec documentFSSpec;
+
+ err = AEGetNthPtr ( &( reply.selection ), 1, typeFSS, &theKeyword, &actualType, &documentFSSpec,
+ sizeof ( documentFSSpec ), &actualSize );
+
+ if (err == noErr) {
+
+ outReply->sfReplacing = reply.replacing;
+ FSMakeFSSpec (documentFSSpec.vRefNum, documentFSSpec.parID, documentFSSpec.name, &(outReply->sfFile));
+ outReply->sfGood = true;
+
+ }
+
+ ( void ) NavDisposeReply ( &reply );
+ }
+ }
+
+ DisposeNavEventUPP ( eventProc );
+
+ return ( err );
+
+ } // TimsPutFile
- OSErr anErr = noErr;
- NavReplyRecord reply;
- NavDialogOptions dialogOptions;
- OSType fileTypeToSave = 'TEXT';
- NavEventUPP eventProc = NewNavEventUPP(NavEventProc);
- anErr = NavGetDefaultDialogOptions(&dialogOptions);
- copystring(fileName, dialogOptions.savedFileName);
- copystring(prompt, dialogOptions.message);
- dialogOptions.dialogOptionFlags |= kNavNoTypePopup; /* 08/25/2000 AR */
- if (anErr == noErr)
- {
- anErr = NavPutFile( nil, &reply, &dialogOptions, eventProc,
- fileTypeToSave, 'LAND', nil);
-
- if (anErr == noErr && reply.validRecord)
- {
- AEKeyword theKeyword;
- DescType actualType;
- Size actualSize;
- FSSpec documentFSSpec;
-
- anErr = AEGetNthPtr(&(reply.selection), 1, typeFSS,
- &theKeyword, &actualType,
- &documentFSSpec, sizeof(documentFSSpec),
- &actualSize );
- if (anErr == noErr)
- {
-
- outReply->sfReplacing = reply.replacing;
- FSMakeFSSpec (documentFSSpec.vRefNum, documentFSSpec.parID, documentFSSpec.name, &(outReply->sfFile));
- outReply->sfGood = true;
- }
- // Always call NavCompleteSave() to complete
- #if TARGET_API_MAC_CARBON != 1
- anErr = NavCompleteSave(&reply, kNavTranslateInPlace);
- #endif
-
- (void) NavDisposeReply(&reply);
- }
- }
- DisposeNavEventUPP(eventProc);
- return anErr;
- }
-
-
OSErr getafile (bigstring prompt, ptrsftypelist filetypes, StandardFileReply * outReply, OSType filecreator) {
/*
@@ -1060,7 +1063,7 @@
NavDialogCreationOptions dialogOptions;
NavDialogRef dialogRef;
- NavEventUPP eventProc = NewNavEventUPP (NavEventProc);
+ // NavEventUPP eventProc = NewNavEventUPP (NavEventProc);
NavReplyRecord reply;
NavTypeListHandle typeList = nil;
OSErr anErr = noErr;
@@ -1088,7 +1091,7 @@
if (filetypes != nil) { // translate into a type list NavServices understands
NavTypeListPtr typesP = nil;
- SInt32 hSize = (sizeof (NavTypeList) + sizeof (OSType) * (filetypes->cttypes - 1));
+ SInt32 hSize = (sizeof (NavTypeList) + sizeof (OSType) * (filetypes->cttypes - 1));
newhandle (hSize, (Handle*) &typeList);
typesP = (NavTypeListPtr) *((Handle) typeList);
@@ -1099,7 +1102,7 @@
BlockMoveData (&(filetypes->types), typesP->osType, (Size) (sizeof (OSType) * filetypes->cttypes));
}
- anErr = NavCreateGetFileDialog (&dialogOptions, typeList, eventProc, NULL, NULL, NULL, &dialogRef);
+ anErr = NavCreateGetFileDialog (&dialogOptions, typeList, NULL, NULL, NULL, NULL, &dialogRef);
anErr = NavDialogRun (dialogRef);
@@ -1126,7 +1129,7 @@
}
}
- DisposeNavEventUPP (eventProc);
+ // DisposeNavEventUPP (eventProc);
NavDialogDispose (dialogRef);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|