mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-15 15:49:36 +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_FILTER_CHANGED, -1);
|
||||||
DECLARE_EVENT_TYPE(EVT_FILEDIALOG_ADD_CONTROLS, -1);
|
DECLARE_EVENT_TYPE(EVT_FILEDIALOG_ADD_CONTROLS, -1);
|
||||||
|
|
||||||
|
#define FD_NO_ADD_EXTENSION 0x0400
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// wxFileDialog convenience functions
|
// wxFileDialog convenience functions
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
|
@ -328,18 +328,21 @@ wxString FileDialog::GetPath() const
|
|||||||
|
|
||||||
if (!path.HasExt())
|
if (!path.HasExt())
|
||||||
{
|
{
|
||||||
int filterIndex = GetFilterIndex();
|
if (!(m_dialogStyle & FD_NO_ADD_EXTENSION))
|
||||||
if (filterIndex != -1)
|
|
||||||
{
|
{
|
||||||
wxStringTokenizer tokenizer(m_patterns[filterIndex], wxT(";"));
|
int filterIndex = GetFilterIndex();
|
||||||
if (tokenizer.HasMoreTokens())
|
if (filterIndex != -1)
|
||||||
{
|
{
|
||||||
wxString extension = tokenizer.GetNextToken().AfterFirst(wxT('.'));
|
wxStringTokenizer tokenizer(m_patterns[filterIndex], wxT(";"));
|
||||||
if (extension.Right(2) == 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);
|
wxFileName fn = ConvertSlashInFileName(thePath);
|
||||||
if (!fn.HasExt())
|
if (!fn.HasExt())
|
||||||
{
|
{
|
||||||
wxStringTokenizer tokenizer( myData.extensions[m_filterIndex], wxT(";"));
|
if (!(m_dialogStyle & FD_NO_ADD_EXTENSION))
|
||||||
if (tokenizer.HasMoreTokens())
|
|
||||||
{
|
{
|
||||||
wxString extension = tokenizer.GetNextToken().AfterFirst(wxT('.'));
|
wxStringTokenizer tokenizer( myData.extensions[m_filterIndex], wxT(";"));
|
||||||
if (extension.Right(2) == 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();
|
m_path = fn.GetFullPath();
|
||||||
|
23
lib-src/FileDialog/win/FileDialogPrivate.cpp
Normal file → Executable file
23
lib-src/FileDialog/win/FileDialogPrivate.cpp
Normal file → Executable file
@ -845,19 +845,22 @@ int FileDialog::ShowModal()
|
|||||||
//=== Adding the correct extension >>=================================
|
//=== Adding the correct extension >>=================================
|
||||||
m_filterIndex = (int)of.nFilterIndex - 1;
|
m_filterIndex = (int)of.nFilterIndex - 1;
|
||||||
|
|
||||||
if ( !of.nFileExtension ||
|
if (!(m_dialogStyle & FD_NO_ADD_EXTENSION))
|
||||||
(of.nFileExtension && fileNameBuffer[of.nFileExtension] == wxT('\0')) )
|
|
||||||
{
|
{
|
||||||
// User has typed a filename without an extension:
|
if ( !of.nFileExtension ||
|
||||||
const wxChar* extension = filterBuffer;
|
(of.nFileExtension && fileNameBuffer[of.nFileExtension] == wxT('\0')) )
|
||||||
int maxFilter = (int)(of.nFilterIndex*2L) - 1;
|
{
|
||||||
|
// 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
|
for( int i = 0; i < maxFilter; i++ ) // get extension
|
||||||
extension = extension + wxStrlen( extension ) + 1;
|
extension = extension + wxStrlen( extension ) + 1;
|
||||||
|
|
||||||
m_fileName = AppendExtension(fileNameBuffer, extension);
|
m_fileName = AppendExtension(fileNameBuffer, extension);
|
||||||
wxStrncpy(fileNameBuffer, m_fileName.c_str(), wxMin(m_fileName.Len(), wxMAXPATH-1));
|
wxStrncpy(fileNameBuffer, m_fileName.c_str(), wxMin(m_fileName.Len(), wxMAXPATH-1));
|
||||||
fileNameBuffer[wxMin(m_fileName.Len(), wxMAXPATH-1)] = wxT('\0');
|
fileNameBuffer[wxMin(m_fileName.Len(), wxMAXPATH-1)] = wxT('\0');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
m_path = fileNameBuffer;
|
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.GetPath(),
|
||||||
mFilename.GetFullName(),
|
mFilename.GetFullName(),
|
||||||
maskString,
|
maskString,
|
||||||
wxFD_SAVE | wxRESIZE_BORDER);
|
wxFD_SAVE | wxRESIZE_BORDER | FD_NO_ADD_EXTENSION);
|
||||||
mDialog = &fd;
|
mDialog = &fd;
|
||||||
|
|
||||||
fd.SetFilterIndex(mFilterIndex);
|
fd.SetFilterIndex(mFilterIndex);
|
||||||
|
@ -325,7 +325,7 @@ public:
|
|||||||
Tags *metadata = NULL,
|
Tags *metadata = NULL,
|
||||||
int subformat = 0);
|
int subformat = 0);
|
||||||
// optional
|
// optional
|
||||||
wxString GetExtension(int index = 0);
|
wxString GetExtension(int index = WXSIZEOF(kFormats));
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -911,7 +911,7 @@ bool ExportPCM::DisplayOptions(wxWindow *parent, int format)
|
|||||||
|
|
||||||
wxString ExportPCM::GetExtension(int index)
|
wxString ExportPCM::GetExtension(int index)
|
||||||
{
|
{
|
||||||
if (index == 0) {
|
if (index == WXSIZEOF(kFormats)) {
|
||||||
// get extension libsndfile thinks is correct for currently selected format
|
// get extension libsndfile thinks is correct for currently selected format
|
||||||
return sf_header_extension(ReadExportFormatPref());
|
return sf_header_extension(ReadExportFormatPref());
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user