From aa39f9ade28f95a157014102018092bb2645d782 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 26 Dec 2019 22:48:00 -0500 Subject: [PATCH] Rewrite FileNames::SelectFile using FileTypes... ... And more uniformity in the descriptions of file types used in more than one place Also fixes missing translations in VSTEffect.cpp --- src/AudacityLogger.cpp | 14 ++++---- src/Benchmark.cpp | 14 ++++---- src/FFmpeg.cpp | 11 +++--- src/FFmpeg.h | 25 ++++++++++---- src/FileNames.cpp | 36 +++++++++++--------- src/FileNames.h | 14 ++++---- src/FreqWindow.cpp | 14 ++++---- src/LabelDialog.cpp | 16 ++++----- src/ProjectFileManager.cpp | 2 +- src/Tags.cpp | 28 ++++++++-------- src/TimerRecordDialog.cpp | 2 +- src/effects/Contrast.cpp | 14 ++++---- src/effects/VST/VSTEffect.cpp | 36 ++++++++++++-------- src/export/ExportCL.cpp | 19 ++++++----- src/export/ExportMP3.cpp | 63 +++++++++++++++++++++++------------ src/menus/FileMenus.cpp | 57 ++++++++++++++++++------------- src/menus/HelpMenus.cpp | 2 +- src/prefs/KeyConfigPrefs.cpp | 28 ++++++++-------- 18 files changed, 226 insertions(+), 169 deletions(-) diff --git a/src/AudacityLogger.cpp b/src/AudacityLogger.cpp index edc336639..8e7d6a493 100644 --- a/src/AudacityLogger.cpp +++ b/src/AudacityLogger.cpp @@ -251,13 +251,13 @@ void AudacityLogger::OnSave(wxCommandEvent & WXUNUSED(e)) wxString fName = _("log.txt"); fName = FileNames::SelectFile(FileNames::Operation::Export, - XO("Save log to:"), - wxEmptyString, - fName, - wxT("txt"), - wxT("*.txt"), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, - mFrame.get()); + XO("Save log to:"), + wxEmptyString, + fName, + wxT("txt"), + { FileNames::TextFiles }, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, + mFrame.get()); if (fName.empty()) { return; diff --git a/src/Benchmark.cpp b/src/Benchmark.cpp index fe498f241..f8b95b42b 100644 --- a/src/Benchmark.cpp +++ b/src/Benchmark.cpp @@ -261,13 +261,13 @@ void BenchmarkDialog::OnSave( wxCommandEvent & WXUNUSED(event)) auto fName = XO("benchmark.txt").Translation(); fName = FileNames::SelectFile(FileNames::Operation::Export, - XO("Export Benchmark Data as:"), - wxEmptyString, - fName, - wxT("txt"), - wxT("*.txt"), - wxFD_SAVE | wxRESIZE_BORDER, - this); + XO("Export Benchmark Data as:"), + wxEmptyString, + fName, + wxT("txt"), + { FileNames::TextFiles }, + wxFD_SAVE | wxRESIZE_BORDER, + this); if (fName.empty()) return; diff --git a/src/FFmpeg.cpp b/src/FFmpeg.cpp index 316958388..60c9d6b8e 100644 --- a/src/FFmpeg.cpp +++ b/src/FFmpeg.cpp @@ -449,7 +449,8 @@ class FindFFmpegDialog final : public wxDialogWrapper { public: - FindFFmpegDialog(wxWindow *parent, const wxString &path, const wxString &name, const wxString &type) + FindFFmpegDialog(wxWindow *parent, const wxString &path, const wxString &name, + FileNames::FileTypes types) : wxDialogWrapper(parent, wxID_ANY, XO("Locate FFmpeg")) { SetName(); @@ -457,7 +458,7 @@ public: mPath = path; mName = name; - mType = type; + mTypes = std::move( types ); mLibPath.Assign(mPath, mName); @@ -522,7 +523,7 @@ public: mLibPath.GetPath(), mLibPath.GetName(), wxT(""), - mType, + mTypes, wxFD_OPEN | wxRESIZE_BORDER, this); if (!path.empty()) { @@ -547,7 +548,7 @@ private: wxString mPath; wxString mName; - wxString mType; + FileNames::FileTypes mTypes; wxTextCtrl *mPathText; @@ -659,7 +660,7 @@ bool FFmpegLibs::FindLibs(wxWindow *parent) FindFFmpegDialog fd(parent, path, name, - GetLibraryTypeString()); + GetLibraryTypes()); if (fd.ShowModal() == wxID_CANCEL) { wxLogMessage(wxT("User canceled the dialog. Failed to find FFmpeg libraries.")); diff --git a/src/FFmpeg.h b/src/FFmpeg.h index 261559ab8..c27578ff4 100644 --- a/src/FFmpeg.h +++ b/src/FFmpeg.h @@ -242,10 +242,14 @@ public: #if defined(__WXMSW__) /* Library names and file filters for Windows only */ - wxString GetLibraryTypeString() + FileNames::FileTypes GetLibraryTypes() { - /* i18n-hint: do not translate avformat. Preserve the computer gibberish.*/ - return _("Only avformat.dll|*avformat*.dll|Dynamically Linked Libraries (*.dll)|*.dll|All Files|*"); + return { + /* i18n-hint: do not translate avformat. Preserve the computer gibberish.*/ + { XO("Only avformat.dll"), { wxT("avformat.dll") } }, + FileNames::DynamicLibraries, + FileNames::AllFiles + }; } wxString GetLibAVFormatPath() @@ -276,9 +280,12 @@ public: } #elif defined(__WXMAC__) /* Library names and file filters for Mac OS only */ - wxString GetLibraryTypeString() + FileNames::FileTypes GetLibraryTypes() { - return _("Dynamic Libraries (*.dylib)|*.dylib|All Files (*)|*"); + return { + FileNames::DynamicLibraries, + FileNames::AllFiles + }; } wxString GetLibAVFormatPath() @@ -309,9 +316,13 @@ public: #else /* Library names and file filters for other platforms, basically Linux and * other *nix platforms */ - wxString GetLibraryTypeString() + FileNames::FileTypes GetLibraryTypes() { - return _("Only libavformat.so|libavformat*.so*|Dynamically Linked Libraries (*.so*)|*.so*|All Files (*)|*"); + return { + { XO("Only libavformat.so"), { wxT("libavformat*.so*") } }, + FileNames::DynamicLibraries, + FileNames::AllFiles + }; } wxString GetLibAVFormatPath() diff --git a/src/FileNames.cpp b/src/FileNames.cpp index f5f258aee..ab4c462bd 100644 --- a/src/FileNames.cpp +++ b/src/FileNames.cpp @@ -558,13 +558,13 @@ void FileNames::UpdateDefaultPath(Operation op, const FilePath &path) wxString FileNames::SelectFile(Operation op, - const TranslatableString& message, - const FilePath& default_path, - const FilePath& default_filename, - const FileExtension& default_extension, - const wxString& wildcard, - int flags, - wxWindow *parent) + const TranslatableString& message, + const FilePath& default_path, + const FilePath& default_filename, + const FileExtension& default_extension, + const FileTypes& fileTypes, + int flags, + wxWindow *parent) { return WithDefaultPath(op, default_path, [&](const FilePath &path) { wxString filter; @@ -572,7 +572,8 @@ FileNames::SelectFile(Operation op, filter = wxT("*.") + default_extension; return FileSelector( message.Translation(), path, default_filename, filter, - wildcard, flags, parent, wxDefaultCoord, wxDefaultCoord); + FormatWildcard( fileTypes ), + flags, parent, wxDefaultCoord, wxDefaultCoord); }); } @@ -711,7 +712,7 @@ char *FileNames::VerifyFilename(const wxString &s, bool input) } else { wxFileName ff(name); - wxString ext; + FileExtension ext; while ((char *) (const char *)name.mb_str() == NULL) { AudacityMessageBox( XO( @@ -719,13 +720,16 @@ char *FileNames::VerifyFilename(const wxString &s, bool input) ext = ff.GetExt(); name = FileNames::SelectFile(FileNames::Operation::_None, - XO("Specify New Filename:"), - wxEmptyString, - name, - ext, - ext.empty() ? wxT("*") : (wxT("*.") + ext), - wxFD_SAVE | wxRESIZE_BORDER, - wxGetTopLevelParent(NULL)); + XO("Specify New Filename:"), + wxEmptyString, + name, + ext, + { ext.empty() + ? FileNames::AllFiles + : FileType{ {}, { ext } } + }, + wxFD_SAVE | wxRESIZE_BORDER, + wxGetTopLevelParent(NULL)); } } diff --git a/src/FileNames.h b/src/FileNames.h index f2431dbd6..139be7cfd 100644 --- a/src/FileNames.h +++ b/src/FileNames.h @@ -159,13 +159,13 @@ public: static wxString SelectFile(Operation op, // op matters only when default_path is empty - const TranslatableString& message, - const FilePath& default_path, - const FilePath& default_filename, - const FileExtension& default_extension, - const wxString& wildcard, - int flags, - wxWindow *parent); + const TranslatableString& message, + const FilePath& default_path, + const FilePath& default_filename, + const FileExtension& default_extension, + const FileTypes& fileTypes, + int flags, + wxWindow *parent); // Useful functions for working with search paths static void AddUniquePathToPathList(const FilePath &path, diff --git a/src/FreqWindow.cpp b/src/FreqWindow.cpp index fa648d835..876dffaf9 100644 --- a/src/FreqWindow.cpp +++ b/src/FreqWindow.cpp @@ -1066,13 +1066,13 @@ void FrequencyPlotDialog::OnExport(wxCommandEvent & WXUNUSED(event)) wxString fName = _("spectrum.txt"); fName = FileNames::SelectFile(FileNames::Operation::Export, - XO("Export Spectral Data As:"), - wxEmptyString, - fName, - wxT("txt"), - _("Text files (*.txt)|*.txt|All files|*"), - wxFD_SAVE | wxRESIZE_BORDER, - this); + XO("Export Spectral Data As:"), + wxEmptyString, + fName, + wxT("txt"), + { FileNames::TextFiles, FileNames::AllFiles }, + wxFD_SAVE | wxRESIZE_BORDER, + this); if (fName.empty()) return; diff --git a/src/LabelDialog.cpp b/src/LabelDialog.cpp index f2228ae31..4fcb3af9f 100644 --- a/src/LabelDialog.cpp +++ b/src/LabelDialog.cpp @@ -628,13 +628,13 @@ void LabelDialog::OnImport(wxCommandEvent & WXUNUSED(event)) // Ask user for a filename wxString fileName = FileNames::SelectFile(FileNames::Operation::Open, - XO("Select a text file containing labels"), - wxEmptyString, // Path - wxT(""), // Name - wxT("txt"), // Extension - _("Text files (*.txt)|*.txt|All files|*"), - wxRESIZE_BORDER, // Flags - this); // Parent + XO("Select a text file containing labels"), + wxEmptyString, // Path + wxT(""), // Name + wxT("txt"), // Extension + { FileNames::TextFiles, FileNames::AllFiles }, + wxRESIZE_BORDER, // Flags + this); // Parent // They gave us one... if (!fileName.empty()) { @@ -681,7 +681,7 @@ void LabelDialog::OnExport(wxCommandEvent & WXUNUSED(event)) wxEmptyString, fName, wxT("txt"), - wxT("*.txt"), + { FileNames::TextFiles }, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, this); diff --git a/src/ProjectFileManager.cpp b/src/ProjectFileManager.cpp index f49c170b2..2a5cc3092 100644 --- a/src/ProjectFileManager.cpp +++ b/src/ProjectFileManager.cpp @@ -849,7 +849,7 @@ For an audio file that will open in other apps, use 'Export'.\n"); filename.GetPath(), filename.GetFullName(), wxT("aup"), - _("Audacity projects") + wxT(" (*.aup)|*.aup"), + { FileNames::AudacityProjects }, wxFD_SAVE | wxRESIZE_BORDER, &window); diff --git a/src/Tags.cpp b/src/Tags.cpp index 46392a875..34234381a 100644 --- a/src/Tags.cpp +++ b/src/Tags.cpp @@ -1234,13 +1234,13 @@ void TagsEditorDialog::OnLoad(wxCommandEvent & WXUNUSED(event)) // Ask the user for the real name fn = FileNames::SelectFile(FileNames::Operation::_None, - XO("Load Metadata As:"), - FileNames::DataDir(), - wxT("Tags.xml"), - wxT("xml"), - wxT("*.xml"), - wxFD_OPEN | wxRESIZE_BORDER, - this); + XO("Load Metadata As:"), + FileNames::DataDir(), + wxT("Tags.xml"), + wxT("xml"), + { FileNames::XMLFiles }, + wxFD_OPEN | wxRESIZE_BORDER, + this); // User canceled... if (fn.empty()) { @@ -1290,13 +1290,13 @@ void TagsEditorDialog::OnSave(wxCommandEvent & WXUNUSED(event)) // Ask the user for the real name fn = FileNames::SelectFile(FileNames::Operation::_None, - XO("Save Metadata As:"), - FileNames::DataDir(), - wxT("Tags.xml"), - wxT("xml"), - wxT("*.xml"), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, - this); + XO("Save Metadata As:"), + FileNames::DataDir(), + wxT("Tags.xml"), + wxT("xml"), + { FileNames::XMLFiles }, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, + this); // User canceled... if (fn.empty()) { diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index 87377296f..aede521b9 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -322,7 +322,7 @@ void TimerRecordDialog::OnAutoSavePathButton_Click(wxCommandEvent& WXUNUSED(even m_fnAutoSaveFile.GetPath(), m_fnAutoSaveFile.GetFullName(), wxT("aup"), - _("Audacity projects") + wxT(" (*.aup)|*.aup"), + { FileNames::AudacityProjects }, wxFD_SAVE | wxRESIZE_BORDER, this); diff --git a/src/effects/Contrast.cpp b/src/effects/Contrast.cpp index 4d1dfe6d0..eb72f88a1 100644 --- a/src/effects/Contrast.cpp +++ b/src/effects/Contrast.cpp @@ -532,13 +532,13 @@ void ContrastDialog::OnExport(wxCommandEvent & WXUNUSED(event)) wxString fName = wxT("contrast.txt"); fName = FileNames::SelectFile(FileNames::Operation::Export, - XO("Export Contrast Result As:"), - wxEmptyString, - fName, - wxT("txt"), - _("Text files (*.txt)|*.txt|All files|*"), - wxFD_SAVE | wxRESIZE_BORDER, - this); + XO("Export Contrast Result As:"), + wxEmptyString, + fName, + wxT("txt"), + { FileNames::TextFiles, FileNames::AllFiles }, + wxFD_SAVE | wxRESIZE_BORDER, + this); if (fName.empty()) return; diff --git a/src/effects/VST/VSTEffect.cpp b/src/effects/VST/VSTEffect.cpp index 945424e9c..fc9e0b44d 100644 --- a/src/effects/VST/VSTEffect.cpp +++ b/src/effects/VST/VSTEffect.cpp @@ -1861,13 +1861,17 @@ void VSTEffect::ExportPresets() // Passing a valid parent will cause some effects dialogs to malfunction // upon returning from the FileNames::SelectFile(). path = FileNames::SelectFile(FileNames::Operation::_None, - XO("Save VST Preset As:"), - FileNames::DataDir(), - wxEmptyString, - wxT("xml"), - wxT("Standard VST bank file (*.fxb)|*.fxb|Standard VST program file (*.fxp)|*.fxp|Audacity VST preset file (*.xml)|*.xml"), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, - NULL); + XO("Save VST Preset As:"), + FileNames::DataDir(), + wxEmptyString, + wxT("xml"), + { + { XO("Standard VST bank file"), { wxT("fxb") }, true }, + { XO("Standard VST program file"), { wxT("fxp") }, true }, + { XO("Audacity VST preset file"), { wxT("xml") }, true }, + }, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, + NULL); // User canceled... if (path.empty()) @@ -1914,13 +1918,17 @@ void VSTEffect::ImportPresets() // Ask the user for the real name path = FileNames::SelectFile(FileNames::Operation::_None, - XO("Load VST Preset:"), - FileNames::DataDir(), - wxEmptyString, - wxT("xml"), - wxT("VST preset files (*.fxb; *.fxp; *.xml)|*.fxb;*.fxp;*.xml"), - wxFD_OPEN | wxRESIZE_BORDER, - mParent); + XO("Load VST Preset:"), + FileNames::DataDir(), + wxEmptyString, + wxT("xml"), + { { + XO("VST preset files"), + { wxT("fxb"), wxT("fxp"), wxT("xml") }, + true + } }, + wxFD_OPEN | wxRESIZE_BORDER, + mParent); // User canceled... if (path.empty()) diff --git a/src/export/ExportCL.cpp b/src/export/ExportCL.cpp index def1a243c..49a9d6a4f 100644 --- a/src/export/ExportCL.cpp +++ b/src/export/ExportCL.cpp @@ -175,20 +175,23 @@ bool ExportCLOptions::TransferDataFromWindow() void ExportCLOptions::OnBrowse(wxCommandEvent& WXUNUSED(event)) { wxString path; - wxString ext; + FileExtension ext; + FileNames::FileType type = FileNames::AllFiles; #if defined(__WXMSW__) ext = wxT("exe"); + /* i18n-hint files that can be run as programs */ + type = { XO("Executables"), { ext } }; #endif path = FileNames::SelectFile(FileNames::Operation::Open, - XO("Find path to command"), - wxEmptyString, - wxEmptyString, - ext, - ext.empty() ? wxT("*") : (wxT("*.") + ext), - wxFD_OPEN | wxRESIZE_BORDER, - this); + XO("Find path to command"), + wxEmptyString, + wxEmptyString, + ext, + { type }, + wxFD_OPEN | wxRESIZE_BORDER, + this); if (path.empty()) { return; } diff --git a/src/export/ExportMP3.cpp b/src/export/ExportMP3.cpp index cea04b3b6..5e081e5f0 100644 --- a/src/export/ExportMP3.cpp +++ b/src/export/ExportMP3.cpp @@ -553,7 +553,8 @@ public: #ifndef DISABLE_DYNAMIC_LOADING_LAME - FindDialog(wxWindow *parent, wxString path, wxString name, wxString type) + FindDialog(wxWindow *parent, wxString path, wxString name, + FileNames::FileTypes types) : wxDialogWrapper(parent, wxID_ANY, /* i18n-hint: LAME is the name of an MP3 converter and should not be translated*/ XO("Locate LAME")) @@ -563,7 +564,7 @@ public: mPath = path; mName = name; - mType = type; + mTypes = std::move( types ); mLibPath.Assign(mPath, mName); @@ -626,13 +627,13 @@ public: auto question = XO("Where is %s?").Format( mName ); wxString path = FileNames::SelectFile(FileNames::Operation::_None, - question, - mLibPath.GetPath(), - mLibPath.GetName(), - wxT(""), - mType, - wxFD_OPEN | wxRESIZE_BORDER, - this); + question, + mLibPath.GetPath(), + mLibPath.GetName(), + wxT(""), + mTypes, + wxFD_OPEN | wxRESIZE_BORDER, + this); if (!path.empty()) { mLibPath = path; mPathText->SetValue(path); @@ -658,7 +659,7 @@ private: wxString mPath; wxString mName; - wxString mType; + FileNames::FileTypes mTypes; #endif // DISABLE_DYNAMIC_LOADING_LAME wxTextCtrl *mPathText; @@ -800,7 +801,7 @@ public: wxString GetLibraryVersion(); wxString GetLibraryName(); wxString GetLibraryPath(); - wxString GetLibraryTypeString(); + FileNames::FileTypes GetLibraryTypes(); /* returns the number of samples PER CHANNEL to send for each call to EncodeBuffer */ int InitializeStream(unsigned channels, int sampleRate); @@ -942,9 +943,9 @@ bool MP3Exporter::FindLibrary(wxWindow *parent) } FindDialog fd(parent, - path, - name, - GetLibraryTypeString()); + path, + name, + GetLibraryTypes()); if (fd.ShowModal() == wxID_CANCEL) { return false; @@ -1493,9 +1494,13 @@ wxString MP3Exporter::GetLibraryName() return wxT("lame_enc.dll"); } -wxString MP3Exporter::GetLibraryTypeString() +FileNames::FileTypes MP3Exporter::GetLibraryTypes() { - return _("Only lame_enc.dll|lame_enc.dll|Dynamically Linked Libraries (*.dll)|*.dll|All Files|*"); + return { + { XO("Only lame_enc.dll"), { wxT("lame_enc.dll") } }, + FileNames::DynamicLibraries, + FileNames::AllFiles + }; } #elif defined(__WXMAC__) @@ -1527,11 +1532,20 @@ wxString MP3Exporter::GetLibraryName() return wxT("libmp3lame.dylib"); } -wxString MP3Exporter::GetLibraryTypeString() +FileNames::FileTypes MP3Exporter::GetLibraryTypes() { - if (sizeof(void*) == 8) - return wxString(_("Only libmp3lame64bit.dylib|libmp3lame64bit.dylib|Dynamic Libraries (*.dylib)|*.dylib|All Files (*)|*")); - return wxString(_("Only libmp3lame.dylib|libmp3lame.dylib|Dynamic Libraries (*.dylib)|*.dylib|All Files (*)|*")); + return { + (sizeof(void*) == 8) + ? FileNames::FileType{ + XO("Only libmp3lame64bit.dylib"), { wxT("libmp3lame64bit.dylib") } + } + : FileNames::FileType{ + XO("Only libmp3lame.dylib"), { wxT("libmp3lame.dylib") } + } + , + FileNames::DynamicLibraries, + FileNames::AllFiles + }; } #else //!__WXMAC__ @@ -1547,9 +1561,14 @@ wxString MP3Exporter::GetLibraryName() return wxT("libmp3lame.so.0"); } -wxString MP3Exporter::GetLibraryTypeString() +FileNames::FileTypes MP3Exporter::GetLibraryTypes() { - return wxString(_("Only libmp3lame.so.0|libmp3lame.so.0|Primary Shared Object files (*.so)|*.so|Extended Libraries (*.so*)|*.so*|All Files (*)|*")); + return { + { XO("Only libmp3lame.so.0"), { wxT("libmp3lame.so.0") } }, + { XO("Primary shared object files"), { wxT("so") }, true }, + { XO("Extended libraries"), { wxT("so*") }, true }, + FileNames::AllFiles + }; } #endif diff --git a/src/menus/FileMenus.cpp b/src/menus/FileMenus.cpp index f14505a11..86de831d4 100644 --- a/src/menus/FileMenus.cpp +++ b/src/menus/FileMenus.cpp @@ -228,13 +228,13 @@ void OnExportLabels(const CommandContext &context) fName = (*trackRange.rbegin())->GetName(); fName = FileNames::SelectFile(FileNames::Operation::Export, - XO("Export Labels As:"), - wxEmptyString, - fName, - wxT("txt"), - wxT("*.txt"), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, - &window); + XO("Export Labels As:"), + wxEmptyString, + fName, + wxT("txt"), + { FileNames::TextFiles }, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, + &window); if (fName.empty()) return; @@ -318,7 +318,10 @@ void OnExportMIDI(const CommandContext &context) wxEmptyString, fName, wxT("mid"), - _("MIDI file (*.mid)|*.mid|Allegro file (*.gro)|*.gro"), + { + { XO("MIDI file"), { wxT("mid") }, true }, + { XO("Allegro file"), { wxT("gro") }, true }, + }, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, &window); @@ -415,13 +418,13 @@ void OnImportLabels(const CommandContext &context) wxString fileName = FileNames::SelectFile(FileNames::Operation::Open, - XO("Select a text file containing labels"), - wxEmptyString, // Path - wxT(""), // Name - wxT("txt"), // Extension - _("Text files (*.txt)|*.txt|All files|*"), - wxRESIZE_BORDER, // Flags - &window); // Parent + XO("Select a text file containing labels"), + wxEmptyString, // Path + wxT(""), // Name + wxT("txt"), // Extension + { FileNames::TextFiles, FileNames::AllFiles }, + wxRESIZE_BORDER, // Flags + &window); // Parent if (!fileName.empty()) { wxTextFile f; @@ -463,7 +466,15 @@ void OnImportMIDI(const CommandContext &context) wxEmptyString, // Path wxT(""), // Name wxT(""), // Extension - _("MIDI and Allegro files (*.mid;*.midi;*.gro)|*.mid;*.midi;*.gro|MIDI files (*.mid;*.midi)|*.mid;*.midi|Allegro files (*.gro)|*.gro|All files|*"), + { + { XO("MIDI and Allegro files"), + { wxT("mid"), wxT("midi"), wxT("gro"), }, true }, + { XO("MIDI files"), + { wxT("mid"), wxT("midi"), }, true }, + { XO("Allegro files"), + { wxT("gro"), }, true }, + FileNames::AllFiles + }, wxRESIZE_BORDER, // Flags &window); // Parent @@ -480,13 +491,13 @@ void OnImportRaw(const CommandContext &context) wxString fileName = FileNames::SelectFile(FileNames::Operation::Open, - XO("Select any uncompressed audio file"), - wxEmptyString, // Path - wxT(""), // Name - wxT(""), // Extension - _("All files|*"), - wxRESIZE_BORDER, // Flags - &window); // Parent + XO("Select any uncompressed audio file"), + wxEmptyString, // Path + wxT(""), // Name + wxT(""), // Extension + { FileNames::AllFiles }, + wxRESIZE_BORDER, // Flags + &window); // Parent if (fileName.empty()) return; diff --git a/src/menus/HelpMenus.cpp b/src/menus/HelpMenus.cpp index 77ef9079e..f73606b12 100644 --- a/src/menus/HelpMenus.cpp +++ b/src/menus/HelpMenus.cpp @@ -63,7 +63,7 @@ void ShowDiagnostics( wxEmptyString, defaultPath, wxT("txt"), - wxT("*.txt"), + { FileNames::TextFiles }, wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, &window); if (!fName.empty()) diff --git a/src/prefs/KeyConfigPrefs.cpp b/src/prefs/KeyConfigPrefs.cpp index 5bdf8a33d..06d5a3c84 100644 --- a/src/prefs/KeyConfigPrefs.cpp +++ b/src/prefs/KeyConfigPrefs.cpp @@ -344,13 +344,13 @@ void KeyConfigPrefs::OnImport(wxCommandEvent & WXUNUSED(event)) wxString file = wxT("Audacity-keys.xml"); file = FileNames::SelectFile(FileNames::Operation::Open, - XO("Select an XML file containing Audacity keyboard shortcuts..."), - wxEmptyString, - file, - wxT(""), - _("XML files (*.xml)|*.xml|All files|*"), - wxRESIZE_BORDER, - this); + XO("Select an XML file containing Audacity keyboard shortcuts..."), + wxEmptyString, + file, + wxT(""), + { FileNames::XMLFiles, FileNames::AllFiles }, + wxRESIZE_BORDER, + this); if (!file) { return; @@ -373,13 +373,13 @@ void KeyConfigPrefs::OnExport(wxCommandEvent & WXUNUSED(event)) wxString file = wxT("Audacity-keys.xml"); file = FileNames::SelectFile(FileNames::Operation::Export, - XO("Export Keyboard Shortcuts As:"), - wxEmptyString, - file, - wxT("xml"), - _("XML files (*.xml)|*.xml|All files|*"), - wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, - this); + XO("Export Keyboard Shortcuts As:"), + wxEmptyString, + file, + wxT("xml"), + { FileNames::XMLFiles, FileNames::AllFiles }, + wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER, + this); if (!file) { return;