1
0
mirror of https://github.com/cookiengineer/audacity synced 2026-03-05 22:21:15 +01:00

With EXPERIMENTAL_MODULE_PREFS we now have a dynamic list of modules, and we have options, enable, disable, ask, failed, new (=ask once and remember the answer). Without the #define the behaviour is unchanged. We ask about each module each time Audacity runs.

This commit is contained in:
james.k.crook@gmail.com
2014-06-12 21:08:14 +00:00
parent 2b3214049a
commit 55e6a71fd3
3 changed files with 127 additions and 35 deletions

View File

@@ -37,8 +37,41 @@ ModulePrefs::~ModulePrefs()
{
}
void ModulePrefs::GetAllModuleStatuses(){
wxString str;
long dummy;
// Modules could for example be:
// mod-script-pipe
// mod-nyq-bench
// mod-track-panel
mModules.Clear();
mStatuses.Clear();
// Iterate through all Modules listed in prefs.
// Get their names and values.
gPrefs->SetPath( wxT("Module/") );
bool bCont = gPrefs->GetFirstEntry(str, dummy);
while ( bCont ) {
int iStatus;
gPrefs->Read( str, &iStatus, kModuleDisabled );
if( iStatus > kModuleNew ){
iStatus = kModuleNew;
gPrefs->Write( str, iStatus );
}
//wxLogDebug( wxT("Entry: %s Value: %i"), str.c_str(), iStatus );
mModules.Add( str );
mStatuses.Add( iStatus );
bCont = gPrefs->GetNextEntry(str, dummy);
}
gPrefs->SetPath( wxT("") );
}
void ModulePrefs::Populate()
{
GetAllModuleStatuses();
//------------------------- Main section --------------------
// Now construct the GUI itself.
// Use 'eIsCreatingFromPrefs' so that the GUI is
@@ -50,20 +83,26 @@ void ModulePrefs::Populate()
void ModulePrefs::PopulateOrExchange(ShuttleGui & S)
{
wxArrayString StatusChoices;
StatusChoices.Add( _("Disabled" ) );
StatusChoices.Add( _("Enabled" ) );
StatusChoices.Add( _("Ask" ) );
StatusChoices.Add( _("Failed" ) );
StatusChoices.Add( _("New" ) );
S.SetBorder(2);
S.StartStatic(_("Enable these Modules (if present), next time Audacity is started"));
S.StartStatic(_(""));
{
S.AddFixedText(_("These are experimental. Enable them only if you've read the manual\nand know what you are doing.") );
S.TieCheckBox(_("mod-&script-pipe"),
wxT("/Module/mod-script-pipe"),
false);
S.TieCheckBox(_("mod-&nyq-bench"),
wxT("/Module/mod-nyq-bench"),
false);
S.TieCheckBox(_("mod-&track-panel"),
wxT("/Module/mod-track-panel"),
false);
S.AddFixedText(_("These are experimental Modules. Enable them only if you've read the manual\nand know what you are doing.") );
S.AddFixedText(wxString(wxT(" ")) + _("'Ask' means Audacity will ask if you want to load the plug-each time it starts.") );
S.AddFixedText(wxString(wxT(" ")) + _("'Failed' means Audacity thinks the plug-in is broken and won't run it.") );
S.AddFixedText(wxString(wxT(" ")) + _("'New' is like 'Ask', but asks just once.") );
S.StartMultiColumn( 2 );
int i;
for(i=0;i<(int)mModules.GetCount();i++)
S.TieChoice( mModules[i], mStatuses[i], &StatusChoices );
S.EndMultiColumn();
}
S.EndStatic();
}
@@ -72,6 +111,33 @@ bool ModulePrefs::Apply()
{
ShuttleGui S(this, eIsSavingToPrefs);
PopulateOrExchange(S);
int i;
for(i=0;i<(int)mModules.GetCount();i++)
SetModuleStatus( mModules[i], mStatuses[i] );
return true;
}
// static function that tells us about a module.
int ModulePrefs::GetModuleStatus( wxString fname ){
// Default status is new module, and we will ask once.
int iStatus = kModuleNew;
wxString ShortName = wxFileName( fname ).GetName();
wxString PrefName = wxString( wxT("/Module/") ) + ShortName.Lower();
gPrefs->Read( PrefName, &iStatus, kModuleNew );
// fix up a bad status.
if( iStatus > kModuleNew )
iStatus=kModuleNew;
return iStatus;
}
void ModulePrefs::SetModuleStatus( wxString fname, int iStatus ){
wxString ShortName = wxFileName( fname ).GetName();
wxString PrefName = wxString( wxT("/Module/") ) + ShortName.Lower();
gPrefs->Write( PrefName, iStatus );
}