mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-08 08:30:02 +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:
parent
36fe24cdd8
commit
650c1b69d3
@ -7,19 +7,20 @@
|
|||||||
Joshua Haberman
|
Joshua Haberman
|
||||||
|
|
||||||
This code allows Audacity to export data by piping it to an external
|
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
|
program.
|
||||||
(and perhaps even Mac), it's not worth it to invest the effort because
|
|
||||||
commandline encoders are rarely installed there.
|
|
||||||
|
|
||||||
**********************************************************************/
|
**********************************************************************/
|
||||||
|
|
||||||
#include "../Audacity.h"
|
#include "../Audacity.h"
|
||||||
|
|
||||||
#include <wx/button.h>
|
#include <wx/button.h>
|
||||||
|
#include <wx/combobox.h>
|
||||||
#include <wx/log.h>
|
#include <wx/log.h>
|
||||||
#include <wx/process.h>
|
#include <wx/process.h>
|
||||||
#include <wx/textctrl.h>
|
#include <wx/textctrl.h>
|
||||||
|
|
||||||
|
#include <FileDialog.h>
|
||||||
|
|
||||||
#include "Export.h"
|
#include "Export.h"
|
||||||
|
|
||||||
#include "../Project.h"
|
#include "../Project.h"
|
||||||
@ -27,6 +28,7 @@
|
|||||||
#include "../Prefs.h"
|
#include "../Prefs.h"
|
||||||
#include "../Internat.h"
|
#include "../Internat.h"
|
||||||
#include "../float_cast.h"
|
#include "../float_cast.h"
|
||||||
|
#include "../widgets/FileHistory.h"
|
||||||
|
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
// ExportCLOptions
|
// ExportCLOptions
|
||||||
@ -40,13 +42,20 @@ public:
|
|||||||
void PopulateOrExchange(ShuttleGui & S);
|
void PopulateOrExchange(ShuttleGui & S);
|
||||||
void OnOK(wxCommandEvent & event);
|
void OnOK(wxCommandEvent & event);
|
||||||
|
|
||||||
|
void OnBrowse(wxCommandEvent & event);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
wxComboBox *mCmd;
|
||||||
|
FileHistory mHistory;
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#define ID_BROWSE 5000
|
||||||
|
|
||||||
BEGIN_EVENT_TABLE(ExportCLOptions, wxDialog)
|
BEGIN_EVENT_TABLE(ExportCLOptions, wxDialog)
|
||||||
EVT_BUTTON(wxID_OK, ExportCLOptions::OnOK)
|
EVT_BUTTON(wxID_OK, ExportCLOptions::OnOK)
|
||||||
|
EVT_BUTTON(ID_BROWSE, ExportCLOptions::OnBrowse)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
///
|
///
|
||||||
@ -55,6 +64,17 @@ ExportCLOptions::ExportCLOptions(wxWindow *parent)
|
|||||||
: wxDialog(parent, wxID_ANY,
|
: wxDialog(parent, wxID_ANY,
|
||||||
wxString(_("Specify Command Line Encoder")))
|
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);
|
ShuttleGui S(this, eIsCreatingFromPrefs);
|
||||||
|
|
||||||
PopulateOrExchange(S);
|
PopulateOrExchange(S);
|
||||||
@ -64,17 +84,26 @@ ExportCLOptions::ExportCLOptions(wxWindow *parent)
|
|||||||
///
|
///
|
||||||
void ExportCLOptions::PopulateOrExchange(ShuttleGui & S)
|
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.StartHorizontalLay(wxEXPAND, 0);
|
||||||
{
|
{
|
||||||
S.StartStatic(_("Command Line Export Setup"), true);
|
S.StartStatic(_("Command Line Export Setup"), true);
|
||||||
{
|
{
|
||||||
S.StartMultiColumn(2, wxEXPAND);
|
S.StartMultiColumn(3, wxEXPAND);
|
||||||
{
|
{
|
||||||
S.SetStretchyCol(1);
|
S.SetStretchyCol(1);
|
||||||
S.TieTextBox(_("Command:"),
|
mCmd = S.AddCombo(_("Command:"),
|
||||||
wxT("/FileFormats/ExternalProgramExportCommand"),
|
cmd,
|
||||||
wxT("lame - \"%f\""),
|
&cmds);
|
||||||
64);
|
S.Id(ID_BROWSE).AddButton(_("Browse..."),
|
||||||
|
wxALIGN_CENTER_VERTICAL);
|
||||||
S.AddFixedText(wxT(""));
|
S.AddFixedText(wxT(""));
|
||||||
S.TieCheckBox(_("Show output"),
|
S.TieCheckBox(_("Show output"),
|
||||||
wxT("/FileFormats/ExternalProgramShowOutput"),
|
wxT("/FileFormats/ExternalProgramShowOutput"),
|
||||||
@ -82,7 +111,6 @@ void ExportCLOptions::PopulateOrExchange(ShuttleGui & S)
|
|||||||
}
|
}
|
||||||
S.EndMultiColumn();
|
S.EndMultiColumn();
|
||||||
|
|
||||||
|
|
||||||
S.AddFixedText(_("Data will be piped to standard in. \"%f\" uses the file name in the export window."));
|
S.AddFixedText(_("Data will be piped to standard in. \"%f\" uses the file name in the export window."));
|
||||||
}
|
}
|
||||||
S.EndStatic();
|
S.EndStatic();
|
||||||
@ -104,13 +132,54 @@ void ExportCLOptions::PopulateOrExchange(ShuttleGui & S)
|
|||||||
void ExportCLOptions::OnOK(wxCommandEvent& event)
|
void ExportCLOptions::OnOK(wxCommandEvent& event)
|
||||||
{
|
{
|
||||||
ShuttleGui S(this, eIsSavingToPrefs);
|
ShuttleGui S(this, eIsSavingToPrefs);
|
||||||
|
wxString cmd = mCmd->GetValue();
|
||||||
|
|
||||||
|
gPrefs->Write(wxT("/FileFormats/ExternalProgramExportCommand"), cmd);
|
||||||
|
|
||||||
PopulateOrExchange(S);
|
PopulateOrExchange(S);
|
||||||
|
|
||||||
|
mHistory.AddFileToHistory(cmd, false);
|
||||||
|
mHistory.Save(*gPrefs, wxT("/FileFormats/ExternalProgramHistory"));
|
||||||
|
|
||||||
EndModal(wxID_OK);
|
EndModal(wxID_OK);
|
||||||
|
|
||||||
return;
|
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
|
// ExportCLProcess
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
@ -359,7 +428,7 @@ int ExportCL::Export(AudacityProject *project,
|
|||||||
ProgressDialog *progress = new ProgressDialog(_("Export"),
|
ProgressDialog *progress = new ProgressDialog(_("Export"),
|
||||||
selectionOnly ?
|
selectionOnly ?
|
||||||
_("Exporting the selected audio using command-line encoder") :
|
_("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
|
// Start piping the mixed data to the command
|
||||||
while (updateResult == eProgressSuccess && p->IsActive() && os->IsOk()) {
|
while (updateResult == eProgressSuccess && p->IsActive() && os->IsOk()) {
|
||||||
@ -428,7 +497,7 @@ int ExportCL::Export(AudacityProject *project,
|
|||||||
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
|
wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER);
|
||||||
|
|
||||||
ShuttleGui S(&dlg, eIsCreating);
|
ShuttleGui S(&dlg, eIsCreating);
|
||||||
S.AddTextWindow(output);
|
S.AddTextWindow(cmd + wxT("\n\n") + output);
|
||||||
S.StartHorizontalLay(wxALIGN_CENTER, false);
|
S.StartHorizontalLay(wxALIGN_CENTER, false);
|
||||||
{
|
{
|
||||||
S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault();
|
S.Id(wxID_OK).AddButton(_("&OK"))->SetDefault();
|
||||||
|
@ -22,7 +22,7 @@
|
|||||||
class AUDACITY_DLL_API FileHistory
|
class AUDACITY_DLL_API FileHistory
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FileHistory(size_t maxfiles = 9, wxWindowID idbase = wxID_FILE);
|
FileHistory(size_t maxfiles = 12, wxWindowID idbase = wxID_FILE);
|
||||||
virtual ~FileHistory();
|
virtual ~FileHistory();
|
||||||
|
|
||||||
void AddFileToHistory(const wxString & file, bool update = true);
|
void AddFileToHistory(const wxString & file, bool update = true);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user