Corrected template names shown in the dialog when creating a new file

This commit is contained in:
Zane U. Ji 2013-10-26 21:21:47 +08:00
parent 9b385e7caa
commit e39638ea3b
1 changed files with 4 additions and 16 deletions

View File

@ -2856,24 +2856,11 @@ void MyFrame::OnNew ( wxCommandEvent& WXUNUSED ( event ) )
if ( wxFileName::DirExists ( templateDir ) ) if ( wxFileName::DirExists ( templateDir ) )
{ {
wxString templateMask, name, extension, entry; wxString templateMask, name, extension, entry;
wxFileName fn;
templateMask = templateDir + wxFileName::GetPathSeparator() + _T ( "*.*" ); templateMask = templateDir + wxFileName::GetPathSeparator() + _T ( "*.*" );
templateFile = wxFindFirstFile ( templateMask, wxFILE ); templateFile = wxFindFirstFile ( templateMask, wxFILE );
wxFileName fn; while ( !templateFile.empty() )
if ( !templateFile.empty() )
{ {
fn.Assign ( templateFile );
name = fn.GetName();
extension = fn.GetExt();
entry.Printf ( _T ( "%s (*.%s)" ), name.c_str(), extension.c_str() );
templateArray.Add ( entry );
for ( ;; )
{
templateFile = wxFindNextFile();
if ( templateFile.empty() )
break;
templateFile.Replace ( _T("_"), _T(" ") ); templateFile.Replace ( _T("_"), _T(" ") );
fn.Assign ( templateFile ); fn.Assign ( templateFile );
name = fn.GetName(); name = fn.GetName();
@ -2881,7 +2868,8 @@ void MyFrame::OnNew ( wxCommandEvent& WXUNUSED ( event ) )
entry.Printf ( _T ( "%s (*.%s)" ), name.c_str(), extension.c_str() ); entry.Printf ( _T ( "%s (*.%s)" ), name.c_str(), extension.c_str() );
templateArray.Add ( entry ); templateArray.Add ( entry );
}
templateFile = wxFindNextFile();
} }
templateArray.Sort(); templateArray.Sort();
templateArray.Insert ( defaultSelection, 0 ); templateArray.Insert ( defaultSelection, 0 );