2010-01-23 19:44:49 +00:00
|
|
|
/**********************************************************************
|
|
|
|
|
|
|
|
Audacity: A Digital Audio Editor
|
|
|
|
|
|
|
|
LibraryPrefs.cpp
|
|
|
|
|
|
|
|
Joshua Haberman
|
|
|
|
Dominic Mazzoni
|
|
|
|
James Crook
|
|
|
|
|
|
|
|
*******************************************************************//**
|
|
|
|
|
|
|
|
\class LibraryPrefs
|
|
|
|
\brief A PrefsPanel used to select manage external libraries like the
|
|
|
|
MP3 and FFmpeg encoding libraries.
|
|
|
|
|
|
|
|
*//*******************************************************************/
|
|
|
|
|
|
|
|
#include "../Audacity.h"
|
|
|
|
|
|
|
|
#include <wx/defs.h>
|
|
|
|
#include <wx/button.h>
|
|
|
|
|
|
|
|
#include "../FFmpeg.h"
|
|
|
|
#include "../ShuttleGui.h"
|
|
|
|
#include "../export/ExportMP3.h"
|
|
|
|
#include "../widgets/LinkingHtmlWindow.h"
|
|
|
|
|
|
|
|
#include "LibraryPrefs.h"
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#define ID_MP3_FIND_BUTTON 7001
|
|
|
|
#define ID_MP3_DOWN_BUTTON 7002
|
|
|
|
#define ID_FFMPEG_FIND_BUTTON 7003
|
|
|
|
#define ID_FFMPEG_DOWN_BUTTON 7004
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE(LibraryPrefs, PrefsPanel)
|
|
|
|
EVT_BUTTON(ID_MP3_FIND_BUTTON, LibraryPrefs::OnMP3FindButton)
|
|
|
|
EVT_BUTTON(ID_MP3_DOWN_BUTTON, LibraryPrefs::OnMP3DownButton)
|
|
|
|
EVT_BUTTON(ID_FFMPEG_FIND_BUTTON, LibraryPrefs::OnFFmpegFindButton)
|
|
|
|
EVT_BUTTON(ID_FFMPEG_DOWN_BUTTON, LibraryPrefs::OnFFmpegDownButton)
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
LibraryPrefs::LibraryPrefs(wxWindow * parent)
|
|
|
|
: PrefsPanel(parent, _("Libraries"))
|
|
|
|
{
|
|
|
|
Populate();
|
|
|
|
}
|
|
|
|
|
|
|
|
LibraryPrefs::~LibraryPrefs()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Creates the dialog and its contents.
|
|
|
|
void LibraryPrefs::Populate()
|
|
|
|
{
|
|
|
|
//------------------------- Main section --------------------
|
|
|
|
// Now construct the GUI itself.
|
2014-06-03 20:30:19 +00:00
|
|
|
// Use 'eIsCreatingFromPrefs' so that the GUI is
|
2010-01-23 19:44:49 +00:00
|
|
|
// initialised with values from gPrefs.
|
|
|
|
ShuttleGui S(this, eIsCreatingFromPrefs);
|
|
|
|
PopulateOrExchange(S);
|
|
|
|
// ----------------------- End of main section --------------
|
|
|
|
|
|
|
|
// Set the MP3 Version string.
|
|
|
|
SetMP3VersionText();
|
|
|
|
SetFFmpegVersionText();
|
|
|
|
}
|
|
|
|
|
2014-06-03 20:30:19 +00:00
|
|
|
/// This PopulateOrExchange function is a good example of mixing the fully
|
2010-01-23 19:44:49 +00:00
|
|
|
/// automatic style of reading/writing from GUI to prefs with the partial form.
|
2014-06-03 20:30:19 +00:00
|
|
|
///
|
2010-01-23 19:44:49 +00:00
|
|
|
/// You'll notice that some of the Tie functions have Prefs identifiers in them
|
2014-06-03 20:30:19 +00:00
|
|
|
/// and others don't.
|
2010-01-23 19:44:49 +00:00
|
|
|
void LibraryPrefs::PopulateOrExchange(ShuttleGui & S)
|
|
|
|
{
|
|
|
|
S.SetBorder(2);
|
|
|
|
S.StartStatic(_("MP3 Export Library"));
|
|
|
|
{
|
|
|
|
S.StartTwoColumn();
|
|
|
|
{
|
|
|
|
S.AddVariableText(_("MP3 Library Version:"),
|
|
|
|
true,
|
|
|
|
wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
|
|
|
|
mMP3Version = S.AddVariableText(wxT("9.99"),
|
|
|
|
true,
|
|
|
|
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
|
|
|
|
S.AddVariableText(_("MP3 Library:"),
|
|
|
|
true,
|
|
|
|
wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
|
2012-06-25 01:41:57 +00:00
|
|
|
wxButton *locate_button = S.Id(ID_MP3_FIND_BUTTON).AddButton(_("&Locate..."),
|
2010-01-23 19:44:49 +00:00
|
|
|
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
|
|
|
|
S.AddVariableText(_("LAME MP3 Library:"),
|
|
|
|
true,
|
|
|
|
wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
|
2012-06-25 01:41:57 +00:00
|
|
|
wxButton *download_button = S.Id(ID_MP3_DOWN_BUTTON).AddButton(_("&Download"),
|
2010-01-23 19:44:49 +00:00
|
|
|
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
|
2012-06-25 01:41:57 +00:00
|
|
|
#ifdef DISABLE_DYNAMIC_LOADING_LAME
|
|
|
|
locate_button->Enable(FALSE);
|
|
|
|
download_button->Enable(FALSE);
|
2013-09-12 16:52:30 +00:00
|
|
|
#else
|
|
|
|
(void)locate_button;
|
|
|
|
(void)download_button;
|
2012-06-25 01:41:57 +00:00
|
|
|
#endif // DISABLE_DYNAMIC_LOADING_LAME
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndTwoColumn();
|
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
|
|
|
|
S.StartStatic(_("FFmpeg Import/Export Library"));
|
|
|
|
{
|
|
|
|
S.StartTwoColumn();
|
|
|
|
{
|
|
|
|
S.AddVariableText(_("FFmpeg Library Version:"),
|
|
|
|
true,
|
|
|
|
wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
|
|
|
|
#if defined(USE_FFMPEG)
|
|
|
|
mFFmpegVersion = S.AddVariableText(_("No compatible FFmpeg library was found"),
|
|
|
|
true,
|
|
|
|
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
|
|
|
|
#else
|
|
|
|
mFFmpegVersion = S.AddVariableText(wxT("FFmpeg support is not compiled in"),
|
|
|
|
true,
|
|
|
|
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
|
|
|
|
#endif
|
|
|
|
S.AddVariableText(_("FFmpeg Library:"),
|
|
|
|
true,
|
|
|
|
wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
|
|
|
|
S.Id(ID_FFMPEG_FIND_BUTTON);
|
2014-06-03 20:30:19 +00:00
|
|
|
wxButton *bfnd = S.AddButton(_("Loca&te..."),
|
2010-01-23 19:44:49 +00:00
|
|
|
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
|
|
|
|
S.AddVariableText(_("FFmpeg Library:"),
|
|
|
|
true,
|
|
|
|
wxALL | wxALIGN_RIGHT | wxALIGN_CENTRE_VERTICAL);
|
|
|
|
S.Id(ID_FFMPEG_DOWN_BUTTON);
|
|
|
|
wxButton *bdwn = S.AddButton(_("Dow&nload"),
|
|
|
|
wxALL | wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
|
2012-08-29 21:31:11 +00:00
|
|
|
#if !defined(USE_FFMPEG) || defined(DISABLE_DYNAMIC_LOADING_FFMPEG)
|
2010-01-23 19:44:49 +00:00
|
|
|
bdwn->Enable(FALSE);
|
|
|
|
bfnd->Enable(FALSE);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
S.EndTwoColumn();
|
2012-06-01 06:11:15 +00:00
|
|
|
#ifdef EXPERIMENTAL_OD_FFMPEG
|
2013-05-25 15:36:04 +00:00
|
|
|
wxCheckBox* checkbox = S.TieCheckBox(_("Allow &background on-demand loading"),
|
2012-06-01 06:11:15 +00:00
|
|
|
wxT("/Library/FFmpegOnDemand"),
|
|
|
|
false);
|
2013-05-25 15:36:04 +00:00
|
|
|
#if !defined(USE_FFMPEG)
|
|
|
|
checkbox->Enable(FALSE);
|
|
|
|
#endif
|
2012-06-01 06:11:15 +00:00
|
|
|
#endif
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
S.EndStatic();
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Sets the a text area on the dialog to have the name
|
|
|
|
/// of the MP3 Library version.
|
|
|
|
void LibraryPrefs::SetMP3VersionText(bool prompt)
|
|
|
|
{
|
|
|
|
mMP3Version->SetLabel(GetMP3Version(this, prompt));
|
2012-10-13 00:59:14 +00:00
|
|
|
mMP3Version->SetName(mMP3Version->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Opens a file-finder dialog so that the user can
|
|
|
|
/// tell us where the MP3 library is.
|
2013-08-25 21:51:26 +00:00
|
|
|
void LibraryPrefs::OnMP3FindButton(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
SetMP3VersionText(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Opens a file-finder dialog so that the user can
|
|
|
|
/// tell us where the MP3 library is.
|
2013-08-25 21:51:26 +00:00
|
|
|
void LibraryPrefs::OnMP3DownButton(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2013-05-19 00:22:26 +00:00
|
|
|
wxString url = wxT("http://manual.audacityteam.org/o/man/faq_installation_and_plug_ins.html#lame");
|
2010-01-23 19:44:49 +00:00
|
|
|
::OpenInDefaultBrowser(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
void LibraryPrefs::SetFFmpegVersionText()
|
|
|
|
{
|
|
|
|
mFFmpegVersion->SetLabel(GetFFmpegVersion(this));
|
2012-10-13 00:59:14 +00:00
|
|
|
mFFmpegVersion->SetName(mFFmpegVersion->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
|
2010-01-23 19:44:49 +00:00
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void LibraryPrefs::OnFFmpegFindButton(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
|
|
|
#ifdef USE_FFMPEG
|
|
|
|
FFmpegLibs* FFmpegLibsInst = PickFFmpegLibs();
|
|
|
|
bool showerrs =
|
|
|
|
#if defined(__WXDEBUG__)
|
|
|
|
true;
|
|
|
|
#else
|
|
|
|
false;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
FFmpegLibsInst->FreeLibs();
|
|
|
|
// Load the libs ('true' means that all errors will be shown)
|
|
|
|
bool locate = !LoadFFmpeg(showerrs);
|
|
|
|
|
|
|
|
// Libs are fine, don't show "locate" dialog unless user really wants it
|
|
|
|
if (!locate) {
|
|
|
|
int response = wxMessageBox(_("Audacity has automatically detected valid FFmpeg libraries.\nDo you still want to locate them manually?"),
|
|
|
|
wxT("Success"),
|
|
|
|
wxCENTRE | wxYES_NO | wxNO_DEFAULT |wxICON_QUESTION);
|
|
|
|
if (response == wxYES) {
|
|
|
|
locate = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (locate) {
|
|
|
|
// Show "Locate FFmpeg" dialog
|
|
|
|
FFmpegLibsInst->FindLibs(this);
|
|
|
|
FFmpegLibsInst->FreeLibs();
|
|
|
|
LoadFFmpeg(showerrs);
|
|
|
|
}
|
|
|
|
SetFFmpegVersionText();
|
|
|
|
|
|
|
|
DropFFmpegLibs();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2013-08-25 21:51:26 +00:00
|
|
|
void LibraryPrefs::OnFFmpegDownButton(wxCommandEvent & WXUNUSED(event))
|
2010-01-23 19:44:49 +00:00
|
|
|
{
|
2013-05-19 00:22:26 +00:00
|
|
|
wxString url = wxT("http://manual.audacityteam.org/o/man/faq_installation_and_plug_ins.html#ffdown");
|
2010-01-23 19:44:49 +00:00
|
|
|
::OpenInDefaultBrowser(url);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool LibraryPrefs::Apply()
|
2014-06-03 20:30:19 +00:00
|
|
|
{
|
2010-01-23 19:44:49 +00:00
|
|
|
ShuttleGui S(this, eIsSavingToPrefs);
|
2014-06-03 20:30:19 +00:00
|
|
|
PopulateOrExchange(S);
|
|
|
|
|
2010-01-23 19:44:49 +00:00
|
|
|
return true;
|
|
|
|
}
|