From 0fd55b6c410e6983f801946e96f702e09ce48215 Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Mon, 21 May 2007 18:54:42 +0000 Subject: [PATCH] removing old codeparts, fixing bug 1532580 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@46148 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/filedlg.cpp | 58 +++++++++++++------------------------- 1 file changed, 19 insertions(+), 39 deletions(-) diff --git a/src/mac/carbon/filedlg.cpp b/src/mac/carbon/filedlg.cpp index bee5c465a1..3ff1fdf130 100644 --- a/src/mac/carbon/filedlg.cpp +++ b/src/mac/carbon/filedlg.cpp @@ -83,12 +83,14 @@ static pascal void NavEventProc( ::NavCustomControl(ioParams->context, kNavCtlSetLocation, (void *) &theLocation); } - NavMenuItemSpec menuItem; - menuItem.version = kNavMenuItemSpecVersion; - menuItem.menuCreator = 'WXNG'; - menuItem.menuType = data->currentfilter; - wxMacStringToPascal( data->name[data->currentfilter] , (StringPtr)(menuItem.menuItemName) ) ; - ::NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &menuItem); + if( data->extensions.GetCount() > 0 ) + { + NavMenuItemSpec menuItem; + memset( &menuItem, 0, sizeof(menuItem) ); + menuItem.version = kNavMenuItemSpecVersion; + menuItem.menuType = data->currentfilter; + ::NavCustomControl(ioParams->context, kNavCtlSelectCustomType, &menuItem); + } } else if ( inSelector == kNavCBPopupMenuSelect ) { @@ -108,7 +110,7 @@ static pascal void NavEventProc( sfilename = cfString.AsString() ; int pos = sfilename.Find('.', true) ; - if ( pos != wxNOT_FOUND ) + if ( pos != wxNOT_FOUND && extension != wxT("*") ) { sfilename = sfilename.Left(pos+1)+extension ; cfString.Assign( sfilename , wxFONTENCODING_DEFAULT ) ; @@ -224,34 +226,6 @@ static Boolean CheckFile( const wxString &filename , OSType type , OpenUserDataR return true ; } -#if !TARGET_API_MAC_OSX -static pascal Boolean CrossPlatformFileFilter(CInfoPBPtr myCInfoPBPtr, void *dataPtr) -{ - OpenUserDataRecPtr data = (OpenUserDataRecPtr) dataPtr ; - // return true if this item is invisible or a file - - Boolean visibleFlag; - Boolean folderFlag; - - visibleFlag = ! (myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdFlags & kIsInvisible); - folderFlag = (myCInfoPBPtr->hFileInfo.ioFlAttrib & 0x10); - - // because the semantics of the filter proc are "true means don't show - // it" we need to invert the result that we return - - if ( !visibleFlag ) - return true ; - - if ( !folderFlag ) - { - wxString file = wxMacMakeStringFromPascal( myCInfoPBPtr->hFileInfo.ioNamePtr ) ; - return !CheckFile( file , myCInfoPBPtr->hFileInfo.ioFlFndrInfo.fdType , data ) ; - } - - return false ; -} -#endif - // end wxmac wxFileDialog::wxFileDialog( @@ -282,9 +256,19 @@ pascal Boolean CrossPlatformFilterCallback( FSRef fsref ; if ( AEGetDescData (theItem, &fsref, sizeof (FSRef)) == noErr ) { +#if 1 memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ; wxString file = wxMacFSRefToPath( &fsref ) ; display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ; +#else + CFStringRef itemUTI = NULL; + OSStatus status = LSCopyItemAttribute (&fsref, kLSRolesAll, kLSItemContentType, (CFTypeRef*)&itemUTI); + if (status == noErr) + { + display = UTTypeConformsTo (itemUTI, CFSTR("public.text") ); + CFRelease (itemUTI); + } +#endif } } } @@ -339,10 +323,6 @@ int wxFileDialog::ShowModal() if (!numFilters) dialogCreateOptions.optionFlags |= kNavNoTypePopup; - // The extension is important - if (numFilters < 2) - dialogCreateOptions.optionFlags |= kNavPreserveSaveFileExtension; - #if TARGET_API_MAC_OSX if (!(m_windowStyle & wxFD_OVERWRITE_PROMPT)) dialogCreateOptions.optionFlags |= kNavDontConfirmReplacement;