From dd0033d817df543e428af0101d995fa5308093ee Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 8 Jul 2020 22:39:08 +0200 Subject: [PATCH] Removing unused obsolete code from wxFileDialog We don't need workaround for macOS earlier than 10.6 any longer. --- include/wx/osx/filedlg.h | 5 -- src/osx/cocoa/filedlg.mm | 135 --------------------------------------- 2 files changed, 140 deletions(-) diff --git a/include/wx/osx/filedlg.h b/include/wx/osx/filedlg.h index 892bad58f6..d8a4490042 100644 --- a/include/wx/osx/filedlg.h +++ b/include/wx/osx/filedlg.h @@ -74,11 +74,6 @@ public: // implementation only -#if wxOSX_USE_COCOA - // returns true if the file can be shown as active - bool CheckFile( const wxString& filename ); -#endif - protected: // not supported for file dialog, RR virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y), diff --git a/src/osx/cocoa/filedlg.mm b/src/osx/cocoa/filedlg.mm index e31aa828a7..4957487fb0 100644 --- a/src/osx/cocoa/filedlg.mm +++ b/src/osx/cocoa/filedlg.mm @@ -45,126 +45,6 @@ // implementation // ============================================================================ -// Open Items: -// - parameter support for descending into packages as directories (setTreatsFilePackagesAsDirectories) -// - as setAllowedFileTypes is only functional for NSOpenPanel on 10.6+, on earlier systems, the file -// type choice will not be shown, but all possible file items will be shown, if a popup must be working -// then the delegate method - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename will have to -// be implemented - -@interface wxOpenPanelDelegate : NSObject -{ - wxFileDialog* _dialog; -} - -- (wxFileDialog*) fileDialog; -- (void) setFileDialog:(wxFileDialog*) dialog; - -- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename; - -@end - -@implementation wxOpenPanelDelegate - -- (id) init -{ - if ( self = [super init] ) - { - _dialog = NULL; - } - return self; -} - -- (wxFileDialog*) fileDialog -{ - return _dialog; -} - -- (void) setFileDialog:(wxFileDialog*) dialog -{ - _dialog = dialog; -} - -- (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename -{ - BOOL showObject = YES; - - wxGCC_WARNING_SUPPRESS(deprecated-declarations) - - NSString* resolvedLink = [[NSFileManager defaultManager] pathContentOfSymbolicLinkAtPath:filename]; - if ( resolvedLink != nil ) - filename = resolvedLink; - - NSDictionary* fileAttribs = [[NSFileManager defaultManager] - fileAttributesAtPath:filename traverseLink:YES]; - - wxGCC_WARNING_RESTORE(deprecated-declarations) - - if (fileAttribs) - { - // check for packages - if ([NSFileTypeDirectory isEqualTo:[fileAttribs objectForKey:NSFileType]]) - { - if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename] == NO) - showObject = YES; // it's a folder, OK to show - else - { - // it's a packaged directory, apply check - wxCFStringRef filecf([filename retain]); - showObject = _dialog->CheckFile(filecf.AsString()); - } - } - else - { - // the code above only solves links, not aliases, do this here: - - NSString* resolvedAlias = nil; - - CFURLRef url = CFURLCreateWithFileSystemPath (kCFAllocatorDefault, - (CFStringRef)filename, - kCFURLPOSIXPathStyle, - NO); - if (url != NULL) - { - FSRef fsRef; - if (CFURLGetFSRef(url, &fsRef)) - { - Boolean targetIsFolder, wasAliased; - OSErr err = FSResolveAliasFile (&fsRef, true, &targetIsFolder, &wasAliased); - - if ((err == noErr) && wasAliased) - { - CFURLRef resolvedUrl = CFURLCreateFromFSRef(kCFAllocatorDefault, &fsRef); - if (resolvedUrl != NULL) - { - resolvedAlias = (NSString*) CFURLCopyFileSystemPath(resolvedUrl, - kCFURLPOSIXPathStyle); - CFRelease(resolvedUrl); - } - } - } - CFRelease(url); - } - - if (resolvedAlias != nil) - { - // recursive call - [resolvedAlias autorelease]; - showObject = [self panel:sender shouldShowFilename:resolvedAlias]; - } - else - { - wxCFStringRef filecf([filename retain]); - showObject = _dialog->CheckFile(filecf.AsString()); - } - } - } - - return showObject; -} - -@end - wxIMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase); void wxFileDialog::Init() @@ -425,21 +305,6 @@ void wxFileDialog::OnFilterSelected( wxCommandEvent &WXUNUSED(event) ) DoOnFilterSelected( m_filterChoice->GetSelection() ); } -bool wxFileDialog::CheckFile( const wxString& filename ) -{ - if ( m_currentExtensions.GetCount() == 0 ) - return true; - - wxString ext = filename.AfterLast('.').Lower(); - - for ( size_t i = 0; i < m_currentExtensions.GetCount(); ++i ) - { - if ( ext == m_currentExtensions[i] ) - return true; - } - return false; -} - void wxFileDialog::SetupExtraControls(WXWindow nativeWindow) { NSSavePanel* panel = (NSSavePanel*) nativeWindow;