eudora-mac/navUtils.c

1 line
40 KiB
C
Raw Permalink Normal View History

2018-05-23 09:59:15 +00:00
/* Copyright (c) 2017, Computer History Museum All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted (subject to the limitations in the disclaimer below) provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of Computer History Museum nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #include "navUtils.h" #define FILE_NUM 118 #pragma segment navUtils extern Boolean DoUpdate(WindowPtr topWin,EventRecord *event); extern OSErr InsertGraphicFile(MyWindowPtr win,FSSpecPtr spec); extern OSErr InsertTextFile(MyWindowPtr win, FSSpecPtr spec, Boolean rich, Boolean delSP); typedef struct { ZoneAndResFileRec zoneAndResFile; // DialogPtr theDialog; // short defaultItem; Boolean customControlsCreated; // Safety for Nav 1.0 Boolean insertDefault; // Insert button is the default // Boolean insertHit; // The insert button was hit // Boolean defaultButtonIsInsert; } attachInsertRec, *attachInsertRecPtr, **attachInsertRecHandle; pascal void attachNavProc (NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, attachInsertRecPtr attachInsertPtr); pascal void updateNavProc (NavEventCallbackMessage callBackSelector, NavCBRecPtr callBackParms, ZoneAndResFilePtr zoneAndResFile); // OSErr HandleNavEvent (DialogPtr navDialog, EventRecord *event, NavDialogRef context, attachInsertRecPtr attachInsertPtr); void NegotiateCustomRectSize (Rect *customRect, short minWidth, short minHeight); OSErr SelectNavEntry (DialogPtr navDialog, NavDialogRef context, AEDescList *fileList, attachInsertRecPtr attachInsertPtr); OSErr AddDialogItemsToNav (short ditlResID, NavDialogRef context); short GetCustomNavItem (NavDialogRef context, short customNavItem); pascal Boolean InsertNavFilterProc ( AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode ); void SeeIfWeShouldPreloadNav (void) { OSErr theError; if (UseNavServices () && PrefIsSet (PREF_PRELOAD_NAV)) if (theError = NavLoad ()) DieWithError (NAV_COULD_NOT_LOAD_ERR, theError); } Boolean UseNavServices (void) { UInt32 version; Boolean useNav; if (HaveOSX ()) return (true); if (useNav = NavServicesAvailable ()) { version = NavLibraryVersion (); useNav = (version >= 0x01100000); } return (useNav && version); } void GetZoneAndResFile (ZoneAndResFilePtr zoneAndResFile) { zoneAndResFile->resFile = CurResFile (); } void SetZoneAndResFile (ZoneAndResFilePtr zoneAndResFile) { UseResFile (zoneAndResFile->resFile); } pascal Boolean InsertNavFilterProc ( AEDesc *theItem, void *info, void *callBackUD, NavFilterModes filterMode ) { OSErr err = noErr; NavFileOrFolderInfo *theInfo; FSSpec spec; Boolean wasAlias; FInfo fInfo; // if it's not a file