From: Stefan Csomor Date: Wed, 16 Feb 2011 07:38:48 +0000 (+0000) Subject: support for file types in save panel X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/5411e35f7b80709ee85056fb192c310569080421 support for file types in save panel git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66901 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/osx/cocoa/filedlg.mm b/src/osx/cocoa/filedlg.mm index 7bae5e1387..a505870f3d 100644 --- a/src/osx/cocoa/filedlg.mm +++ b/src/osx/cocoa/filedlg.mm @@ -164,6 +164,7 @@ void wxFileDialog::ShowWindowModal() wxASSERT_MSG(parentWindow, "Window modal display requires parent."); + NSArray* types = CopyTypesFromFilter( m_wildCard ) ; if (HasFlag(wxFD_SAVE)) { NSSavePanel* sPanel = [NSSavePanel savePanel]; @@ -177,6 +178,8 @@ void wxFileDialog::ShowWindowModal() // be able to pass this in [sPanel setTreatsFilePackagesAsDirectories:NO]; [sPanel setCanSelectHiddenExtension:YES]; + [sPanel setAllowedFileTypes:types]; + [sPanel setAllowsOtherFileTypes:NO]; NSWindow* nativeParent = parentWindow->GetWXWindow(); ModalDialogDelegate* sheetDelegate = [[ModalDialogDelegate alloc] init]; @@ -188,7 +191,6 @@ void wxFileDialog::ShowWindowModal() } else { - NSArray* types = CopyTypesFromFilter( m_wildCard ) ; NSOpenPanel* oPanel = [NSOpenPanel openPanel]; SetupExtraControls(oPanel); @@ -209,9 +211,9 @@ void wxFileDialog::ShowWindowModal() modalDelegate: sheetDelegate didEndSelector: @selector(sheetDidEnd:returnCode:contextInfo:) contextInfo: nil]; - [types release]; - types = nil; } + [types release]; + types = nil; } void wxFileDialog::SetupExtraControls(WXWindow nativeWindow) @@ -258,6 +260,7 @@ int wxFileDialog::ShowModal() parentWindow = dynamic_cast(wxGetTopLevelParent(GetParent())); } + NSArray* types = CopyTypesFromFilter( m_wildCard ) ; if (HasFlag(wxFD_SAVE)) { NSSavePanel* sPanel = [NSSavePanel savePanel]; @@ -271,6 +274,8 @@ int wxFileDialog::ShowModal() // be able to pass this in [sPanel setTreatsFilePackagesAsDirectories:NO]; [sPanel setCanSelectHiddenExtension:YES]; + [sPanel setAllowedFileTypes:types]; + [sPanel setAllowsOtherFileTypes:NO]; if ( HasFlag(wxFD_OVERWRITE_PROMPT) ) { @@ -284,7 +289,6 @@ int wxFileDialog::ShowModal() } else { - NSArray* types = CopyTypesFromFilter( m_wildCard ) ; NSOpenPanel* oPanel = [NSOpenPanel openPanel]; SetupExtraControls(oPanel); @@ -305,9 +309,9 @@ int wxFileDialog::ShowModal() UnsubclassWin(); [oPanel setAccessoryView:nil]; - [types release]; - types = nil; } + [types release]; + types = nil; return GetReturnCode(); }