mirror of
https://github.com/cookiengineer/audacity
synced 2025-04-30 15:49:41 +02:00
Fix for bug #983
Now we know why the "automatically add extension" stuff was commented on in the FileDialog at least. :-)
This commit is contained in:
parent
5c67bc38b3
commit
e5f6a44656
2
lib-src/FileDialog/FileDialog.h
Normal file → Executable file
2
lib-src/FileDialog/FileDialog.h
Normal file → Executable file
@ -50,6 +50,8 @@ DECLARE_EVENT_TYPE(EVT_FILEDIALOG_SELECTION_CHANGED, -1);
|
||||
DECLARE_EVENT_TYPE(EVT_FILEDIALOG_FILTER_CHANGED, -1);
|
||||
DECLARE_EVENT_TYPE(EVT_FILEDIALOG_ADD_CONTROLS, -1);
|
||||
|
||||
#define FD_NO_ADD_EXTENSION 0x0400
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// wxFileDialog convenience functions
|
||||
//----------------------------------------------------------------------------
|
||||
|
@ -328,18 +328,21 @@ wxString FileDialog::GetPath() const
|
||||
|
||||
if (!path.HasExt())
|
||||
{
|
||||
int filterIndex = GetFilterIndex();
|
||||
if (filterIndex != -1)
|
||||
{
|
||||
wxStringTokenizer tokenizer(m_patterns[filterIndex], wxT(";"));
|
||||
if (tokenizer.HasMoreTokens())
|
||||
if (!(m_dialogStyle & FD_NO_ADD_EXTENSION))
|
||||
{
|
||||
int filterIndex = GetFilterIndex();
|
||||
if (filterIndex != -1)
|
||||
{
|
||||
wxString extension = tokenizer.GetNextToken().AfterFirst(wxT('.'));
|
||||
if (extension.Right(2) == wxT("*"))
|
||||
wxStringTokenizer tokenizer(m_patterns[filterIndex], wxT(";"));
|
||||
if (tokenizer.HasMoreTokens())
|
||||
{
|
||||
extension = wxEmptyString;
|
||||
wxString extension = tokenizer.GetNextToken().AfterFirst(wxT('.'));
|
||||
if (extension.Right(2) == wxT("*"))
|
||||
{
|
||||
extension = wxEmptyString;
|
||||
}
|
||||
path.SetExt(extension);
|
||||
}
|
||||
path.SetExt(extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -744,15 +744,18 @@ int FileDialog::ShowModal()
|
||||
wxFileName fn = ConvertSlashInFileName(thePath);
|
||||
if (!fn.HasExt())
|
||||
{
|
||||
wxStringTokenizer tokenizer( myData.extensions[m_filterIndex], wxT(";"));
|
||||
if (tokenizer.HasMoreTokens())
|
||||
if (!(m_dialogStyle & FD_NO_ADD_EXTENSION))
|
||||
{
|
||||
wxString extension = tokenizer.GetNextToken().AfterFirst(wxT('.'));
|
||||
if (extension.Right(2) == wxT("*"))
|
||||
wxStringTokenizer tokenizer( myData.extensions[m_filterIndex], wxT(";"));
|
||||
if (tokenizer.HasMoreTokens())
|
||||
{
|
||||
extension = wxEmptyString;
|
||||
wxString extension = tokenizer.GetNextToken().AfterFirst(wxT('.'));
|
||||
if (extension.Right(2) == wxT("*"))
|
||||
{
|
||||
extension = wxEmptyString;
|
||||
}
|
||||
fn.SetExt(extension);
|
||||
}
|
||||
fn.SetExt(extension);
|
||||
}
|
||||
}
|
||||
m_path = fn.GetFullPath();
|
||||
|
25
lib-src/FileDialog/win/FileDialogPrivate.cpp
Normal file → Executable file
25
lib-src/FileDialog/win/FileDialogPrivate.cpp
Normal file → Executable file
@ -844,20 +844,23 @@ int FileDialog::ShowModal()
|
||||
{
|
||||
//=== Adding the correct extension >>=================================
|
||||
m_filterIndex = (int)of.nFilterIndex - 1;
|
||||
|
||||
if ( !of.nFileExtension ||
|
||||
(of.nFileExtension && fileNameBuffer[of.nFileExtension] == wxT('\0')) )
|
||||
|
||||
if (!(m_dialogStyle & FD_NO_ADD_EXTENSION))
|
||||
{
|
||||
// User has typed a filename without an extension:
|
||||
const wxChar* extension = filterBuffer;
|
||||
int maxFilter = (int)(of.nFilterIndex*2L) - 1;
|
||||
if ( !of.nFileExtension ||
|
||||
(of.nFileExtension && fileNameBuffer[of.nFileExtension] == wxT('\0')) )
|
||||
{
|
||||
// User has typed a filename without an extension:
|
||||
const wxChar* extension = filterBuffer;
|
||||
int maxFilter = (int)(of.nFilterIndex*2L) - 1;
|
||||
|
||||
for( int i = 0; i < maxFilter; i++ ) // get extension
|
||||
extension = extension + wxStrlen( extension ) + 1;
|
||||
for( int i = 0; i < maxFilter; i++ ) // get extension
|
||||
extension = extension + wxStrlen( extension ) + 1;
|
||||
|
||||
m_fileName = AppendExtension(fileNameBuffer, extension);
|
||||
wxStrncpy(fileNameBuffer, m_fileName.c_str(), wxMin(m_fileName.Len(), wxMAXPATH-1));
|
||||
fileNameBuffer[wxMin(m_fileName.Len(), wxMAXPATH-1)] = wxT('\0');
|
||||
m_fileName = AppendExtension(fileNameBuffer, extension);
|
||||
wxStrncpy(fileNameBuffer, m_fileName.c_str(), wxMin(m_fileName.Len(), wxMAXPATH-1));
|
||||
fileNameBuffer[wxMin(m_fileName.Len(), wxMAXPATH-1)] = wxT('\0');
|
||||
}
|
||||
}
|
||||
|
||||
m_path = fileNameBuffer;
|
||||
|
2
src/export/Export.cpp
Normal file → Executable file
2
src/export/Export.cpp
Normal file → Executable file
@ -550,7 +550,7 @@ bool Exporter::GetFilename()
|
||||
mFilename.GetPath(),
|
||||
mFilename.GetFullName(),
|
||||
maskString,
|
||||
wxFD_SAVE | wxRESIZE_BORDER);
|
||||
wxFD_SAVE | wxRESIZE_BORDER | FD_NO_ADD_EXTENSION);
|
||||
mDialog = &fd;
|
||||
|
||||
fd.SetFilterIndex(mFilterIndex);
|
||||
|
@ -325,7 +325,7 @@ public:
|
||||
Tags *metadata = NULL,
|
||||
int subformat = 0);
|
||||
// optional
|
||||
wxString GetExtension(int index = 0);
|
||||
wxString GetExtension(int index = WXSIZEOF(kFormats));
|
||||
|
||||
private:
|
||||
|
||||
@ -911,7 +911,7 @@ bool ExportPCM::DisplayOptions(wxWindow *parent, int format)
|
||||
|
||||
wxString ExportPCM::GetExtension(int index)
|
||||
{
|
||||
if (index == 0) {
|
||||
if (index == WXSIZEOF(kFormats)) {
|
||||
// get extension libsndfile thinks is correct for currently selected format
|
||||
return sf_header_extension(ReadExportFormatPref());
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user