Update of /cvsroot/audacity/audacity-src/src
In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv21122

Modified Files:
        BatchCommandDialog.cpp BatchCommands.cpp UndoManager.cpp 
        BatchCommandDialog.h BatchProcessDialog.cpp BatchCommands.h 
        Menus.h Menus.cpp BatchProcessDialog.h FileNames.cpp 
        FileNames.h 
Log Message:
First cleanup of Chain processing.

Index: BatchProcessDialog.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/BatchProcessDialog.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- BatchProcessDialog.cpp      29 Sep 2006 05:50:21 -0000      1.10
+++ BatchProcessDialog.cpp      1 Oct 2006 07:23:49 -0000       1.11
@@ -42,7 +42,6 @@
 #include "Theme.h"
 #include "AllThemeResources.h"
 
-
 #define ChainsListID       7001
 #define ApplyToProjectID   7002
 #define ApplyToFilesID     7003
@@ -54,7 +53,9 @@
 END_EVENT_TABLE()
 
 BatchProcessDialog::BatchProcessDialog(wxWindow * parent):
[...967 lines suppressed...]
-   {
-      // Add new rogue
-      AddItem( _("- END -"),wxT(""));
-      mChain->Add( mBatchCommands.Join( command, params ) );
-   }
-   else
-   {
-      (*mChain)[itemNo] = mBatchCommands.Join( command, params );
+///
+void EditChainsDialog::OnKeyDown(wxKeyEvent &event)
+{
+   if (event.GetKeyCode() == WXK_DELETE) {
+      printf("hello\n");
    }
 
-   mList->Refresh(false);
+   event.Skip();
 }
 
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a

Index: FileNames.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/FileNames.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- FileNames.cpp       19 Jul 2006 20:55:29 -0000      1.8
+++ FileNames.cpp       1 Oct 2006 07:23:49 -0000       1.9
@@ -93,6 +93,11 @@
    return gDataDir;
 }
 
