+ // this was always unset in the old code
+ dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation;
+
+ wxMacCFStringHolder message(m_message, m_font.GetEncoding());
+ dialogCreateOptions.windowTitle = message;
+
+ wxMacCFStringHolder defaultFileName(m_fileName, m_font.GetEncoding());
+ dialogCreateOptions.saveFileName = defaultFileName;
+
+
+ NavDialogRef dialog;
+ NavObjectFilterUPP navFilterUPP = NULL;
+ OpenUserDataRec myData;
+ myData.defaultLocation = m_dir;
+
+ MakeUserDataRec(&myData , m_wildCard);
+ myData.currentfilter = m_filterIndex;
+ size_t numFilters = myData.extensions.GetCount();
+ if (numFilters)
+ {
+ CFMutableArrayRef popup = CFArrayCreateMutable( kCFAllocatorDefault ,
+ numFilters , &kCFTypeArrayCallBacks ) ;
+ dialogCreateOptions.popupExtension = popup ;
+ myData.menuitems = dialogCreateOptions.popupExtension ;
+ for ( size_t i = 0 ; i < numFilters ; ++i )
+ {
+ CFArrayAppendValue( popup , (CFStringRef) wxMacCFStringHolder( myData.name[i] , m_font.GetEncoding() ) ) ;
+ }
+ }
+
+ if (HasFdFlag(wxFD_SAVE))
+ {
+ myData.saveMode = true;
+
+ dialogCreateOptions.optionFlags |= kNavDontAutoTranslate;
+ dialogCreateOptions.optionFlags |= kNavDontAddTranslateItems;
+ if (!numFilters)
+ dialogCreateOptions.optionFlags |= kNavNoTypePopup;
+
+ // The extension is important
+ if (numFilters < 2)
+ dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension;
+
+ if (!(m_windowStyle & wxFD_OVERWRITE_PROMPT))
+ dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;
+
+ err = ::NavCreatePutFileDialog(
+ &dialogCreateOptions,
+ kNavGenericSignature, // Suppresses the 'Default' (top) menu item
+ kNavGenericSignature,
+ sStandardNavEventFilter,
+ &myData, // for defaultLocation
+ &dialog );
+ }
+ else
+ {
+ // let the user select bundles/programs in dialogs
+ dialogCreateOptions.optionFlags |= kNavSupportPackages;
+
+ navFilterUPP = NewNavObjectFilterUPP(CrossPlatformFilterCallback);
+ err = ::NavCreateGetFileDialog(
+ &dialogCreateOptions,
+ NULL, // NavTypeListHandle
+ sStandardNavEventFilter,
+ NULL, // NavPreviewUPP
+ navFilterUPP,
+ (void *) &myData, // inClientData
+ &dialog );
+ }
+
+ if (err == noErr)
+ err = ::NavDialogRun(dialog);
+
+ // clean up filter related data, etc.
+ if (navFilterUPP)
+ ::DisposeNavObjectFilterUPP(navFilterUPP);
+
+ if (err != noErr)
+ {
+ ::NavDialogDispose(dialog);
+ return wxID_CANCEL;
+ }
+
+ NavReplyRecord navReply;
+ err = ::NavDialogGetReply(dialog, &navReply);
+ if (err == noErr && navReply.validRecord)
+ {
+ AEKeyword theKeyword;
+ DescType actualType;
+ Size actualSize;
+ FSRef theFSRef;
+ wxString thePath ;
+ long count;
+
+ m_filterIndex = myData.currentfilter;
+ ::AECountItems( &navReply.selection, &count );
+ for (long i = 1; i <= count; ++i)
+ {
+ err = ::AEGetNthPtr(
+ &(navReply.selection), i, typeFSRef, &theKeyword, &actualType,
+ &theFSRef, sizeof(theFSRef), &actualSize );
+ if (err != noErr)
+ break;
+
+ if (HasFdFlag(wxFD_SAVE))
+ thePath = wxMacFSRefToPath( &theFSRef, navReply.saveFileName );
+ else
+ thePath = wxMacFSRefToPath( &theFSRef );
+
+ if (!thePath)
+ {
+ ::NavDisposeReply(&navReply);
+ ::NavDialogDispose(dialog);
+ return wxID_CANCEL;
+ }
+
+ m_path = thePath;
+ m_paths.Add(m_path);
+ m_fileName = wxFileNameFromPath(m_path);
+ m_fileNames.Add(m_fileName);
+ }
+
+ // set these to the first hit
+ m_path = m_paths[0];
+ m_fileName = wxFileNameFromPath(m_path);
+ m_dir = wxPathOnly(m_path);
+ }
+
+ ::NavDisposeReply(&navReply);
+ ::NavDialogDispose(dialog);
+
+ return (err == noErr) ? wxID_OK : wxID_CANCEL;