|
From: <and...@us...> - 2010-06-13 18:20:42
|
Revision: 1831
http://frontierkernel.svn.sourceforge.net/frontierkernel/?rev=1831&view=rev
Author: andreradke
Date: 2010-06-13 18:20:35 +0000 (Sun, 13 Jun 2010)
Log Message:
-----------
Unhack sfdialog in filedialog.c and update to use modern Navigation Services APIs.
Modified Paths:
--------------
Frontier/trunk/Common/headers/file.h
Frontier/trunk/Common/source/filedialog.c
Frontier/trunk/Common/source/fileloop.c
Frontier/trunk/Common/source/fileops.c
Frontier/trunk/Common/source/fileverbs.c
Frontier/trunk/Common/source/opverbs.c
Frontier/trunk/build_Xcode/Frontier Universal Binary.xcodeproj/project.pbxproj
Modified: Frontier/trunk/Common/headers/file.h
===================================================================
--- Frontier/trunk/Common/headers/file.h 2010-01-24 21:17:34 UTC (rev 1830)
+++ Frontier/trunk/Common/headers/file.h 2010-06-13 18:20:35 UTC (rev 1831)
@@ -438,27 +438,8 @@
extern boolean sfdialog (tysfverb, bigstring, ptrsftypelist, ptrfilespec , OSType); /* 2005-10-06 creedon - added OSType */
extern boolean initfiledialog (void);
-
-#ifdef MACVERSION
-
- //Code change by Timothy Paustian Tuesday, June 20, 2000 2:22:02 PM
- //Nav services code for Frontier.
-
- extern OSErr TimsPutFile( bigstring, Str255, StandardFileReply *, OSType );
-
- extern OSErr TimsGetFolderOrVolume(bigstring prompt, SInt16 dialogType, StandardFileReply * outReply);
-
- extern pascal void NavEventProc(NavEventCallbackMessage callBackSelector,
- NavCBRecPtr callBackParms,
- NavCallBackUserData callBackUD);
-
- extern OSErr getafile (bigstring prompt, ptrsftypelist filetypes, StandardFileReply * outReply, OSType); /* 2005-09-23 creedon */
-
-#endif
-#endif
-
#pragma mark === filemp3.c ===
boolean getmp3info (const ptrfilespec , long *, long *, long *, long *, boolean *);
@@ -508,7 +489,7 @@
extern void fsnametobigstring(const tyfsnameptr fsname, bigstring bs); // 2009-09-05 aradke
- extern boolean CFStringRefToStr255 (CFStringRef input, StringPtr output); // 2006-08-08 creedon
+ extern boolean cfstringreftobigstring (CFStringRef input, StringPtr output); // 2006-08-08 creedon
extern OSStatus GetApplicationIconRef ( const ProcessSerialNumber * , const FSSpec* , IconRef * ); // 2006-06-04 creedon
@@ -556,3 +537,7 @@
extern boolean filestart (void); /*6.1b15 AR*/
+
+#endif //fileinclude
+
+
Modified: Frontier/trunk/Common/source/filedialog.c
===================================================================
--- Frontier/trunk/Common/source/filedialog.c 2010-01-24 21:17:34 UTC (rev 1830)
+++ Frontier/trunk/Common/source/filedialog.c 2010-06-13 18:20:35 UTC (rev 1831)
@@ -56,341 +56,21 @@
#ifdef MACVERSION
- #include "SetUpA5.h"
-
#define sfgetfileid 5000
#define sfputfileid 5001
#define sfgetfolderid 5002
#define sfgetdiskid 5003
- #define sfgetfolderbutton 11
- #define sfgetpromptitem 10
+ //Code change by Timothy Paustian Tuesday, June 20, 2000 2:22:02 PM
+ //Nav services code for Frontier.
+
+ static OSErr macputfiledialog (bigstring, ptrfilespec fs, OSType);
+ static OSErr macgetfiledialog (SInt16 dialogtype, bigstring prompt, ptrfilespec fs, OSType filecreator, ptrsftypelist filetypes); /* 2005-09-23 creedon */
- typedef struct tysfdata { /*data passed to hook routines*/
-
- StandardFileReply sfreply;
-
- bigstring sfprompt;
-
- Str63 sfname;
-
- ptrsftypelist sftypes;
- } tysfdata, *ptrsfdata;
-
#if ! TARGET_API_MAC_CARBON
- static pascal short sfputfilehook (short item, DialogPtr pdialog, tysfdata *pdata) {
-
- /*
- 6/11/93 dmb: added for System 7 Standard File
- */
-
- #ifdef flcomponent
- long curA5;
- #endif
-
- if (GetWRefCon (pdialog) != sfMainDialogRefCon)
- return (item);
-
- #ifdef flcomponent
-
- curA5 = SetUpAppA5 ();
-
- #endif
-
- if (item == sfHookFirstCall) {
-
- if ((*pdata).sfreply.sfFile.vRefNum != 0)
- item = sfHookChangeSelection;
- }
-
- #ifdef flcomponent
-
- RestoreA5 (curA5);
-
- #endif
-
- return (item);
- } /*sfputfilehook*/
-
-
- static pascal short sfprompthook (short item, DialogPtr pdialog, tysfdata *pdata) {
-
- /*
- 6/11/93 dmb: recoded to System 7 Standard File
- */
-
- #ifdef flcomponent
- long curA5;
- #endif
-
- if (GetWRefCon (pdialog) != sfMainDialogRefCon)
- return (item);
-
- #ifdef flcomponent
-
- curA5 = SetUpAppA5 ();
-
- #endif
-
- if (item == sfHookFirstCall) {
- Rect ritem, rdialog;
- CGrafPtr dialogPort;
- dialoggetobjectrect (pdialog, sfgetpromptitem, &ritem);
-
- //Code change by Timothy Paustian Sunday, April 30, 2000 9:20:45 PM
- //Changed to Opaque call for Carbon
-
- #if ACCESSOR_CALLS_ARE_FUNCTIONS == 1
- dialogPort = GetDialogPort(pdialog);
- GetPortBounds(dialogPort, &rdialog);
- #else
- //old code
- #pragma unused(dialogPort)
- rdialog = (*pdialog).portRect;
- #endif
-
- if (isemptystring ((*pdata).sfprompt)) {
-
- rdialog.bottom = ritem.top;
-
- /*
- hidedialogitem (pdialog, sfgetpromptitem);
- */
- }
- else {
-
- rdialog.bottom = ritem.bottom + 4;
-
- setdialogtext (pdialog, sfgetpromptitem, (*pdata).sfprompt);
- }
-
- sizewindow (pdialog, rdialog.right - rdialog.left, rdialog.bottom - rdialog.top);
-
- if ((*pdata).sfreply.sfFile.vRefNum != 0)
- item = sfHookChangeSelection;
- }
-
- #ifdef flcomponent
-
- RestoreA5 (curA5);
-
- #endif
-
- return (item);
- } /*sfprompthook*/
-
-
- static pascal short sffolderhook (short item, DialogPtr pdialog, tysfdata *pdata) {
-
- /*
- 12/5/91 dmb: if a folder is selected, use it instead of the current folder
-
- 1/30/92 dmb: added code to handle folder aliases, which are files
-
- 9/15/92 dmb: save path in sfstring (255 chars) instead of reply.fName (63 chars)
-
- 6/11/93 dmb: recoded to System 7 Standard File
-
- 2.1b9 dmb: push dialog port when ellipsizing button title
- */
-
- bigstring bs;
-
- #ifdef flcomponent
- long curA5;
- #endif
-
- if (GetWRefCon (pdialog) != sfMainDialogRefCon)
- return (item);
-
- #ifdef flcomponent
-
- curA5 = SetUpAppA5 ();
-
- #endif
-
- item = sfprompthook (item, pdialog, pdata);
-
- switch (item) {
-
- case sfgetfolderbutton: {
-
- if ((*pdata).sfreply.sfFlags & kIsAlias) { /*must be the alias of a folder*/
- Boolean flfolder, flwasalias;
- OSErr errcode;
-
- errcode = ResolveAliasFile (&(*pdata).sfreply.sfFile, true, &flfolder, &flwasalias);
-
- switch (errcode) {
-
- case noErr:
- break;
-
- case userCanceledErr:
- item = sfHookNullEvent;
-
- goto exit;
-
- default:
- getsystemerrorstring (errcode, bs);
-
- parsedialogstring (bs, (*pdata).sfreply.sfFile.name, nil, nil, nil, bs);
-
- customalert (sferrordialogid, bs);
-
- item = sfHookNullEvent;
-
- goto exit;
- }
- }
-
- (*pdata).sfreply.sfGood = true;
-
- item = sfItemCancelButton; /*force exit*/
-
- break;
- };
-
- case sfHookNullEvent:
- if (!equalstrings ((*pdata).sfname, (*pdata).sfreply.sfFile.name)) { /*selection changed*/
- FSSpec fs;
-
- fs = (*pdata).sfreply.sfFile;
-
- copystring (fs.name, (*pdata).sfname); /*remember for next time before changing*/
-
- if (isemptystring (fs.name)) /*nothing selected*/
- FSMakeFSSpec (fs.vRefNum, fs.parID, nil, &fs);
-
- copystring (fs.name, bs);
- //Code change by Timothy Paustian Monday, August 21, 2000 4:20:21 PM
- //pushport must have a CGrafPtr on OS X
- {
- CGrafPtr thePort;
- #if TARGET_API_MAC_CARBON == 1
- thePort = GetDialogPort(pdialog);
- #else
- thePort = (CGrafPtr)pdialog;
- #endif
-
- pushport (thePort);
- }
- ellipsize (bs, 72);
-
- popport ();
-
- setdialogbutton (pdialog, sfgetfolderbutton, bs);
- }
-
- break;
- }
-
- exit:
-
- #ifdef flcomponent
-
- RestoreA5 (curA5);
-
- #endif
-
- return (item);
- } /*sffolderhook*/
-
-
- static pascal short sfdiskhook (short item, DialogPtr pdialog, tysfdata *pdata) {
-
- /*
- 6/11/93 dmb: recoded to System 7 Standard File; back to using Drive
- button like Frontier 1.0.
- */
-
- #ifdef flcomponent
- long curA5;
- #endif
-
- if (GetWRefCon (pdialog) != sfMainDialogRefCon)
- return (item);
-
- #ifdef flcomponent
-
- curA5 = SetUpAppA5 ();
-
- #endif
-
- item = sfprompthook (item, pdialog, pdata);
-
- switch (item) {
-
- case sfItemOpenButton:
- case sfHookOpenFolder:
- #if 0
-
- (*pdata).sfreply.vRefNum = -SFSaveDisk; /*IM IV-72*/
-
- setemptystring ((*pdata).sfreply.fName); /*we just want the volume*/
-
- #endif
-
- FSMakeFSSpec ((*pdata).sfreply.sfFile.vRefNum, 0, 0, &(*pdata).sfreply.sfFile);
-
- (*pdata).sfreply.sfGood = true;
-
- item = sfItemCancelButton; /*force exit*/
-
- break;
-
- case sfHookGoToDesktop:
- item = sfHookGoToNextDrive;
-
- break;
-
- case sfHookNullEvent:
- if ((*pdata).sfreply.sfIsVolume) /*need to open volume to enable Drive button*/
- item = sfHookOpenFolder;
- else {
- if (isemptystring ((*pdata).sfreply.sfFile.name)) /*no selection*/
- item = sfHookGoToParent;
- }
-
- break;
-
- case sfHookGoToParent:
- item = sfHookNullEvent;
-
- break;
-
- default:
- if (item >= sfHookCharOffset) /*typing -- ignore*/
- item = sfHookNullEvent;
- }
-
- #ifdef flcomponent
-
- RestoreA5 (curA5);
-
- #endif
-
- return (item);
- } /*sfdiskhook*/
-
-
- static pascal Boolean onlyfoldersfilter (ParmBlkPtr pb, tysfdata *pdata) {
- #pragma unused (pdata)
-
- /*
- if (foldertest (pb))
- */
-
- if (pb->fileParam.ioFlAttrib & ioDirMask)
- return (0);
-
- return (-1); /*...don't show files*/
- } /*onlyfoldersfilter*/
-
-
static pascal Boolean knowntypesfilter (ParmBlkPtr pb, tysfdata *pdata) {
short i;
@@ -427,30 +107,14 @@
#if !TARGET_RT_MAC_CFM
- #define onlyfoldersfilterUPP ((FileFilterYDUPP) &onlyfoldersfilter)
#define knowntypesfilterUPP ((FileFilterYDUPP) &knowntypesfilter)
- #define sfputfilehookUPP (&sfputfilehook)
- #define sfprompthookUPP (&sfprompthook)
- #define sffolderhookUPP (&sffolderhook)
- #define sfdiskhookUPP (&sfdiskhook)
#else
#if !TARGET_API_MAC_CARBON
- static RoutineDescriptor onlyfoldersfilterDesc = BUILD_ROUTINE_DESCRIPTOR (uppFileFilterYDProcInfo, onlyfoldersfilter);
static RoutineDescriptor knowntypesfilterDesc = BUILD_ROUTINE_DESCRIPTOR (uppFileFilterYDProcInfo, knowntypesfilter);
- static RoutineDescriptor sfputfilehookDesc = BUILD_ROUTINE_DESCRIPTOR (uppDlgHookYDProcInfo, sfputfilehook);
- static RoutineDescriptor sfprompthookDesc = BUILD_ROUTINE_DESCRIPTOR (uppDlgHookYDProcInfo, sfprompthook);
- static RoutineDescriptor sffolderhookDesc = BUILD_ROUTINE_DESCRIPTOR (uppDlgHookYDProcInfo, sffolderhook);
- static RoutineDescriptor sfdiskhookDesc = BUILD_ROUTINE_DESCRIPTOR (uppDlgHookYDProcInfo, sfdiskhook);
-
- #define onlyfoldersfilterUPP (&onlyfoldersfilterDesc)
#define knowntypesfilterUPP (&knowntypesfilterDesc)
- #define sfputfilehookUPP (&sfputfilehookDesc)
- #define sfprompthookUPP (&sfprompthookDesc)
- #define sffolderhookUPP (&sffolderhookDesc)
- #define sfdiskhookUPP (&sfdiskhookDesc)
#endif
@@ -487,19 +151,20 @@
//
// return true if the user selected a file with one of the SF routines, return false otherwise.
//
- // as a bonus, we return the full path for the selected file in the path string.
- //
-
+
#ifdef MACVERSION
+ // 2010-03-14 aradke: pick up default location from fspec, type filtering checks extension if file type not set
//
+ // 2009-09-20 aradke: discontinue use of FSSpecs and "un-hack" this routine (see 2000-06-20)
+ //
// 2006-11-04 creedon: fix a problem with returning gibberish if fs was pointing to a volume
//
// 2006-09-15 creedon: minimally FSRef-ized
//
// 2005-10-06 creedon: added filecreator parameter, used for get file dialog
//
- // 2005-09-21 creedon: changed from TimsGetFile to getafile
+ // 2005-09-21 creedon: changed from TimsGetFile to macgetfiledialog
//
// 2000-06-20 Timothy Paustian: I am going to hack the heck out of this routine. See what you think
//
@@ -534,48 +199,12 @@
// 8/1/90 dmb: if filetype is zero, show all files by passing zero to SFGetFile
//
- tysfdata sfdata;
- FSSpec *fs = &sfdata.sfreply.sfFile;
- FSSpec fspect;
OSErr err = noErr;
OSType filetype = 0;
- 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 ( sfverb == sfputfileverb ) {
-
- if (oserror (macgetfsspec (fspec, &fspect)))
- return (false);
- }
-
if ( filetypes != NULL )
filetype = ( *filetypes ).types [ 0 ];
- copystring (bsprompt, sfdata.sfprompt);
-
- sfdata.sftypes = filetypes;
-
- // setemptystring (bs);
-
- if ( ! isemptystring ( fspect.name ) ) { // if path is included, set default dir and strip to file name
-
- *fs = fspect; /*seed directory & file selection*/
-
- /*
- if (pathtofilespec (fname, fs) && ((*fs).vRefNum != 0))
- copystring ((*fs).name, fname);
- else
- filefrompath (fname, fname);
- */
- }
-
- setstringlength (sfdata.sfname, -1); /*make sure it can't match fsspec*/
-
shellwritescrap (textscraptype);
shellactivate ();
@@ -583,27 +212,19 @@
switch (sfverb) {
case sfputfileverb:
- if(gCanUseNavServ) {
- err = TimsPutFile (bsprompt, ( *fs ).name, &sfdata.sfreply, filetype);
- }
-
+ err = macputfiledialog (bsprompt, fspec, filetype);
break;
case sfgetfileverb:
- err = getafile (bsprompt, filetypes, &sfdata.sfreply, filecreator);
-
+ err = macgetfiledialog (sfgetfileid, bsprompt, fspec, filecreator, filetypes);
break;
case sfgetfolderverb:
- if(gCanUseNavServ)
- err = TimsGetFolderOrVolume(bsprompt, sfgetfolderid, &sfdata.sfreply);
-
+ err = macgetfiledialog (sfgetfolderid, bsprompt, fspec, kNavGenericSignature, NULL);
break;
case sfgetdiskverb:
- if(gCanUseNavServ)
- err = TimsGetFolderOrVolume(bsprompt, sfgetdiskid, &sfdata.sfreply);
-
+ err = macgetfiledialog (sfgetdiskid, bsprompt, fspec, kNavGenericSignature, NULL);
break;
}
@@ -613,37 +234,11 @@
if (userCanceledErr == err)
return false;
- if (oserror(err))
+ if (oserror (err))
return false;
- if (sfdata.sfreply.sfGood) { // canonize
+ return (true);
- FSRef fsref;
- bigstring bs;
-
- setemptystring (bs);
-
- fspec->flags.flvolume = (fs->parID == fsRtParID);
-
- if (fspec->flags.flvolume)
- copystring (fs->name, bs);
-
- err = FSMakeFSRef (fs->vRefNum, fs->parID, bs, &fsref);
-
- if (fspec->flags.flvolume) {
- fspec->ref = fsref;
- HFSNameGetUnicodeName (fs->name, kTextEncodingUnknown, &fspec->name);
- }
- else {
- macmakefilespec (&fsref, fspec);
- }
-
- return (true);
-
- }
-
- return (false);
-
#endif // MACVERSION
#ifdef WIN95VERSION
@@ -1003,212 +598,356 @@
} /*initfile*/
- OSErr TimsPutFile ( bigstring prompt, Str255 fileName, StandardFileReply *outReply, OSType filetype ) {
+ typedef struct {
+ ptrfilespec fslocation;
+ ptrsftypelist filtertypes;
+ OSType filecreator;
+ } navcallbackcontext;
+
+
+ pascal static void macnaveventcallback(NavEventCallbackMessage cbselector, NavCBRecPtr cbparams, void* refcon) {
+
+ // 2010-03-13 aradke: set initial location of file navigation dialog
+ switch (cbselector) {
+
+ case kNavCBStart: {
+
+ navcallbackcontext* context = (navcallbackcontext*) refcon;
+ ptrfilespec fs = context->fslocation;
+ FSRef fsref;
+
+ if (macgetfsref (fs, &fsref) != noErr) {
+
+ fsref = fs->ref; // try parent for putfile
+ }
+
+ if (FSRefValid (&fsref)) {
+
+ OSErr err;
+ AEDesc desc;
+
+ err = AECreateDesc (typeFSRef, &fsref, sizeof(FSRef), &desc);
+
+ if (err == noErr)
+ err = NavCustomControl (cbparams->context, kNavCtlSetLocation, (void*)&desc);
+ }
+ }
+ }/*switch*/
+ } /*macfiledialogeventcallback*/
+
+
+ pascal static boolean macnavfiltercallback(AEDesc *item, void* info, void* refcon, NavFilterModes mode) {
+
+ // 2010-03-13 aradke: filter by file creator, type and extension.
+ // file.type(f) returns the extension if no actual file type is set.
+ // with this callback, the file will be shown if the specified list of
+ // file types contains file.type(f).
+
+ if (mode == kNavFilteringBrowserList && item->descriptorType == typeFSRef) {
+
+ FSRef fsref;
+ LSItemInfoRecord iteminfo;
+ boolean flcontainer, flapp, flpackage;
+ OSErr err;
+
+ err = AEGetDescData (item, &fsref, sizeof(FSRef));
+
+ if (err != noErr)
+ return (false);
+
+ err = LSCopyItemInfoForRef (&fsref, kLSRequestAllInfo, &iteminfo);
+
+ if (err != noErr)
+ return (false);
+
+ flcontainer = ((iteminfo.flags & kLSItemInfoIsContainer) != 0);
+ flapp = ((iteminfo.flags & kLSItemInfoIsApplication) != 0);
+ flpackage = ((iteminfo.flags & kLSItemInfoIsPackage) != 0);
+
+ if (flcontainer && !flpackage && !flapp) {
+
+ return (true); // always show plain folders
+ }
+
+ navcallbackcontext* context = (navcallbackcontext*) refcon;
+ OSType filtercreator = context->filecreator;
+ ptrsftypelist filtertypes = context->filtertypes;
+
+ if (filtercreator != kNavGenericSignature)
+ if (iteminfo.creator != filtercreator)
+ return (false);
+
+ if (filtertypes == NULL || ((filtertypes->cttypes > 0) && (filtertypes->types[0] == kUnknownType)))
+ return (true);
+
+ OSType filetype = iteminfo.filetype;
+
+ if (filetype == kLSUnknownType) { // try file extension
+
+ if (iteminfo.extension == NULL)
+ return (false);
+
+ bigstring bsext;
+
+ cfstringreftobigstring (iteminfo.extension, bsext);
+
+ filetype = ' '; // init to four spaces in case actual extension is shorter
+
+ stringtoostype (bsext, &filetype);
+ }
+
+ for (short k = 0; k < filtertypes->cttypes; ++k) {
+
+ if ((filetype == filtertypes->types[k]) || (filtertypes->types[k] == kNavGenericSignature))
+ return (true);
+ }
+ }
+
+ return (false);
+ } /*macnavfiltercallback*/
+
+
+ static OSErr macputfiledialog (bigstring prompt, ptrfilespec fs, OSType filetype) {
+
+ // 2009-09-20 aradke: discontinue use of FSSpecs
+ //
// 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 );
+ NavDialogCreationOptions options;
+ NavDialogRef dialog;
+ NavEventUPP eventupp;
+ navcallbackcontext context;
+ NavReplyRecord reply;
+ OSErr err = noErr;
+ boolean flfolder = false; // default
if ( filetype == 0 )
filetype = 'TEXT';
- err = NavGetDefaultDialogOptions ( &dialogOptions );
- copystring ( fileName, dialogOptions.savedFileName );
- copystring (prompt, dialogOptions.message );
- dialogOptions.dialogOptionFlags |= kNavNoTypePopup; // 2000-08-25 AR
+ err = NavGetDefaultDialogCreationOptions (&options);
- if (err == noErr) {
+ if (err != noErr)
+ return (err);
- err = NavPutFile ( nil, &reply, &dialogOptions, eventProc, filetype, 'LAND', nil );
+ options.clientName = CFStringCreateWithCString (kCFAllocatorDefault, APPNAME_SHORT, kCFStringEncodingMacRoman);
+
+ options.message = CFStringCreateWithPascalString (kCFAllocatorDefault, prompt, kCFStringEncodingMacRoman);
+
+ disablelangerror();
+
+ fileisfolder(fs, &flfolder);
+
+ enablelangerror();
+
+ if (!flfolder) {
+ options.saveFileName = CFStringCreateWithCharacters (kCFAllocatorDefault, fs->name.unicode, fs->name.length);
+ }
+ else {
+ bigstring bsuntitled;
- if ( err == noErr && reply.validRecord ) {
+ setemptystring (bsuntitled);
- AEKeyword theKeyword;
- DescType actualType;
- Size actualSize;
- FSSpec documentFSSpec;
+ getuntitledfilename (bsuntitled);
+
+ options.saveFileName = CFStringCreateWithPascalString (kCFAllocatorDefault, bsuntitled, kCFStringEncodingMacRoman);
+ }
+
+ options.optionFlags |= kNavNoTypePopup; // 2000-08-25 AR
+
+ context.fslocation = fs;
+ context.filtertypes = NULL;
+ context.filecreator = kNavGenericSignature;
+
+ eventupp = NewNavEventUPP(&macnaveventcallback);
+
+ err = NavCreatePutFileDialog (&options, filetype, 'LAND', eventupp, &context, &dialog);
+
+ if (err == noErr) {
- err = AEGetNthPtr ( &( reply.selection ), 1, typeFSS, &theKeyword, &actualType, &documentFSSpec,
- sizeof ( documentFSSpec ), &actualSize );
-
+ err = NavDialogRun(dialog);
+
+ if (err == noErr) {
+
+ err = NavDialogGetReply (dialog, &reply);
+
if (err == noErr) {
+
+ if (reply.validRecord) { // get fsref and name to make filespec
- outReply->sfReplacing = reply.replacing;
+ AEKeyword key;
+ DescType actualtype;
+ Size actualsize;
+ FSRef parentref;
+
+ err = AEGetNthPtr (&(reply.selection), 1, typeFSRef, &key, &actualtype, &parentref, sizeof (parentref), &actualsize);
+
+ if (err == noErr) {
+
+ assert (actualtype == typeFSRef);
+
+ fs->flags.flvolume = false;
+
+ fs->ref = parentref;
+
+ fs->name.length = CFStringGetBytes (reply.saveFileName, CFRangeMake (0, min(CFStringGetLength (reply.saveFileName), 255)),
+ kCFStringEncodingUnicode, 0, false, (UInt8 *)(fs->name.unicode), 255, NULL );
+ }
+ }
+ else {
+ err = userCanceledErr;
+ }
- FSMakeFSSpec (documentFSSpec.vRefNum, documentFSSpec.parID, documentFSSpec.name, &(outReply->sfFile));
- outReply->sfGood = true;
-
+ NavDisposeReply (&reply);
}
-
- ( void ) NavDisposeReply ( &reply );
+ }
+
+ NavDialogDispose (dialog);
}
- }
- DisposeNavEventUPP ( eventProc );
+ DisposeNavEventUPP(eventupp);
- return ( err );
+ CFRelease (options.clientName);
+ CFRelease (options.message);
+ CFRelease (options.saveFileName);
+
+ return (err);
- } // TimsPutFile
+ } // macputfiledialog
- OSErr getafile (bigstring prompt, ptrsftypelist filetypes, StandardFileReply * outReply, OSType filecreator) {
+ static OSErr macgetfiledialog (SInt16 dialogtype, bigstring prompt, ptrfilespec fs, OSType filecreator, ptrsftypelist filetypes) {
- /*
- 2005-10-06 creedon: added filecreator parameter
-
- 2005-09-21 creedon: created, cribbed from TimsGetFile
- */
+ // 2009-09-20 aradke: discontinue use of FSSpecs, merge with getfolderorvolumedialog
+ //
+ // 2005-10-06 creedon: added filecreator parameter
+ //
+ // 2005-09-21 creedon: created, cribbed from TimsGetFile
- NavDialogCreationOptions dialogOptions;
- NavDialogRef dialogRef;
- // NavEventUPP eventProc = NewNavEventUPP (NavEventProc);
- NavReplyRecord reply;
- NavTypeListHandle typeList = nil;
- OSErr anErr = noErr;
+ NavDialogCreationOptions options;
+ NavDialogRef dialog;
+ NavEventUPP eventupp;
+ NavObjectFilterUPP filterupp;
+ navcallbackcontext context;
+ NavReplyRecord reply;
+ //NavTypeListHandle typeList = NULL;
+ OSErr err;
- anErr = NavGetDefaultDialogCreationOptions (&dialogOptions);
+ err = NavGetDefaultDialogCreationOptions (&options);
- dialogOptions.clientName = CFStringCreateWithCString ( kCFAllocatorDefault, APPNAME_SHORT, kCFStringEncodingMacRoman );
- dialogOptions.message = CFStringCreateWithPascalString ( kCFAllocatorDefault, prompt, kCFStringEncodingMacRoman );
+ if (err != noErr)
+ return (err);
- if (anErr == noErr) {
+ options.clientName = CFStringCreateWithCString (kCFAllocatorDefault, APPNAME_SHORT, kCFStringEncodingMacRoman);
- if (filetypes == nil)
- dialogOptions.optionFlags -= kNavNoTypePopup;
- else
- dialogOptions.optionFlags += kNavAllFilesInPopup; // add all documents to show pop-up
+ options.message = CFStringCreateWithPascalString (kCFAllocatorDefault, prompt, kCFStringEncodingMacRoman );
+
+ options.optionFlags &= ~kNavAllowMultipleFiles; // no multiple files for now
+
+ options.optionFlags &= ~kNavAllowPreviews; // clear preview option
+
+ options.optionFlags |= kNavSupportPackages; // show packages
+
+ options.optionFlags |= kNavNoTypePopup; // disable type pop-up
- dialogOptions.optionFlags ^=kNavAllowMultipleFiles; //no multiple files for now
-
- dialogOptions.optionFlags ^= kNavAllowPreviews; // clear preview option
-
- dialogOptions.optionFlags += kNavSupportPackages; // see packages
-
- // dialogOptions.dialogOptionFlags += kNavAllowOpenPackages; // can open packages
-
- if (filetypes != nil) { // translate into a type list NavServices understands
-
- NavTypeListPtr typesP = nil;
- SInt32 hSize = (sizeof (NavTypeList) + sizeof (OSType) * (filetypes->cttypes - 1));
- newhandle (hSize, (Handle*) &typeList);
- typesP = (NavTypeListPtr) *((Handle) typeList);
+ // options.dialogOptionFlags |= kNavAllowOpenPackages; // can open packages
+
+ eventupp = NewNavEventUPP(&macnaveventcallback);
+ filterupp = NewNavObjectFilterUPP(&macnavfiltercallback);
+
+ context.fslocation = fs;
+ context.filtertypes = filetypes;
+ context.filecreator = filecreator;
+
+ if ((dialogtype == sfgetfileid)) { // translate into a type list NavServices understands
+
+ if ((filetypes != NULL) || (filecreator != kNavGenericSignature)) {
+ /*
+ NavTypeListPtr typesP = nil;
+ SInt32 hSize = (sizeof (NavTypeList) + sizeof (OSType) * (filetypes->cttypes - 1));
+
+ newhandle (hSize, (Handle*) &typeList);
+
+ typesP = (NavTypeListPtr) *((Handle) typeList);
+
typesP->componentSignature = filecreator;
typesP->reserved = 0;
typesP->osTypeCount = filetypes->cttypes;
BlockMoveData (&(filetypes->types), typesP->osType, (Size) (sizeof (OSType) * filetypes->cttypes));
+
+ options.optionFlags |= kNavAllFilesInPopup; // add "All Files" to pop-up
+ options.optionFlags |= kNavSelectAllReadableItem; // select "All Readable Items" in pop-up
+ options.optionFlags &= ~kNavNoTypePopup; // re-enable type pop-up
+
+ err = NavCreateGetFileDialog (&options, typeList, eventupp, NULL, filterupp, &context, &dialog);
+ */
+
+ err = NavCreateGetFileDialog (&options, NULL, eventupp, NULL, filterupp, &context, &dialog);
}
-
- anErr = NavCreateGetFileDialog (&dialogOptions, typeList, NULL, NULL, NULL, NULL, &dialogRef);
+ else {
- anErr = NavDialogRun (dialogRef);
+ err = NavCreateGetFileDialog (&options, NULL, eventupp, NULL, NULL, &context, &dialog);
+ }
+ }
+ else if (dialogtype == sfgetfolderid) {
+
+ err = NavCreateChooseFolderDialog (&options, eventupp, NULL, &context, &dialog);
+ }
+ else {
+ assert (dialogtype == sfgetdiskid);
- anErr = NavDialogGetReply (dialogRef, &reply);
+ err = NavCreateChooseVolumeDialog (&options, eventupp, NULL, &context, &dialog);
+ }
- if (anErr == noErr && reply.validRecord) {
+ if (err == noErr) {
+
+ err = NavDialogRun (dialog);
- AEKeyword theKeyword;
- DescType actualType;
- Size actualSize;
- FSSpec documentFSSpec;
-
- anErr = AEGetNthPtr (&(reply.selection), 1, typeFSS, &theKeyword, &actualType, &documentFSSpec, sizeof (documentFSSpec), &actualSize); // get a pointer to selected file
+ if (err == noErr) {
+
+ err = NavDialogGetReply (dialog, &reply);
- assert (actualType == typeFSS);
-
- if (anErr == noErr) {
- FSMakeFSSpec (documentFSSpec.vRefNum, documentFSSpec.parID, documentFSSpec.name, &(outReply->sfFile));
-
- outReply->sfGood = true;
- }
+ if (err == noErr) {
- anErr = NavDisposeReply (&reply); // dispose of NavReplyRecord, resources, descriptors
+ if (reply.validRecord) {
+
+ AEKeyword key;
+ DescType actualtype;
+ Size actualsize;
+ FSRef fsref;
+
+ err = AEGetNthPtr (&(reply.selection), 1, typeFSRef, &key, &actualtype, &fsref, sizeof (fsref), &actualsize);
+
+ if (err == noErr) {
+
+ assert (actualtype == typeFSRef);
+
+ err = macmakefilespec (&fsref, fs);
+ }
+ }
+ else {
+ err = userCanceledErr;
+ }
+
+ NavDisposeReply (&reply); // dispose of NavReplyRecord, resources, descriptors
+ }
}
+
+ NavDialogDispose (dialog);
}
-
- // DisposeNavEventUPP (eventProc);
- NavDialogDispose (dialogRef);
+ DisposeNavEventUPP(eventupp);
+ DisposeNavObjectFilterUPP(filterupp);
+
+ CFRelease (options.clientName);
+ CFRelease (options.message);
+
+ //disposehandle ((Handle) typeList);
- return anErr;
- } /* getafile */
+ return (err);
+ } /* macgetfiledialog */
-
- OSErr
- TimsGetFolderOrVolume(bigstring prompt, SInt16 dialogType, StandardFileReply * outReply)
- {
- NavDialogOptions dialogOptions;
- NavEventUPP eventProc = NewNavEventUPP(NavEventProc);
- OSErr anErr = noErr;
- NavReplyRecord reply;
-
- // Specify default options for dialog box
- //we don't really need to modify this, but it is needed for NavChooseFolder
- anErr = NavGetDefaultDialogOptions(&dialogOptions);
- copystring(prompt, dialogOptions.message);
-
- if(anErr == noErr)
- {
- //display the dialog
- if(sfgetfolderid == dialogType)
- anErr = NavChooseFolder(nil, &reply, &dialogOptions, eventProc, nil, nil);
- else
- {
- assert(sfgetdiskid == dialogType);
- anErr = NavChooseVolume(nil, &reply, &dialogOptions, eventProc, nil, nil);
- }
-
- if (anErr == noErr && reply.validRecord)
- {
- AEKeyword theKeyword;
- DescType actualType;
- Size actualSize;
- FSSpec documentFSSpec;
-
- // Get a pointer to selected file
- anErr = AEGetNthPtr(&(reply.selection), 1,
- typeFSS, &theKeyword,
- &actualType, &documentFSSpec,
- sizeof(documentFSSpec),
- &actualSize);
- assert(actualType == typeFSS);
- if (anErr == noErr)
- {
- FSMakeFSSpec (documentFSSpec.vRefNum, documentFSSpec.parID, documentFSSpec.name, &(outReply->sfFile));
- outReply->sfGood = true;
- }
- // Dispose of NavReplyRecord
- anErr = NavDisposeReply(&reply);
- }
- }
- DisposeNavEventUPP (eventProc);
- return anErr;
- }
-
-
- //Code change by Timothy Paustian Tuesday, June 20, 2000 9:07:26 PM
- //a very simple event proc so that Nav file service dialogs are movable and resizable.
- pascal void NavEventProc(NavEventCallbackMessage callBackSelector,
- NavCBRecPtr callBackParms,
- NavCallBackUserData callBackUD)
- {
- #pragma unused(callBackUD)
- if (callBackSelector == kNavCBEvent)
- {
- if( ((callBackParms->eventData).eventDataParms).event->what == updateEvt)
- {
- //I was having a crash due to getting the window ptr outside the switch statement.
- // This now works.
- //10/30/00 Timothy Paustian
- WindowPtr window = (WindowPtr)(((callBackParms->eventData).eventDataParms).event)->message;
- shellupdatenow(window);
- }
- }
- }
-
#endif
Modified: Frontier/trunk/Common/source/fileloop.c
===================================================================
--- Frontier/trunk/Common/source/fileloop.c 2010-01-24 21:17:34 UTC (rev 1830)
+++ Frontier/trunk/Common/source/fileloop.c 2010-06-13 18:20:35 UTC (rev 1831)
@@ -364,13 +364,13 @@
if ( fs.parID == fsRtParID ) {
- if ( equalstrings ( bsfile, "\x0F" ".Spotlight-V100" ) ) // skip Spotlight
+ if ( equalstrings ( bsfile, BIGSTRING ("\x0F" ".Spotlight-V100") ) ) // skip Spotlight
continue;
- if ( equalstrings ( bsfile, "\x04" ".vol" ) ) // skip .vol ( volfs )
+ if ( equalstrings ( bsfile, BIGSTRING ("\x04" ".vol" ) ) ) // skip .vol ( volfs )
continue;
- if ( equalstrings ( bsfile, "\x07" "Volumes" ) ) // skip Volumes
+ if ( equalstrings ( bsfile, BIGSTRING ("\x07" "Volumes") ) ) // skip Volumes
continue;
}
@@ -675,7 +675,7 @@
texthandletostring (hdata, bs);
- *flfolder = bs [*bs] == ':';
+ *flfolder = (lastchar (bs) == ':');
if (*flfolder)
--*bs;
Modified: Frontier/trunk/Common/source/fileops.c
===================================================================
--- Frontier/trunk/Common/source/fileops.c 2010-01-24 21:17:34 UTC (rev 1830)
+++ Frontier/trunk/Common/source/fileops.c 2010-06-13 18:20:35 UTC (rev 1831)
@@ -661,7 +661,7 @@
status = LSCopyItemInfoForRef ( ( *pb ).ref, kLSRequestExtension, &iteminfo );
if ( iteminfo.extension != NULL )
- CFStringRefToStr255 ( iteminfo.extension, bsext );
+ cfstringreftobigstring ( iteminfo.extension, bsext );
if ( isemptystring ( bsext ) || ( stringlength ( bsext ) > 4 ) ) // no extension
@@ -3739,7 +3739,7 @@
fss->vRefNum = catalogInfo.volume;
fss->parID = catalogInfo.nodeID;
- fsnametobigstring (&fs->name, fss->name);
+ fsnametobigstring (&fs->name, fss->name); // FIXME: what if fs->name is longer than fss->name has room for?
return (noErr);
} /*macgetfsspec*/
@@ -3907,14 +3907,14 @@
csr = CFStringCreateWithCharacters (kCFAllocatorDefault, fsname->unicode, fsname->length);
- CFStringRefToStr255 (csr, bs);
+ cfstringreftobigstring (csr, bs);
CFRelease (csr);
} /*fsnametobigstring*/
- boolean CFStringRefToStr255 (CFStringRef input, StringPtr output) {
+ boolean cfstringreftobigstring (CFStringRef input, StringPtr output) {
/*
2006-08-08 creedon: created, cribbed from < http://developer.apple.com/carbon/tipsandtricks.html#CFStringFromUnicode >
@@ -3932,7 +3932,7 @@
return (true);
- } // CFStringRefToStr255
+ } //cfstringreftobigstring
#endif /*MACVERSION*/
Modified: Frontier/trunk/Common/source/fileverbs.c
===================================================================
--- Frontier/trunk/Common/source/fileverbs.c 2010-01-24 21:17:34 UTC (rev 1830)
+++ Frontier/trunk/Common/source/fileverbs.c 2010-06-13 18:20:35 UTC (rev 1831)
@@ -748,7 +748,7 @@
}
- clearbytes (&fs, sizeof (fs));
+ clearfilespec (&fs);
//
// if (idstringvalue (htable, bsvarname, bsfname))
@@ -776,7 +776,7 @@
lastword ( bs, '.', bsext);
- if ( ! ( ( stringlength ( bs ) == stringlength ( bsext ) ) || ( stringlength ( bsext ) > 4 ) ) ) { // extension
+ if (!((stringlength (bs) == stringlength (bsext)) || (stringlength (bsext) > 4))) { // extension
stringtoostype (bsext, &ostype);
filetypes.cttypes = 1;
filetypes.types [0] = ostype;
@@ -2715,7 +2715,7 @@
CFStringRef csr = CFStringCreateWithCString ( kCFAllocatorDefault, bs, kCFStringEncodingUTF8 );
- CFStringRefToStr255 ( csr, bs );
+ cfstringreftobigstring ( csr, bs );
CFRelease ( csr );
Modified: Frontier/trunk/Common/source/opverbs.c
===================================================================
--- Frontier/trunk/Common/source/opverbs.c 2010-01-24 21:17:34 UTC (rev 1830)
+++ Frontier/trunk/Common/source/opverbs.c 2010-06-13 18:20:35 UTC (rev 1831)
@@ -1432,7 +1432,7 @@
status = LSCopyItemInfoForRef ( &fsref, kLSRequestTypeCreator || kLSRequestExtension, &iteminfo );
- CFStringRefToStr255 ( iteminfo.extension, bs );
+ cfstringreftobigstring ( iteminfo.extension, bs );
alllower ( bs );
Modified: Frontier/trunk/build_Xcode/Frontier Universal Binary.xcodeproj/project.pbxproj
===================================================================
--- Frontier/trunk/build_Xcode/Frontier Universal Binary.xcodeproj/project.pbxproj 2010-01-24 21:17:34 UTC (rev 1830)
+++ Frontier/trunk/build_Xcode/Frontier Universal Binary.xcodeproj/project.pbxproj 2010-06-13 18:20:35 UTC (rev 1831)
@@ -4084,7 +4084,6 @@
"-Wmost",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
- "-Wno-long-double",
);
ZERO_LINK = NO;
};
@@ -4143,7 +4142,6 @@
"-Wmost",
"-Wno-four-char-constants",
"-Wno-unknown-pragmas",
- "-Wno-long-double",
);
ZERO_LINK = NO;
};
@@ -4156,6 +4154,7 @@
ppc,
i386,
);
+ GCC_VERSION = 4.0;
OTHER_CFLAGS = "";
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
};
@@ -4168,6 +4167,7 @@
ppc,
i386,
);
+ GCC_VERSION = 4.0;
OTHER_CFLAGS = "";
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk;
};
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|