Removing unused obsolete code from wxFileDialog
We don't need workaround for macOS earlier than 10.6 any longer.
This commit is contained in:
committed by
Vadim Zeitlin
parent
19b875830b
commit
dd0033d817
@@ -74,11 +74,6 @@ public:
|
|||||||
|
|
||||||
// implementation only
|
// implementation only
|
||||||
|
|
||||||
#if wxOSX_USE_COCOA
|
|
||||||
// returns true if the file can be shown as active
|
|
||||||
bool CheckFile( const wxString& filename );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
// not supported for file dialog, RR
|
// not supported for file dialog, RR
|
||||||
virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
|
virtual void DoSetSize(int WXUNUSED(x), int WXUNUSED(y),
|
||||||
|
@@ -45,126 +45,6 @@
|
|||||||
// implementation
|
// 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);
|
wxIMPLEMENT_CLASS(wxFileDialog, wxFileDialogBase);
|
||||||
|
|
||||||
void wxFileDialog::Init()
|
void wxFileDialog::Init()
|
||||||
@@ -425,21 +305,6 @@ void wxFileDialog::OnFilterSelected( wxCommandEvent &WXUNUSED(event) )
|
|||||||
DoOnFilterSelected( m_filterChoice->GetSelection() );
|
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)
|
void wxFileDialog::SetupExtraControls(WXWindow nativeWindow)
|
||||||
{
|
{
|
||||||
NSSavePanel* panel = (NSSavePanel*) nativeWindow;
|
NSSavePanel* panel = (NSSavePanel*) nativeWindow;
|
||||||
|
Reference in New Issue
Block a user