1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-02 16:49:41 +02:00

Fixes bug #64 and increase the default number of history items remembered by the FileHistory class to 12 from 9.

This commit is contained in:
lllucius 2011-03-11 15:23:35 +00:00
parent 36fe24cdd8
commit 650c1b69d3
2 changed files with 81 additions and 12 deletions

View File

@ -7,19 +7,20 @@
Joshua Haberman
This code allows Audacity to export data by piping it to an external
program. Although it could in theory be made to work on Windows
(and perhaps even Mac), it's not worth it to invest the effort because
commandline encoders are rarely installed there.
program.
**********************************************************************/
#include "../Audacity.h"
#include <wx/button.h>
#include <wx/combobox.h>
#include <wx/log.h>
#include <wx/process.h>
#include <wx/textctrl.h>
#include <FileDialog.h>
#include "Export.h"
#include "../Project.h"
@ -27,6 +28,7 @@
#include "../Prefs.h"
#include "../Internat.h"
#include "../float_cast.h"
#include "../widgets/FileHistory.h"
//----------------------------------------------------------------------------
// ExportCLOptions
@ -40,13 +42,20 @@ public:
void PopulateOrExchange(ShuttleGui & S);
void OnOK(wxCommandEvent & event);
void OnBrowse(wxCommandEvent & event);
private:
wxComboBox *mCmd;
FileHistory mHistory;
DECLARE_EVENT_TABLE()
};
#define ID_BROWSE 5000
BEGIN_EVENT_TABLE(ExportCLOptions, wxDialog)
EVT_BUTTON(wxID_OK, ExportCLOptions::OnOK)
EVT_BUTTON(ID_BROWSE, ExportCLOptions::OnBrowse)
END_EVENT_TABLE()
///
@ -55,6 +64,17 @@ ExportCLOptions::ExportCLOptions(wxWindow *parent)
: wxDialog(parent, wxID_ANY,
wxString(_("Specify Command Line Encoder")))
{
mHistory.Load(*gPrefs, wxT("/FileFormats/ExternalProgramHistory"));
if (mHistory.GetCount() == 0) {
mHistory.AddFileToHistory(wxT("ffmpeg -i - \"%f\""), false);
mHistory.AddFileToHistory(wxT("lame - \"%f\""), false);
}
mHistory.AddFileToHistory(gPrefs->Read(wxT("/FileFormats/ExternalProgramExportCommand"),
mHistory.GetHistoryFile(0)),
false);
ShuttleGui S(this, eIsCreatingFromPrefs);
PopulateOrExchange(S);
@ -64,17 +84,26 @@ ExportCLOptions::ExportCLOptions(wxWindow *parent)
///
void ExportCLOptions::PopulateOrExchange(ShuttleGui & S)
{
wxArrayString cmds;
wxString cmd;
for (size_t i = 0; i < mHistory.GetCount(); i++) {
cmds.Add(mHistory.GetHistoryFile(i));
}
cmd = cmds[0];
S.StartHorizontalLay(wxEXPAND, 0);
{
S.StartStatic(_("Command Line Export Setup"), true);
{
S.StartMultiColumn(2, wxEXPAND);
S.StartMultiColumn(3, wxEXPAND);
{
S.SetStretchyCol(1);
S.TieTextBox(_("Command:"),
wxT("/FileFormats/ExternalProgramExportCommand"),
wxT("lame - \"%f\""),
64);
mCmd = S.AddCombo(_("Command:"),
cmd,
&cmds);
S.Id(ID_BROWSE).AddButton(_("Browse..."),
wxALIGN_CENTER_VERTICAL);
S.AddFixedText(wxT(""));
S.TieCheckBox(_("Show output"),
wxT("/FileFormats/ExternalProgramShowOutput"),
@ -82,7 +111,6 @@ void ExportCLOptions::PopulateOrExchange(ShuttleGui & S)
}
S.EndMultiColumn();
S.AddFixedText(_("Data will be piped to standard in. \"%f\" uses the file name in the export window."));
}
S.EndStatic();
@ -104,13 +132,54 @@ void ExportCLOptions::PopulateOrExchange(ShuttleGui & S)
void ExportCLOptions::OnOK(wxCommandEvent& event)
{
ShuttleGui S(this, eIsSavingToPrefs);
wxString cmd = mCmd->GetValue();
gPrefs->Write(wxT("/FileFormats/ExternalProgramExportCommand"), cmd);
PopulateOrExchange(S);
mHistory.AddFileToHistory(cmd, false);
mHistory.Save(*gPrefs, wxT("/FileFormats/ExternalProgramHistory"));
EndModal(wxID_OK);
return;
}
///
///
void ExportCLOptions::OnBrowse(wxCommandEvent& event)
{
wxString path;
wxString ext;
#if defined(__WXMSW__)
ext = wxT(".exe");
#endif
path = FileSelector(_("Find path to command"),
wxEmptyString,
wxEmptyString,
ext,
wxT("*") + ext,
wxFD_OPEN | wxRESIZE_BORDER,
this);
if (path.IsEmpty()) {
return;
}
if (path.Find(wxT(' ')) == wxNOT_FOUND) {
mCmd->SetValue(path);
}
else {
mCmd->SetValue(wxT('"') + path + wxT('"'));
}
mCmd->SetInsertionPointEnd();
return;
}
//----------------------------------------------------------------------------
// ExportCLProcess
//----------------------------------------------------------------------------
@ -359,7 +428,7 @@ int ExportCL::Export(AudacityProject *project,
ProgressDialog *progress = new ProgressDialog(_("Export"),
selectionOnly ?
_("Exporting the selected audio using command-line encoder") :
_("Exporting the entire project using command-line encoder"));
_("Exporting the entire project using command-line encoder"));
// Start piping the mixed data to the command
while (updateResult == eProgressSuccess && p->IsActive() && os->IsOk()) {
@ -428,7 +497,7 @@ int ExportCL::Export(AudacityProject *project,
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
ShuttleGui S(&dlg, eIsCreating);
S.AddTextWindow(output);
S.AddTextWindow(cmd + wxT("\n\n") + output);
S.StartHorizontalLay(wxALIGN_CENTER, false);
{
S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault();

View File

@ -22,7 +22,7 @@
class AUDACITY_DLL_API FileHistory
{
public:
FileHistory(size_t maxfiles = 9, wxWindowID idbase = wxID_FILE);
FileHistory(size_t maxfiles = 12, wxWindowID idbase = wxID_FILE);
virtual ~FileHistory();
void AddFileToHistory(const wxString & file, bool update = true);