+wxString FileNames::ChainDir()
+{
+   return FileNames::MkDir( wxFileName( DataDir(), wxT("Chains") 
).GetFullPath() );
+}
+
 wxString FileNames::ThemeDir()
 {
    return FileNames::MkDir( wxFileName( DataDir(), wxT("Theme") 
).GetFullPath() );

Index: BatchCommandDialog.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/BatchCommandDialog.cpp,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- BatchCommandDialog.cpp      3 Jul 2006 19:15:47 -0000       1.7
+++ BatchCommandDialog.cpp      1 Oct 2006 07:23:49 -0000       1.8
@@ -39,6 +39,7 @@
 #include "commands/CommandManager.h"
 #include "effects/Effect.h"
 #include "BatchCommands.h"
+#include "ShuttleGui.h"
 
 
 #define CommandsListID        7001
@@ -52,76 +53,63 @@
 END_EVENT_TABLE();
 
 BatchCommandDialog::BatchCommandDialog(wxWindow * parent, wxWindowID id):
-   wxDialog(parent, id,
-            _("Select Command"),
-            wxDefaultPosition, wxSize(250,200), wxDIALOG_MODAL | wxCAPTION | 
wxTHICK_FRAME)
+   wxDialog(parent, id, _("Select Command"),
+            wxDefaultPosition, wxSize(250,200),
+            wxDIALOG_MODAL | wxCAPTION | wxTHICK_FRAME)
 {
+   SetLabel(_("Select Command"));         // Provide visual label
+   SetName(_("Select Command"));          // Provide audible label
+   Populate();
+}
 
-   wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
-
-   wxFlexGridSizer * gridSizer = new wxFlexGridSizer( 2,2,5,5);// 2 rows, 3 
cols, 5 padding.
-   gridSizer->AddGrowableCol( 1 );
-
-   wxControl *item;
-   
-   item = new wxStaticText(this, -1, _("Command:"),  wxDefaultPosition, 
wxDefaultSize, 0);
-   gridSizer->Add(item, 0, wxALIGN_RIGHT | wxTOP, 3);
-
-   wxBoxSizer * boxSizer = new wxBoxSizer( wxHORIZONTAL ); 
-   mCommand = new wxTextCtrl(this, -1, wxT(""));
-   boxSizer->Add(mCommand, 1, wxALIGN_LEFT | wxALL | wxGROW, 0);
-   mEditParams = new wxButton( this, EditParamsButtonID, _("&Edit 
Parameters"));
-   boxSizer->Add(mEditParams, 0, wxALIGN_LEFT | wxLEFT, 3);
-   gridSizer->Add(boxSizer, 0, wxALIGN_LEFT | wxALL | wxGROW, 0);
-
-   item = new wxStaticText(this, -1, _("Parameters:"),  wxDefaultPosition, 
wxDefaultSize, 0);
-   gridSizer->Add(item, 0, wxALIGN_RIGHT | wxTOP, 3);
-   mParameters = new wxTextCtrl(this, -1, wxT(""),  wxDefaultPosition, 
wxSize(250,-1),0);
-   gridSizer->Add(mParameters, 0, wxALIGN_LEFT | wxALL | wxGROW, 0);
-
-   mainSizer->Add(gridSizer, 0, wxALIGN_LEFT | wxALL | wxGROW, 5);
+void BatchCommandDialog::Populate()
+{
+   //------------------------- Main section --------------------
+   ShuttleGui S(this, eIsCreating);
+   PopulateOrExchange(S);
+   // ----------------------- End of main section --------------
+}
 
-   item = new wxStaticText(this, -1,
-                     _("Choose from the list below"),
-                     wxDefaultPosition, wxDefaultSize, 0);
+void BatchCommandDialog::PopulateOrExchange(ShuttleGui &S)
+{
+   S.StartVerticalLay(true);
+   {
+      S.StartMultiColumn(3, wxEXPAND);
+      {
+         S.SetStretchyCol(1);
+         mCommand = S.AddTextBox(_("&Command"), wxT(""), 20);
+         mCommand->SetEditable(false);
+         mEditParams = S.Id(EditParamsButtonID).AddButton(_("&Edit 
Parameters"));
+      }
+      S.EndMultiColumn();
 
-   mainSizer->Add(item, 0, wxALIGN_LEFT | wxALL, 5);
+      S.StartMultiColumn(2, wxEXPAND);
+      {
+         S.SetStretchyCol(1);
+         mParameters = S.AddTextBox(_("&Parameters"), wxT(""), 0);
+      }
+      S.EndMultiColumn();
 
-   int i;
+      S.StartStatic(_("C&hoose command"), true);
+      {
+         S.SetStyle(wxSUNKEN_BORDER | wxLC_LIST | wxLC_SINGLE_SEL);
+         mChoices = S.Id(CommandsListID).AddListControl();
+      }
+      S.EndStatic();
+   }
+   S.EndVerticalLay();
 
-   mChoices = new wxListCtrl( this, CommandsListID ,
-      wxDefaultPosition, wxDefaultSize,
-      wxLC_LIST | wxLC_SINGLE_SEL| wxSUNKEN_BORDER 
-      );
+   GetSizer()->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALIGN_RIGHT | 
wxBOTTOM, 10);
 
-   wxASSERT( mChoices );
-   for(i=0;i<99;i++)
+   for(int i=0;i<99;i++)
    {
       mChoices->InsertItem( i, wxString::Format(wxT("Item%02i"),i));
    }
    PopulateCommandList();
 
-   mainSizer->Add(mChoices, 1, wxEXPAND | wxALL, 5);
-
-   wxBoxSizer *okSizer = new wxBoxSizer(wxHORIZONTAL);
-
-   wxButton *cancel =
-       new wxButton(this, wxID_CANCEL, _("&Cancel"), wxDefaultPosition,
-                    wxDefaultSize, 0);
-   okSizer->Add(cancel, 0, wxALIGN_CENTRE | wxALL, 5);
-
-   mOK = 
-       new wxButton(this, wxID_OK, _("&OK"), wxDefaultPosition,
-                    wxDefaultSize, 0);
-   mOK->SetDefault();
-   mOK->SetFocus();
-   okSizer->Add(mOK, 0, wxALIGN_CENTRE | wxALL, 5);
-
-   mainSizer->Add(okSizer,0 , wxALIGN_CENTRE | wxALL, 5);
-
-   SetAutoLayout(TRUE);
-   SetSizer(mainSizer);
    SetSize(350, 400);
+   SetSizeHints(GetSize());
+   Center();
 }
 
 void BatchCommandDialog::PopulateCommandList()
@@ -153,22 +141,20 @@
 
 void BatchCommandDialog::ValidateChoices()
 {
-   mOK->Enable(false);
 }
 
-void BatchCommandDialog::OnChoice(wxCommandEvent & event)
+void BatchCommandDialog::OnChoice(wxCommandEvent &event)
 {
-   ValidateChoices();
 }
 
-void BatchCommandDialog::OnOk(wxCommandEvent & event)
+void BatchCommandDialog::OnOk(wxCommandEvent &event)
 {
-   mSelectedCommand = mCommand->GetValue();
-   mSelectedParameters = mParameters->GetValue();
-   EndModal(true );
+   mSelectedCommand = mCommand->GetValue().Strip(wxString::both);
+   mSelectedParameters = mParameters->GetValue().Strip(wxString::both);
+   EndModal(true);
 }
 
-void BatchCommandDialog::OnCancel(wxCommandEvent & event)
+void BatchCommandDialog::OnCancel(wxCommandEvent &event)
 {
    EndModal(false);
 }
@@ -180,6 +166,8 @@
    mCommand->SetValue( command );
    wxString params = BatchCommands::GetCurrentParamsFor( command );
    mParameters->SetValue( params );
+   Effect * f = BatchCommands::GetEffectFromCommandName( command );
+   mEditParams->Enable( f != NULL );
 }
 
 void BatchCommandDialog::OnEditParams(wxCommandEvent &event)
@@ -195,7 +183,7 @@
       // we've just prompted for the parameters, so the values
       // that are current have changed.
       params = BatchCommands::GetCurrentParamsFor( command );
-      mParameters->SetValue( params );
+      mParameters->SetValue( params.Strip(wxString::both) );
       mParameters->Refresh();
    }
 }
@@ -204,6 +192,12 @@
 {
    mCommand->SetValue( Command );
    mParameters->SetValue( Params );
+
+   int item = mChoices->FindItem(-1, Command);
+   if( item != -1 )
+   {
+      mChoices->SetItemState(item, wxLIST_STATE_SELECTED, 
wxLIST_STATE_SELECTED);
+   }
 }
 
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a

Index: FileNames.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/FileNames.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- FileNames.h 19 Jul 2006 20:55:30 -0000      1.6
+++ FileNames.h 1 Oct 2006 07:23:49 -0000       1.7
@@ -23,6 +23,7 @@
    static wxString TempDir();
    static wxString DataDir();
    static wxString AutoSaveDir();
+   static wxString ChainDir();
    static wxString ThemeDir();
    static wxString ThemeComponentsDir();
    static wxString ThemeCachePng();

Index: BatchCommands.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/BatchCommands.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- BatchCommands.h     29 Sep 2006 05:50:21 -0000      1.6
+++ BatchCommands.h     1 Oct 2006 07:23:49 -0000       1.7
@@ -17,75 +17,66 @@
 
 class Effect;
 
-WX_DECLARE_STRING_HASH_MAP(wxArrayString, CommandChains);
-
 class BatchCommands {
  public:
    // constructors and destructors
    BatchCommands();
  public:
-       bool ReportAndSkip( const wxString command, const wxString params );
+   bool ApplyChain(const wxString & filename = wxT(""));
    bool ApplyCommand( const wxString command, const wxString params );
    bool ApplyCommandInBatchMode(const wxString & command, const wxString 
&params);
-   bool ApplyChain(const wxString & name, const wxString & filename);
    bool ApplySpecialCommand(int iCommand, const wxString command,const 
wxString params);
    bool ApplyEffectCommand(Effect * f, const wxString command, const wxString 
params);
    bool ApplyMenuCommand(const wxString command, const wxString params);
-   wxString mFileName;
+   bool ReportAndSkip( const wxString command, const wxString params );
+   void AbortBatch();
 
    // Utility functions for the special commands.
    bool WriteMp3File( const wxString Name, int bitrate );
    double GetEndTime();
    bool IsMono();
 
-// These commands do not depend on the command list.
-       static bool PromptForParamsFor( wxString command );
-       static Effect * GetEffectFromCommandName( wxString command );
-       static wxString GetCurrentParamsFor( wxString command );
+   // These commands do not depend on the command list.
+   wxArrayString GetNames();
+   static bool PromptForParamsFor( wxString command );
+   static Effect * GetEffectFromCommandName( wxString command );
+   static wxString GetCurrentParamsFor( wxString command );
    static bool SetCurrentParametersFor( Effect * f, const wxString command, 
const wxString params);
    static wxArrayString GetAllCommands();
 
-// These commands do depend on the command list.    
-       wxString GetChainWarnings();
-       void ResetChain();
-       void AddToChain( const wxString & command );
-   void AbortBatch();
-       void ReadChain();
-       void WriteChain();
-       void LoadChain( wxWindow * parent );
-       void SaveChain( wxWindow * parent );
-       void SetWavToMp3Chain();
-       void SetCleanSpeechChain();
+   // These commands do depend on the command list.    
+   void ResetChain();
 
-   void ReadChains();
-   void WriteChains();
-   void FlushChains();
-   wxArrayString GetChainNames();
-   int GetChainCount();
+   bool ReadChain(const wxString & chain);
+   bool WriteChain(const wxString & chain);
+   bool AddChain(const wxString & chain);
+   bool DeleteChain(const wxString & name);
+   bool RenameChain(const wxString & oldchain, const wxString & newchain);
 
-   wxArrayString * GetChain(const wxString & name);
-   wxArrayString * RenameChain(const wxString & oldname, const wxString & 
newname);
-   void DeleteChain(const wxString & name);
+   void AddToChain(const wxString & command, int before = -1);
+   void AddToChain(const wxString & command, const wxString & params, int 
before = -1);
+   void DeleteFromChain(int index);
+   wxString GetCommand(int index);
+   wxString GetParams(int index);
+   int GetCount();
 
-   bool IsFixed(const wxString & name);
+   void SetWavToMp3Chain();
+   void SetCleanSpeechChain();
 
-   wxArrayString * RestoreChain(const wxString & name);
+   bool IsFixed(const wxString & name);
 
-   void ImportChain(wxWindow *parent, const wxString & name);
-   void ExportChain(wxWindow *parent, const wxString & name);
+   void RestoreChain(const wxString & name);
 
    void Split(const wxString & str, wxString & command, wxString & param);
    wxString Join(const wxString & command, const wxString & param);
-       wxString Defaults(const wxString & command);
 
    wxArrayString mCommandChain;
    wxArrayString mParamsChain;
    bool mAbort;
 
-   CommandChains mCommandChains;
+   wxString mFileName;
 };
 
-
 #endif
 
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a

Index: BatchCommands.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/BatchCommands.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- BatchCommands.cpp   29 Sep 2006 05:50:21 -0000      1.21
+++ BatchCommands.cpp   1 Oct 2006 07:23:49 -0000       1.22
@@ -19,6 +19,7 @@
 #include "Audacity.h"
 
 #include <wx/defs.h>
+#include <wx/dir.h>
 #include <wx/msgdlg.h>
 #include <wx/filedlg.h>
 #include <wx/textfile.h>
@@ -27,13 +28,13 @@
 #include "BatchCommands.h"
 #include "commands/CommandManager.h"
 #include "effects/Effect.h"
-//#include "../images/Arrow.xpm"
+#include "FileNames.h"
 #include "Internat.h"
-#include "../Prefs.h"
+#include "Prefs.h"
 #include "Shuttle.h"
-#include "../export/ExportMP3.h"
-#include "../export/ExportOGG.h"
-#include "../export/ExportPCM.h"
+#include "export/ExportMP3.h"
+#include "export/ExportOGG.h"
+#include "export/ExportPCM.h"
 
 #include "Theme.h"
 #include "AllThemeResources.h"
@@ -59,167 +60,123 @@
    wxT("ExportWav")
 };
 
