Removing unused obsolete code from wxFileDialog

We don't need workaround for macOS earlier than 10.6 any longer.
This commit is contained in:
Stefan Csomor 2020-07-08 22:39:08 +02:00 committed by Vadim Zeitlin
parent 19b875830b
commit dd0033d817
2 changed files with 0 additions and 140 deletions

View File

@ -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),

View File

@ -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 <NSOpenSavePanelDelegate>
{
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;