|
From: creedon <icr...@us...> - 2005-09-29 21:36:39
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23810 Modified Files: filedialog.c Log Message: changed mac open file dialog to make it easier to access Mac OS X style osax. Index: filedialog.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/filedialog.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** filedialog.c 11 Jan 2005 22:48:05 -0000 1.5 --- filedialog.c 29 Sep 2005 21:36:29 -0000 1.6 *************** *** 49,52 **** --- 49,53 ---- #include "shell.rsrc.h" #include "langinternal.h" /*for langbackgroundtask*/ + #include "versions.h" /* 2005-09-23 creedon */ *************** *** 557,561 **** case sfgetfileverb: if(gCanUseNavServ) ! anErr = TimsGetFile(bsprompt, filetypes, &sfdata.sfreply); #if !TARGET_API_MAC_CARBON else --- 558,562 ---- case sfgetfileverb: if(gCanUseNavServ) ! anErr = getafile (bsprompt, filetypes, &sfdata.sfreply); /* 2005-09-21 creedon - changed from TimsGetFile to getafile*/ #if !TARGET_API_MAC_CARBON else *************** *** 1053,1134 **** ! OSErr ! TimsGetFile(bigstring prompt, ptrsftypelist filetypes, StandardFileReply * outReply) ! { ! NavDialogOptions dialogOptions; ! NavEventUPP eventProc = NewNavEventUPP(NavEventProc); ! OSErr anErr = noErr; ! NavTypeListHandle typeList = nil; ! NavReplyRecord reply; ! ! // Specify default options for dialog box ! anErr = NavGetDefaultDialogOptions(&dialogOptions); ! copystring(prompt, dialogOptions.message); ! if (anErr == noErr) ! { ! // Clear preview option ! dialogOptions.dialogOptionFlags ^= kNavAllowPreviews; ! //no multiple files for now. ! dialogOptions.dialogOptionFlags ^=kNavAllowMultipleFiles; ! ! dialogOptions.dialogOptionFlags += kNavSupportPackages; ! // Create the typelist dynamically. ! /*struct tysftypelist { ! short cttypes; ! OSType types [maxsftypelist]; ! }*/ ! //I need to translate this into a type list NavServices understands. - if (filetypes != nil) - { NavTypeListPtr typesP = nil; ! SInt32 hSize = (sizeof(NavTypeList) + ! sizeof(OSType) * (filetypes->cttypes - 1)); ! newhandle(hSize, (Handle*) &typeList); ! typesP = (NavTypeListPtr) *((Handle) typeList); ! typesP->componentSignature = 'LAND'; ! typesP->reserved = 0; ! typesP->osTypeCount = filetypes->cttypes; ! BlockMoveData(&(filetypes->types), typesP->osType, ! (Size) (sizeof(OSType) * filetypes->cttypes)); ! } ! // Call NavGetFile() with specified options and ! // declare our app-defined functions and type list ! anErr = NavChooseFile (nil, &reply, &dialogOptions, ! eventProc, nil, nil, typeList, 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, resources, descriptors ! anErr = NavDisposeReply(&reply); ! } ! } ! DisposeNavEventUPP(eventProc); ! return anErr; ! } --- 1054,1144 ---- ! OSErr getafile (bigstring prompt, ptrsftypelist filetypes, StandardFileReply * outReply) { ! ! /* 2005-09-21 creedon: created, cribbed from TimsGetFile */ ! ! NavDialogCreationOptions dialogOptions; ! NavDialogRef dialogRef; ! NavEventUPP eventProc = NewNavEventUPP (NavEventProc); ! NavReplyRecord reply; ! NavTypeListHandle typeList = nil; ! OSErr anErr = noErr; ! ! anErr = NavGetDefaultDialogCreationOptions (&dialogOptions); ! dialogOptions.clientName = CFStringCreateWithCString (NULL, APPNAME_SHORT, kCFStringEncodingMacRoman); ! dialogOptions.message = CFStringCreateWithPascalString (NULL, prompt, kCFStringEncodingMacRoman); ! if (anErr == noErr) { ! ! if (filetypes == nil) ! dialogOptions.optionFlags -= kNavNoTypePopup; ! else ! dialogOptions.optionFlags += kNavAllFilesInPopup; // add all documents to show 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); ! OSType creator = 'LAND'; ! if (filetypes->cttypes <= 1) ! creator = kNavGenericSignature; ! typesP->componentSignature = creator; ! typesP->reserved = 0; ! typesP->osTypeCount = filetypes->cttypes; ! ! BlockMoveData(&(filetypes->types), typesP->osType, (Size) (sizeof(OSType) * filetypes->cttypes)); ! } ! anErr = NavCreateGetFileDialog (&dialogOptions, typeList, eventProc, NULL, NULL, NULL, &dialogRef); ! anErr = NavDialogRun (dialogRef); ! ! anErr = NavDialogGetReply (dialogRef, &reply); ! ! 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; ! } ! ! anErr = NavDisposeReply (&reply); // dispose of NavReplyRecord, resources, descriptors ! } ! } ! ! DisposeNavEventUPP (eventProc); ! ! NavDialogDispose (dialogRef); ! return anErr; ! } /* getafile */ |