+static const wxString CleanSpeech = wxT("CleanSpeech");
+static const wxString MP3Conversion = wxT("MP3 Conversion");
 
 BatchCommands::BatchCommands()
 {
    ResetChain();
-}
 
-void BatchCommands::WriteChain()
-{
-   int i;
-   wxString PrefName;
-   gPrefs->DeleteGroup( wxT("Batch/Chain") );
-   for(i=0;i<(int)mCommandChain.GetCount();i++)
-   {
-      PrefName = wxString::Format( wxT("/Batch/Chain/Command%02i"), i);
-      gPrefs->Write(PrefName, mCommandChain[i] + wxT(":") + mParamsChain[i]);
+   wxArrayString names = GetNames();
+   if (names.Index(CleanSpeech) == wxNOT_FOUND) {
+      AddChain(CleanSpeech);
+      RestoreChain(CleanSpeech);
+      WriteChain(CleanSpeech);
+   }
+
+   if (names.Index(MP3Conversion) == wxNOT_FOUND) {
+      AddChain(MP3Conversion);
+      RestoreChain(MP3Conversion);
+      WriteChain(MP3Conversion);
    }
 }
 
-void BatchCommands::ReadChain()
+wxString BatchCommands::GetCommand(int index)
 {
-//   SetCleanSpeechChain();
-   ResetChain();
-   int i;
-   int splitAt;
-   const int maxCommands = 20;
-   wxString PrefName;
-   wxString Value;
-   for(i=0;i<maxCommands;i++)
-   {
-      PrefName = wxString::Format( wxT("/Batch/Chain/Command%02i"), i);
-      Value = gPrefs->Read(PrefName, wxT(""));
-      if( Value.IsEmpty() )
-         return;
-      splitAt = Value.Find( wxT(':') );
-      if( splitAt < 0 )
-         return;
-      mCommandChain.Add( Value.Mid( 0,splitAt ));
-      mParamsChain.Add( Value.Mid( splitAt+1));
+   if (index < 0 || index >= (int)mCommandChain.GetCount()) {
+      return wxT("");
    }
+
+   return mCommandChain[index];
 }
 
-void BatchCommands::LoadChain( wxWindow *parent )
+wxString BatchCommands::GetParams(int index)
 {
-   // Get the initial path
-   wxString pName = gPrefs->Read( wxT("/Batch/DefaultChainPath"),
-                                  ::wxGetCwd() );
+   if (index < 0 || index >= (int)mParamsChain.GetCount()) {
+      return wxT("");
+   }
 
-   // Prompt user for a file name
-   wxString fName = wxFileSelector( _("Select a command chain file..."),
-                                    pName,         // Path
-                                    wxT(""),       // Name
-                                    wxT(""),       // Extension
-                                    _("Text files (*.txt)|*.txt|All files 
(*.*)|*.*"),
-                                    0,             // Flags
-                                    parent);       // Parent
+   return mParamsChain[index];
+}
 
-   // Nothing to do
-   if( !fName )
-      return;
+int BatchCommands::GetCount()
+{
+   return (int)mCommandChain.GetCount();
+}
 
-   // Remember path
-   gPrefs->Write( wxT("/Batch/DefaultChainPath"), wxPathOnly( fName ) );
+bool BatchCommands::ReadChain(const wxString & chain)
+{
+   // Clear any previous chain
+   ResetChain();
 
-   // Remember last filename
-   gPrefs->Write( wxT("/Batch/LastFile"), fName );
+   // Build the filename
+   wxFileName name(FileNames::ChainDir(), chain, wxT("txt"));
 
    // Set the file name
-   wxTextFile tf( fName );
+   wxTextFile tf(name.GetFullPath());
 
    // Open and check
    tf.Open();
-   if( !tf.IsOpened() )
-   {
+   if (!tf.IsOpened()) {
       // wxTextFile will display any errors
-      return;
+      return false;
    }
 
-   // Clear any previous chain
-   ResetChain();
-
    // Load commands from the file
-   int i;
    int lines = tf.GetLineCount();
-   int splitAt;
-   wxString cmd;
-   wxString parm;
-   for( i = 0; i < lines; i++ )
-   {
-      // Find the command name terminator...ingore line if not found
-      splitAt = tf[ i ].Find( wxT(':') );
-      if( splitAt < 0 )
-         continue;
+   if (lines > 0) {
+      for (int i = 0; i < lines; i++) {
 
-      // Parse and clean
-      cmd = tf[ i ].Left( splitAt ).Trim( false ).Trim( true );
-      parm = tf[ i ].Mid( splitAt + 1 ).Trim( false ).Trim( true );
+         // Find the command name terminator...ingore line if not found
+         int splitAt = tf[i].Find(wxT(':'));
+         if (splitAt < 0)
+            continue;
 
-      // Add to lists
-      mCommandChain.Add( cmd );
-      mParamsChain.Add( parm );
+         // Parse and clean
+         wxString cmd = tf[i].Left(splitAt).Strip(wxString::both);
+         wxString parm = tf[i].Mid(splitAt + 1).Strip(wxString::both);
+
+         // Add to lists
+         mCommandChain.Add(cmd);
+         mParamsChain.Add(parm);
+      }
    }
 
    // Done with the file
    tf.Close();
-}
-
-void BatchCommands::SaveChain( wxWindow *parent )
-{
-   // Get the initial path
-   wxString pName = gPrefs->Read( wxT("/DefaultChainPath"),
-                                  ::wxGetCwd() );
-
-   // Get last used filename
-   wxString fName = gPrefs->Read( wxT("/Batch/LastFile"),
-                                  wxT("Chain.txt") );
-
-   // Prompt user for a file name
-   fName = wxFileSelector( _("Save command chain As:"),
-                           NULL,                         // Path
-                           fName,                        // Name
-                           wxT("txt"),                   // Extension
-                           _("Text files (*.txt)|*.txt|All files (*.*)|*.*"),
-                           wxSAVE | wxOVERWRITE_PROMPT,  // Flags
-                           parent );                     // Parent
 
-   // Nothing to do
-   if( !fName )
-      return;
+   return true;
+}
 
-   // Remember path
-   gPrefs->Write( wxT("/DefaultChainPath"), wxPathOnly( fName ) );
 
-   // Remember last filename
-   gPrefs->Write( wxT("/Batch/LastFile"), fName );
+bool BatchCommands::WriteChain(const wxString & chain)
+{
+   // Build the filename
+   wxFileName name(FileNames::ChainDir(), chain, wxT("txt"));
 
    // Set the file name
-   wxTextFile tf( fName );
+   wxTextFile tf(name.GetFullPath());
 
-   // (Possibly) create new file
-   if( !tf.Exists() )
-   {
+   // Create the file (Create() doesn't leave the file open)
+   if (!tf.Exists()) {
       tf.Create();
    }
 
-   // Open and check
+   // Open it
    tf.Open();
-   if( !tf.IsOpened() )
-   {
+
+   if (!tf.IsOpened()) {
       // wxTextFile will display any errors
-      return;
+      return false;
    }
 
    // Start with a clean slate
    tf.Clear();
 
    // Copy over the commands
-   int i;
    int lines = mCommandChain.GetCount();
-   for( i = 0; i < lines; i++ )
-   {
-      tf.AddLine( mCommandChain[i] + wxT(":") + mParamsChain[ i ] );
+   for (int i = 0; i < lines; i++) {
+      tf.AddLine(mCommandChain[i] + wxT(":") + mParamsChain[ i ]);
    }
 
    // Write the chain
@@ -227,9 +184,40 @@
 
    // Done with the file
    tf.Close();
+
+   return true;
+}
+
+bool BatchCommands::AddChain(const wxString & chain)
+{
+   // Build the filename
+   wxFileName name(FileNames::ChainDir(), chain, wxT("txt"));
+
+   // Set the file name
+   wxTextFile tf(name.GetFullPath());
+
+   // Create it..Create will display errors
+   return tf.Create();
+}
+
+bool BatchCommands::DeleteChain(const wxString & chain)
+{
+   // Build the filename
+   wxFileName name(FileNames::ChainDir(), chain, wxT("txt"));
+
+   // Delete it...wxRemoveFile will display errors
+   return wxRemoveFile(name.GetFullPath());
 }
 
+bool BatchCommands::RenameChain(const wxString & oldchain, const wxString & 
newchain)
+{
+   // Build the filenames
+   wxFileName oname(FileNames::ChainDir(), oldchain, wxT("txt"));
+   wxFileName nname(FileNames::ChainDir(), newchain, wxT("txt"));
 
+   // Rename it...wxRenameFile will display errors
+   return wxRenameFile(oname.GetFullPath(), nname.GetFullPath());
+}
 
 void BatchCommands::SetCleanSpeechChain()
 {
@@ -253,6 +241,7 @@
 void BatchCommands::SetWavToMp3Chain()
 {
    ResetChain();
+ 
    AddToChain( wxT("Import") );
    AddToChain(   _("Normalize") );
    AddToChain( wxT("ExportMp3") );
@@ -595,21 +584,16 @@
 
 // ApplyChain returns true on success, false otherwise.
 // Any error reporting to the user has already been done.
-bool BatchCommands::ApplyChain(const wxString & name, const wxString & 
filename)
+bool BatchCommands::ApplyChain(const wxString & filename)
 {
-   wxArrayString *chain = GetChain(name);
    mFileName = filename;
    unsigned int i;
    bool res = true;
 
    mAbort = false;
 
-   for (i = 0; i < chain->GetCount(); i++) {
-      wxString command;
-      wxString params;
-
-      Split((*chain)[i], command, params);
-      if (!ApplyCommandInBatchMode(command, params) || mAbort) {
+   for (i = 0; i < mCommandChain.GetCount(); i++) {
+      if (!ApplyCommandInBatchMode(mCommandChain[i], mParamsChain[i]) || 
mAbort) {
          res = false;
          break;
       }
@@ -626,30 +610,36 @@
    mAbort = true;
 }
 
-void BatchCommands::AddToChain(const wxString &command)
+void BatchCommands::AddToChain(const wxString &command, int before)
 {
-   mCommandChain.Add( command );
-   mParamsChain.Add( GetCurrentParamsFor( command ));
+   AddToChain(command, GetCurrentParamsFor(command), before);
 }
 
-void BatchCommands::ResetChain()
+void BatchCommands::AddToChain(const wxString &command, const wxString 
&params, int before)
 {
-   mCommandChain.Clear();
-   mParamsChain.Clear();
+   if (before == -1) {
+      before = (int)mCommandChain.GetCount();
+   }
+
+   mCommandChain.Insert(command, before);
+   mParamsChain.Insert(params, before);
 }
 
-// TODO: Add warnings for non-useful batch chains.
-// e.g. every batch chain should have an import and 
-// and an export.
-wxString BatchCommands::GetChainWarnings()
+void BatchCommands::DeleteFromChain(int index)
 {
-   if( mCommandChain.GetCount() == 0)
-   {
-      return _("No batch command chain defined.");
+   if (index < 0 || index >= (int)mCommandChain.GetCount()) {
+      return;
    }
-   return wxT("");
+
+   mCommandChain.RemoveAt(index);
+   mParamsChain.RemoveAt(index);
 }
 
+void BatchCommands::ResetChain()
+{
+   mCommandChain.Clear();
+   mParamsChain.Clear();
+}
 
 // ReportAndSkip() is a diagnostic function that avoids actually
 // applying the requested effect if in batch-debug mode.
@@ -674,258 +664,43 @@
    return true;
 }
 
-void BatchCommands::ReadChains()
+wxArrayString BatchCommands::GetNames()
 {
-   wxString groupName;
-   long groupNdx;
-
-   mCommandChains.empty();
-   RestoreChain(wxT("CleanSpeech"));
-   RestoreChain(wxT("MP3 Conversion"));
-
-   wxString oldPath = gPrefs->GetPath();
-
-   gPrefs->SetPath(wxT("/Batch/Chains"));
-
-   if (gPrefs->GetFirstGroup(groupName, groupNdx)) {
-      do {
-         gPrefs->SetPath(groupName);
-
-         wxArrayString chain;
-         wxString entryName;
-         long entryNdx;
-         if (gPrefs->GetFirstEntry(entryName, entryNdx)) {
-            do {
-               wxString cmd = gPrefs->Read(entryName, wxT(""));
-               if (cmd.Length()) {
-                  chain.Add(cmd);
-               }
-            } while (gPrefs->GetNextEntry(entryName, entryNdx));
-         }
-         mCommandChains[groupName] = chain;
+   wxArrayString names;
+   wxArrayString files;
+   wxDir::GetAllFiles(FileNames::ChainDir(), &files, wxT("*.txt"), 
wxDIR_FILES);
+   size_t i;
 
-         gPrefs->SetPath(wxT(".."));
-      } while (gPrefs->GetNextGroup(groupName, groupNdx));
+   for (i = 0; i < files.GetCount(); i++) {
+      wxFileName f(files[i]);
+      names.Add(f.GetName());
    }
 
-   gPrefs->SetPath(oldPath);
-}
-
-void BatchCommands::WriteChains()
-{
-   wxString groupName;
-
-   wxString oldPath = gPrefs->GetPath();
-
-   gPrefs->DeleteGroup(wxT("/Batch/Chains"));
-   gPrefs->SetPath(wxT("/Batch/Chains"));
-
-   CommandChains::iterator it;
-   for (it = mCommandChains.begin(); it != mCommandChains.end(); it++)
-   {
-      wxString groupName = it->first;
-      wxArrayString chain = it->second;
-
-      gPrefs->SetPath(groupName);
-
-      for (int i = 0; i < chain.GetCount(); i++) {
-         gPrefs->Write(wxString::Format(wxT("%d"), i), chain[i]);
-      }
-
-      gPrefs->SetPath(wxT(".."));
-   } 
-
-   gPrefs->SetPath(oldPath);
-}
-
-void BatchCommands::FlushChains()
-{
-   mCommandChains.clear();
-}
-
-wxArrayString * BatchCommands::GetChain(const wxString & name)
-{
-   return &mCommandChains[name];
-}
-
-wxArrayString * BatchCommands::RenameChain(const wxString & oldname, const 
wxString & newname)
-{
-   wxArrayString chain = *(GetChain(oldname));
-   mCommandChains.erase(oldname);
-   mCommandChains[newname] = chain;
-
-   return GetChain(newname);
-}
-
-void BatchCommands::DeleteChain(const wxString & name)
-{
-   mCommandChains.erase(name);
+   return names;
 }
 
 bool BatchCommands::IsFixed(const wxString & name)
 {
-   if (name == wxT("CleanSpeech") || name == wxT("MP3 Conversion")) {
+   if (name == CleanSpeech || name == MP3Conversion) {
       return true;
    }
 
    return false;
 }
 
-int BatchCommands::GetChainCount()
-{
-   return (int) mCommandChains.size();
-}
-
-wxArrayString BatchCommands::GetChainNames()
-{
-   wxArrayString names;
-
-   CommandChains::iterator it;
-   for (it = mCommandChains.begin(); it != mCommandChains.end(); it++)
-   {
-      names.Add(it->first);
-   } 
-
-   return names;
-}
-
-
-wxArrayString * BatchCommands::RestoreChain(const wxString & name)
+void BatchCommands::RestoreChain(const wxString & name)
 {
-
 // TIDY-ME: Effects change their name with localisation.
 // Commands (at least currently) don't.  Messy.
 
 /* i18n-hint: Effect name translations must agree with those used elsewhere, 
or batch won't find them */
 
-   wxArrayString *chain = GetChain(name);
-   chain->Empty();
-
-   if (name == wxT("CleanSpeech")) {
-      chain->Add(Defaults(wxT("Import")));
-      chain->Add(Defaults(  _("Stereo To Mono")));
-      chain->Add(Defaults(  _("Normalize")));
-      chain->Add(Defaults(wxT("Save Hq Master1")));
-      chain->Add(Defaults(  _("Noise Removal")));
-      chain->Add(Defaults(  _("Truncate Silence")));
-      chain->Add(Defaults(  _("Leveller")));
-      chain->Add(Defaults(  _("Normalize")));
-      chain->Add(Defaults(wxT("ExportMp3")));
-   }
-   else if (name == wxT("MP3 Conversion")) {
-      chain->Add(Defaults(wxT("Import")));
-      chain->Add(Defaults(  _("Normalize")));
-      chain->Add(Defaults(wxT("ExportMp3")));
-   }
-
-   return chain;
-}
-
-void BatchCommands::ImportChain( wxWindow *parent, const wxString & name )
-{
-   // Get the initial path
-   wxString pName = gPrefs->Read( wxT("/Batch/DefaultChainPath"),
-                                  ::wxGetCwd() );
-
-   // Prompt user for a file name
-   wxString fName = wxFileSelector( _("Select a command chain file..."),
-                                    pName,                     // Path
-                                    name + wxT(".txt"),        // Name
-                                    wxT("txt"),                // Extension
-                                    _("Text files (*.txt)|*.txt|All files 
(*.*)|*.*"),
-                                    0,                         // Flags
-                                    parent);                   // Parent
-
-   // Nothing to do
-   if( !fName )
-      return;
-
-   // Remember path
-   gPrefs->Write( wxT("/Batch/DefaultChainPath"), wxPathOnly( fName ) );
-
-   // Set the file name
-   wxTextFile tf( fName );
-
-   // Open and check
-   tf.Open();
-   if( !tf.IsOpened() )
-   {
-      // wxTextFile will display any errors
-      return;
-   }
-
-   // Clear any previous chain
-   wxArrayString *chain = GetChain( name );
-   chain->Clear();
-
-   // Load commands from the file
-   int i;
-   int lines = tf.GetLineCount();
-   for( i = 0; i < lines; i++ )
-   {
-      chain->Add( tf[ i ] );
-   }
-
-   // Done with the file
-   tf.Close();
-}
-
-void BatchCommands::ExportChain( wxWindow *parent, const wxString & name )
-{
-   // Get the initial path
-   wxString pName = gPrefs->Read( wxT("/DefaultChainPath"),
-                                  ::wxGetCwd() );
-
-   // Prompt user for a file name
-   wxString fName = wxFileSelector( _("Save command chain As:"),
-                                    pName,                        // Path
-                                    name + wxT(".txt"),           // Name
-                                    wxT("txt"),                   // Extension
-                                    _("Text files (*.txt)|*.txt|All files 
(*.*)|*.*"),
-                                    wxSAVE | wxOVERWRITE_PROMPT,  // Flags
-                                    parent );                     // Parent
-
-   // Nothing to do
-   if( !fName )
-      return;
-
-   // Remember path
-   gPrefs->Write( wxT("/DefaultChainPath"), wxPathOnly( fName ) );
-
-   // Set the file name
-   wxTextFile tf( fName );
-
-   // (Possibly) create new file
-   if( !tf.Exists() )
-   {
-      tf.Create();
-   }
-
-   // Open and check
-   tf.Open();
-   if( !tf.IsOpened() )
-   {
-      // wxTextFile will display any errors
-      return;
+   if (name == CleanSpeech) {
+      SetCleanSpeechChain();
    }
-
-   // Start with a clean slate
-   tf.Clear();
-
-   // Copy over the commands
-   wxArrayString *chain = GetChain( name );
-   int i;
-   int lines = chain->GetCount();
-   for( i = 0; i < lines; i++ )
-   {
-      tf.AddLine( (*chain)[i] );
+   else if (name == MP3Conversion) {
+      SetWavToMp3Chain();
    }
-
-   // Write the chain
-   tf.Write();
-
-   // Done with the file
-   tf.Close();
 }
 
 void BatchCommands::Split(const wxString & str, wxString & command, wxString & 
param)
@@ -956,11 +731,6 @@
    return command + wxT(": ") + param;
 }
 
-wxString BatchCommands::Defaults(const wxString & command)
-{
-   return Join(command, GetCurrentParamsFor(command));
-}
-
 // Indentation settings for Vim and Emacs and unique identifier for Arch, a
 // version control system. Please do not modify past this point.
 //

Index: Menus.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Menus.cpp,v
retrieving revision 1.282
retrieving revision 1.283
diff -u -d -r1.282 -r1.283
--- Menus.cpp   29 Sep 2006 05:50:21 -0000      1.282
+++ Menus.cpp   1 Oct 2006 07:23:49 -0000       1.283
@@ -208,11 +208,11 @@
       c->AddItem(wxT("SaveAs"),         _("Save Project &As..."),            
FN(OnSaveAs));
    }
 
-   c->AddItem(wxT("CheckDeps"),      _("Check Dependencies..."),          
FN(OnCheckDependencies));
+   c->AddItem(wxT("CheckDeps"),      _("Chec&k Dependencies..."),          
FN(OnCheckDependencies));
 
    c->AddSeparator();
 
-   c->AddItem(wxT("EditID3"),        _("Open &Metadata Editor"),              
FN(OnEditID3));
+   c->AddItem(wxT("EditID3"),        _("Open Me&tadata Editor"),              
FN(OnEditID3));
    //c->SetCommandFlags(wxT("EditID3"), AudioIONotBusyFlag, 
AudioIONotBusyFlag);
 
    if( !mCleanSpeechMode )
@@ -312,7 +312,8 @@
       
       c->AddSeparator();
 
-      c->AddItem(wxT("BatchProcess"),     _("CleanSpeech C&hain..."),   
FN(OnBatch));
+      c->AddItem(wxT("ApplyChain"), _("CleanSpeech C&hain..."),   
FN(OnApplyChain));
+      c->AddItem(wxT("EditChains"), _("Edit C&hains..."), FN(OnEditChains));
       c->AddItem(wxT("ExportCcSettings"), _("Export CleanSpeech &Presets..."), 
  FN(OnExportCleanSpeechPresets));
       c->AddItem(wxT("ImportCcSettings"), _("I&mport CleanSpeech Presets..."), 
  FN(OnImportCleanSpeechPresets));
       c->SetCommandFlags(wxT("BatchProcess"), AudioIONotBusyFlag, 
AudioIONotBusyFlag);
@@ -324,9 +325,9 @@
        }
    else
    {
-      c->AddItem(wxT("BatchProcess"),     _("Process &Batch..."),   
FN(OnBatch));
+      c->AddItem(wxT("AppplyChain"), _("Appl&y Chain..."), FN(OnApplyChain));
       c->SetCommandFlags(wxT("BatchProcess"), AudioIONotBusyFlag, 
AudioIONotBusyFlag);
-      c->AddItem(wxT("EditChains"),       _("Edit Chains..."),   
FN(OnEditChains));
+      c->AddItem(wxT("EditChains"), _("Edit C&hains..."), FN(OnEditChains));
    }
 
    c->AddSeparator();
@@ -4153,7 +4154,7 @@
    } while(!fileOkay);
 }
 
-void AudacityProject::OnBatch()
+void AudacityProject::OnApplyChain()
 {
    BatchProcessDialog d(this);
    d.ShowModal();
@@ -4163,17 +4164,6 @@
 {
    EditChainsDialog d(this);
    d.ShowModal();
-#if 0
-   wxDialog d(this, wxID_ANY, _("Edit Chains"), wxDefaultPosition, wxSize(500, 
500));
-   wxBoxSizer *s = new wxBoxSizer(wxVERTICAL);
-   BatchPrefs *b = new BatchPrefs(&d);
-   s->Add(b);
-   s->Add(d.CreateButtonSizer(wxOK | wxCANCEL));
-   d.SetSizerAndFit(s);
-   d.Layout();
-   d.ShowModal();
-   b->Destroy();
-#endif
 }
 
 wxString AudacityProject::BuildCleanFileName(wxString fileName)

Index: UndoManager.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/UndoManager.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- UndoManager.cpp     29 Jun 2006 09:35:25 -0000      1.19
+++ UndoManager.cpp     1 Oct 2006 07:23:49 -0000       1.20
@@ -25,6 +25,7 @@
 #include <wx/textctrl.h>
 #include <wx/log.h>
 
+#include "Internat.h"
 #include "UndoManager.h"
 #include "Track.h"
 
@@ -49,15 +50,17 @@
    n -= 1; // 1 based to zero based
 
    wxASSERT(n < stack.Count());
+   double bytes;
 
    *desc = stack[n]->description;
 
    if (n == 0)
-      size->Printf(wxT("%d MB"), stack[n]->tracks->GetSpaceUsage() / 1048576);
+      bytes = stack[n]->tracks->GetSpaceUsage();
    else {
-      int bytes = stack[n]->tracks->GetAdditionalSpaceUsage(&stack);
-      size->Printf(wxT("%d MB"), bytes / 1048576);
+      bytes = stack[n]->tracks->GetAdditionalSpaceUsage(&stack);
    }
+
+   *size = Internat::FormatSize(bytes);
 }
 
 void UndoManager::GetShortDescription(unsigned int n, wxString *desc)

Index: Menus.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/Menus.h,v
retrieving revision 1.90
retrieving revision 1.91
diff -u -d -r1.90 -r1.91
--- Menus.h     29 Sep 2006 05:50:21 -0000      1.90
+++ Menus.h     1 Oct 2006 07:23:49 -0000       1.91
@@ -263,7 +263,7 @@
 
         //lda CleanSpeech Menu
 
-void OnBatch();
+void OnApplyChain();
 void OnEditChains();
 void OnImportCleanSpeechPresets();
 void OnExportCleanSpeechPresets();

Index: BatchProcessDialog.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/BatchProcessDialog.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- BatchProcessDialog.h        29 Sep 2006 05:50:21 -0000      1.3
+++ BatchProcessDialog.h        1 Oct 2006 07:23:49 -0000       1.4
@@ -70,36 +70,42 @@
 
 private:
    void Populate();
-   void PopulateOrExchange( ShuttleGui & S );
+   void PopulateOrExchange(ShuttleGui &S);
    void PopulateChains();
        void PopulateList();
-   void AddItem( wxString const & Action, wxString const & Params);
-       void SetItem( int ItemNo, const wxString command, const wxString params 
);
+   void AddItem(const wxString &command, wxString const &params);
+   bool ChangeOK();
 
-   void OnOK(wxCommandEvent &event);
-   void OnCancel(wxCommandEvent &event);
+   void OnChainSelected(wxListEvent &event);
+   void OnChainsBeginEdit(wxListEvent &event);
+   void OnChainsEndEdit(wxListEvent &event);
    void OnAdd(wxCommandEvent &event);
    void OnRemove(wxCommandEvent &event);
    void OnRename(wxCommandEvent &event);
+
+   void OnCommandActivated(wxListEvent &event);
+   void OnInsert(wxCommandEvent &event);
+   void OnDelete(wxCommandEvent &event);
    void OnUp(wxCommandEvent &event);
    void OnDown(wxCommandEvent &event);
-   void OnImport(wxCommandEvent &event);
-   void OnExport(wxCommandEvent &event);
    void OnDefaults(wxCommandEvent &event);
-   void OnChainSelected(wxListEvent &event);
-   void OnChainsBeginEdit(wxListEvent &event);
-   void OnChainsEndEdit(wxListEvent &event);
-   void OnItemSelected(wxListEvent &event);
 
-   wxListCtrl * mChains; /// List of chains.
-   wxListCtrl * mList;   /// List of commands in current command chain.
-   wxButton * mRemove;
-   wxButton * mRename;
-   wxButton * mDefaults;
+   void OnOK(wxCommandEvent &event);
+   void OnCancel(wxCommandEvent &event);
+
+   void OnKeyDown(wxKeyEvent &event);
+
+   wxListCtrl *mChains; /// List of chains.
+   wxListCtrl *mList;   /// List of commands in current command chain.
+   wxButton *mRemove;
+   wxButton *mRename;
+   wxButton *mDefaults;
 
    BatchCommands mBatchCommands;  /// Provides list of available commands.
    wxString mActiveChain;
-   wxArrayString *mChain;
+
+   int mSelectedCommand;
+   bool mChanged;
 
    DECLARE_EVENT_TABLE();
 };

Index: BatchCommandDialog.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/BatchCommandDialog.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- BatchCommandDialog.h        20 Jun 2005 20:14:39 -0000      1.2
+++ BatchCommandDialog.h        1 Oct 2006 07:23:49 -0000       1.3
@@ -34,26 +34,29 @@
 class wxListCtrl;
 class wxListEvent;
 class wxButton;
+class ShuttleGui;
 
 class BatchCommandDialog:public wxDialog {
  public:
    // constructors and destructors
-   BatchCommandDialog(wxWindow * parent, wxWindowID id);
+   BatchCommandDialog(wxWindow *parent, wxWindowID id);
+       void SetCommandAndParams(const wxString &Command, const wxString 
&Params);
  public:
-       void SetCommandAndParams( const wxString &Command, const wxString & 
Params);
+   wxString   mSelectedCommand;
+   wxString   mSelectedParameters;
+ private:
+   void Populate();
+   void PopulateOrExchange(ShuttleGui &S);
        void OnEditParams(wxCommandEvent &event);
-   void OnChoice(wxCommandEvent & event);
-   void OnOk(wxCommandEvent & event);
-   void OnCancel(wxCommandEvent & event);
+   void OnChoice(wxCommandEvent &event);
+   void OnOk(wxCommandEvent &event);
+   void OnCancel(wxCommandEvent &event);
    void OnItemSelected(wxListEvent &event);
 
    void ValidateChoices();
    void PopulateCommandList();
    int GetSelectedItem();
 
-   wxString   mSelectedCommand;
-   wxString   mSelectedParameters;
-   wxButton   *mOK;
    wxButton   *mEditParams;
    wxListCtrl *mChoices;
    wxTextCtrl * mCommand;


-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys -- and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Audacity-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/audacity-cvs

Reply via email to