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

Modified Files:
        BatchPrefs.cpp BatchPrefs.h PrefsPanel.h PrefsDialog.cpp 
Log Message:
Committing rough chain processing to allow other to review.  

Index: PrefsDialog.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/prefs/PrefsDialog.cpp,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- PrefsDialog.cpp     7 Jul 2006 11:56:02 -0000       1.37
+++ PrefsDialog.cpp     29 Sep 2006 05:50:07 -0000      1.38
@@ -220,6 +220,12 @@
 
 void PrefsDialog::OnCancel(wxCommandEvent & event)
 {
+   int i;
+
+   for (i = 0; i < (int)mCategories->GetPageCount(); i++) {
+      ((PrefsPanel *) mCategories->GetPage(i))->Cancel();
+   }
+
    EndModal(0);
 }
 

Index: BatchPrefs.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/prefs/BatchPrefs.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- BatchPrefs.h        6 Jun 2006 11:40:44 -0000       1.4
+++ BatchPrefs.h        29 Sep 2006 05:50:07 -0000      1.5
@@ -29,26 +29,39 @@
    BatchPrefs(wxWindow * parent);
    ~BatchPrefs();
    virtual bool Apply();
+   virtual void Cancel();
 
 private:
    void Populate();
    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 PopulateList();
-   void CreateList();
 
+   void OnAdd(wxCommandEvent &event);
+   void OnRemove(wxCommandEvent &event);
+   void OnRename(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);
-   void OnDrag(wxListEvent &event);
-   void OnDragEnd(wxListEvent &event);
-   void OnSetChainMp3(wxCommandEvent &event);
-   void OnSetChainCleanSpeech(wxCommandEvent &event);
-   void OnSetChainEmpty(wxCommandEvent &event);
-   void OnLoad(wxCommandEvent &event);
-   void OnSave(wxCommandEvent &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;
+
    DECLARE_EVENT_TABLE();
 };
 

Index: PrefsPanel.h
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/prefs/PrefsPanel.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- PrefsPanel.h        19 Jun 2006 13:13:58 -0000      1.7
+++ PrefsPanel.h        29 Sep 2006 05:50:07 -0000      1.8
@@ -56,6 +56,7 @@
    
    virtual ~ PrefsPanel() {}
    virtual bool Apply() = 0;
+   virtual void Cancel() {};
 protected:
    wxBoxSizer *topSizer;
    wxBoxSizer *outSizer;

Index: BatchPrefs.cpp
===================================================================
RCS file: /cvsroot/audacity/audacity-src/src/prefs/BatchPrefs.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- BatchPrefs.cpp      6 Jul 2006 12:56:47 -0000       1.14
+++ BatchPrefs.cpp      29 Sep 2006 05:50:06 -0000      1.15
@@ -18,6 +18,7 @@
 
 #include <wx/defs.h>
 #include <wx/intl.h>
+#include <wx/textdlg.h>
 
 #include "BatchPrefs.h"
 #include "../Envelope.h"
@@ -27,25 +28,31 @@
 #include "../BatchCommandDialog.h"
 #include "../ShuttleGui.h"
 
-#define CommandsListID          7005
-#define SaveButtonID            7006
-#define LoadButtonID            7007
-#define CleanSpeechButtonID     7008
-#define Mp3ButtonID             7009
-#define EmptyChainButtonID      7010
+#define ChainsListID             7005
+#define AddButtonID              7006
+#define RemoveButtonID           7007
+#define CommandsListID           7008
+#define ImportButtonID           7009
+#define ExportButtonID           7010
+#define DefaultsButtonID         7011
+#define UpButtonID               7012
+#define DownButtonID             7013
+#define RenameButtonID           7014
 
 BEGIN_EVENT_TABLE(BatchPrefs, wxPanel)
-   EVT_BUTTON(SaveButtonID, BatchPrefs::OnSave)
-   EVT_BUTTON(LoadButtonID, BatchPrefs::OnLoad)
-   EVT_BUTTON(CleanSpeechButtonID, BatchPrefs::OnSetChainCleanSpeech)
-   EVT_BUTTON(Mp3ButtonID,         BatchPrefs::OnSetChainMp3)
-   EVT_BUTTON(EmptyChainButtonID,  BatchPrefs::OnSetChainEmpty)
+   EVT_BUTTON(AddButtonID, BatchPrefs::OnAdd)
+   EVT_BUTTON(RemoveButtonID, BatchPrefs::OnRemove)
+   EVT_BUTTON(RenameButtonID, BatchPrefs::OnRename)
+   EVT_BUTTON(UpButtonID, BatchPrefs::OnUp)
+   EVT_BUTTON(DownButtonID, BatchPrefs::OnDown)
+   EVT_BUTTON(ImportButtonID, BatchPrefs::OnImport)
+   EVT_BUTTON(ExportButtonID, BatchPrefs::OnExport)
+   EVT_BUTTON(DefaultsButtonID, BatchPrefs::OnDefaults)
+   EVT_LIST_ITEM_SELECTED(ChainsListID, BatchPrefs::OnChainSelected)
+   EVT_LIST_BEGIN_LABEL_EDIT(ChainsListID, BatchPrefs::OnChainsBeginEdit)
+   EVT_LIST_END_LABEL_EDIT(ChainsListID, BatchPrefs::OnChainsEndEdit)
    EVT_LIST_ITEM_ACTIVATED(CommandsListID, BatchPrefs::OnItemSelected)
 
-// Is someone working on drag and drop????
-   EVT_LIST_BEGIN_DRAG(CommandsListID, BatchPrefs::OnDrag)  // The user has 
started dragging an item with the left mouse button. The event handler must 
call wxTreeEvent::Allow() for the drag operation to continue.  
-// EVT_TREE_BEGIN_RDRAG(id, func)  // The user has started dragging an item 
with the right mouse button. The event handler must call wxTreeEvent::Allow() 
for the drag operation to continue.  
-// EVT_LIST_END_DRAG(CommandsListID, BatchPrefs::OnDragEnd)   // The user has 
released the mouse after dragging an item.  
 END_EVENT_TABLE()
 
 enum { BlankColumn,   
@@ -54,6 +61,10 @@
    ParamsColumn,
 };
 
+enum { CleanSpeechID,
+   MP3ConversionID,
+};
+
 /// Constructor
 BatchPrefs::BatchPrefs(wxWindow * parent):
    PrefsPanel(parent)
@@ -67,6 +78,7 @@
 void BatchPrefs::Populate( )
 {
    // First any pre-processing for constructing the GUI.
+   mBatchCommands.ReadChains();
 
    //------------------------- Main section --------------------
    // Now construct the GUI itself.
@@ -75,8 +87,36 @@
    ShuttleGui S(this, eIsCreatingFromPrefs);
    PopulateOrExchange(S);
    // ----------------------- End of main section --------------
+
+   // Set the column size for the chains list.
+   PopulateChains();
+
+   // Set the column size for the chains list.
+   wxSize sz = mChains->GetClientSize();
+   mChains->SetColumnWidth(0, sz.x);
+
+   // Get and validate the currently active chain
+   mActiveChain = gPrefs->Read(wxT("/Batch/ActiveChain"), wxT("CleanSpeech"));
+   int item = mChains->FindItem(-1, mActiveChain);
+   if (mChains->FindItem(-1, mActiveChain) == -1) {
+      item = 0;
+      mActiveChain = mChains->GetItemText(0);
+   }
+
+   // Load it
+   mChain = mBatchCommands.GetChain(mActiveChain);
+
+   // Select the name in the list...this will fire an event.
+   mChains->SetItemState(item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+
    // We have a bare list.  We need to add columns and content.
-   CreateList();
+   PopulateList();
+
+   // Size columns properly
+   mList->SetColumnWidth( BlankColumn,  0 ); // First column width is zero, to 
hide it.
+   mList->SetColumnWidth( ItemNumberColumn,  wxLIST_AUTOSIZE );
+   mList->SetColumnWidth( ActionColumn, 110 );
+   mList->SetColumnWidth( ParamsColumn, 220 );
 }
 
 /// Defines the dialog and does data exchange with it.
@@ -100,11 +140,10 @@
    {
       S.TieCheckBox( _("S&how MP3-ID3 Dialog"), 
          wxT("/Batch/ShowId3Dialog"), false);
-//    S.TieCheckBox( _("Show Confirmation for 'delete orphans'"), 
-//       wxT("/Batch/ShowDeleteConfirmation"), true);
    }
    S.EndStatic();
    S.EndHorizontalLay();
+
    S.StartHorizontalLay( wxEXPAND, 1 );
    S.StartStatic( _("Batch Options"));
    {
@@ -122,123 +161,312 @@
       S.AddFixedText( 
          _("Batch mode is an\n\
 experimental feature.\n\n\
-Please read the release\nnotes for known limitations"));
-      S.Id( CleanSpeechButtonID ).AddButton( _("&CleanSpeech chain") );
-      S.Id( Mp3ButtonID ).AddButton( _("&MP3 conversion chain") );
-      S.Id( EmptyChainButtonID ).AddButton( _("&Empty chain") );
-      S.Id( LoadButtonID ).AddButton( _("&Load chain") );
-      S.Id( SaveButtonID ).AddButton( _("&Save chain") );
+Please read the release\nnotes for known limitations\n\n"));
+
+      S.SetStyle( wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | 
wxLC_SINGLE_SEL |
+                  wxLC_EDIT_LABELS );
+      mChains = S.Id( ChainsListID ).AddListControlReportMode();
+      mChains->InsertColumn( 0, wxT("Chain"), wxLIST_FORMAT_LEFT );
+      S.StartHorizontalLay( wxEXPAND, 0 );
+      {
+         S.Id( AddButtonID ).AddButton( _("&Add") );
+         mRemove = S.Id( RemoveButtonID ).AddButton( _("&Remove") );
+         mRename = S.Id( RenameButtonID ).AddButton( _("Rena&me") );
+      }
+      S.EndHorizontalLay();
    }
    S.EndStatic();
    S.StartStatic( _("Batch Sequence (Double-Click or press SPACE to edit)"),1);
    {
+      S.SetStyle( wxSUNKEN_BORDER | wxLC_REPORT | wxLC_HRULES | wxLC_VRULES |
+                  wxLC_SINGLE_SEL );
       mList = S.Id( CommandsListID ).AddListControlReportMode();
+
+      //An empty first column is a workaround - under Win98 the first column 
+      //can't be right aligned.
+      mList->InsertColumn(BlankColumn,   wxT(""),         wxLIST_FORMAT_LEFT );
+      mList->InsertColumn(ItemNumberColumn,    _("No"),   wxLIST_FORMAT_RIGHT 
);
+      mList->InsertColumn(ActionColumn,  _("Command"),    wxLIST_FORMAT_RIGHT 
);
+      mList->InsertColumn(ParamsColumn,  _("Parameters"), wxLIST_FORMAT_LEFT );
+
+      S.StartHorizontalLay(wxEXPAND, 0);
+      {
+         S.Id( UpButtonID ).AddButton( _("Move &Up"), wxALIGN_LEFT );
+         S.Id( DownButtonID ).AddButton( _("Move &Down"), wxALIGN_LEFT );
+         mDefaults = S.Id( DefaultsButtonID ).AddButton( _("De&faults") );
+         S.Id( ImportButtonID ).AddButton( _("&Import"), wxALIGN_LEFT );
+         S.Id( ExportButtonID ).AddButton( _("E&xport"), wxALIGN_LEFT );
+      }
+      S.EndHorizontalLay();
    }
    S.EndStatic();
    S.EndHorizontalLay();
    return;
 }
 
-/// Sets up mList with the right number of columns, titles,
-/// fills the contents and sets column widths.
-void BatchPrefs::CreateList()
+/// This clears and updates the contents of mChains
+void BatchPrefs::PopulateChains()
 {
-   wxASSERT( mList );
-
-   //An empty first column is a workaround - under Win98 the first column 
-   //can't be right aligned.
-   mList->InsertColumn(BlankColumn,   wxT(""),         wxLIST_FORMAT_LEFT );
-   mList->InsertColumn(ItemNumberColumn,    _("No"),   wxLIST_FORMAT_RIGHT );
-   mList->InsertColumn(ActionColumn,  _("Command"),    wxLIST_FORMAT_RIGHT );
-   mList->InsertColumn(ParamsColumn,  _("Parameters"), wxLIST_FORMAT_LEFT );
-
-   wxASSERT( mList );
-   mBatchCommands.ReadChain();
-   PopulateList();
+   wxArrayString names = mBatchCommands.GetChainNames();
+   int i;
 
-   mList->SetColumnWidth( BlankColumn,  0 ); // First column width is zero, to 
hide it.
-   mList->SetColumnWidth( ItemNumberColumn,  wxLIST_AUTOSIZE );
-   mList->SetColumnWidth( ActionColumn, 110 );
-   mList->SetColumnWidth( ParamsColumn, 220 );
-}
+   mChains->DeleteAllItems();
+   for (i = 0; i < names.GetCount(); i++)
+   {
+      mChains->InsertItem(i, names[i]);
+   }
 
-/// Add one item into mList
-void BatchPrefs::AddItem( wxString const & Action, wxString const & Params)
-{
-   int i=mList->GetItemCount();
-   mList->InsertItem( i, wxT("") );
-   mList->SetItem( i, ItemNumberColumn, wxString::Format(wxT(" %02i"),i+1) );
-   mList->SetItem( i, ActionColumn, Action );
-   mList->SetItem( i, ParamsColumn, Params );
+   mChains->Refresh(false);
 }
 
 /// This clears and updates the contents of mList
 void BatchPrefs::PopulateList()
 {
-   unsigned int i;
    wxString command;
    wxString params;
-   wxASSERT( mList );
+   int i;
+
    mList->DeleteAllItems();
-   for(i=0;i<mBatchCommands.mCommandChain.GetCount();i++)
-   {
-      command =mBatchCommands.mCommandChain[i]; 
-      params  =mBatchCommands.mParamsChain[i];
+
+   for (i = 0; i < mChain->GetCount(); i++) {
+      mBatchCommands.Split( (*mChain)[i], command, params );
       AddItem( command, params );
    }
+
    AddItem( _("- END -"), wxT(""));
    mList->Refresh(false);
 }
 
-/// Select the MP3 Command chain.
-void BatchPrefs::OnSetChainMp3(wxCommandEvent &event)
+/// 
+void BatchPrefs::OnAdd(wxCommandEvent &event)
 {
-   mBatchCommands.SetWavToMp3Chain();
-   PopulateList();
+   while (true) {
+      wxTextEntryDialog d(this,
+                          _("Enter name of new chain"),
+                          _("Batch Chain"));
+      wxString name;
+
+      if (d.ShowModal() == wxID_CANCEL) {
+         return;
+      }
+
+      name = d.GetValue().Strip(wxString::both);
+
+      if (name.Length() == 0) {
+         wxMessageBox(_("Name must not be blank"),
+                      _("Batch Chain"),
+                      wxOK | wxICON_ERROR,
+                      this);
+         continue;
+      }
+
+      if (name.Contains(wxT("[")) ||
+          name.Contains(wxT("]")) ||
+          name.Contains(wxCONFIG_PATH_SEPARATOR)) {
+         wxMessageBox(wxString::Format(_("Names may not contain brackets and 
'%c'"), wxCONFIG_PATH_SEPARATOR),
+                      _("Batch Chain"),
+                      wxOK | wxICON_ERROR,
+                      this);
+         continue;
+      }
+
+      if (mChains->FindItem(-1, name) != -1) {
+         wxMessageBox(_("Chain already exists"),
+                      _("Batch Chain"),
+                      wxOK | wxICON_ERROR,
+                      this);
+         continue;
+      }
+
+      mBatchCommands.GetChain(name);
+      
+      long item = mChains->InsertItem(mChains->GetItemCount(), name);
+      mChains->SetItemState(item, wxLIST_STATE_SELECTED, 
wxLIST_STATE_SELECTED);
+
+      break;
+   }
 }
 
-/// Select the CleanSpeech Command chain.
-void BatchPrefs::OnSetChainCleanSpeech(wxCommandEvent &event)
+///
+void BatchPrefs::OnRemove(wxCommandEvent &event)
 {
-   mBatchCommands.SetCleanSpeechChain();
-   PopulateList();
+   long item = mChains->GetNextItem(-1,
+                                    wxLIST_NEXT_ALL,
+                                    wxLIST_STATE_SELECTED);
+   if (item == -1) {
+      return;
+   }
+
+   wxString name = mChains->GetItemText(item);
+   wxMessageDialog m(this,
+                     wxString::Format(_("Are you sure you want to delete 
%s?"), name.c_str()),
+                     _("Batch Chain"),
+                     wxYES_NO | wxICON_QUESTION);
+   if (m.ShowModal() == wxID_NO) {
+      return;
+   }
 }
 
-/// Select the empty Command chain.
-void BatchPrefs::OnSetChainEmpty(wxCommandEvent &event)
+///
+void BatchPrefs::OnRename(wxCommandEvent &event)
 {
-   mBatchCommands.ResetChain();
-   PopulateList();
+   long item = mChains->GetNextItem(-1,
+                                    wxLIST_NEXT_ALL,
+                                    wxLIST_STATE_SELECTED);
+   if (item == -1) {
+      return;
+   }
+
+   mChains->EditLabel(item);
+}
+
+///
+void BatchPrefs::OnUp(wxCommandEvent &event)
+{
+   long item = mList->GetNextItem(-1,
+                                  wxLIST_NEXT_ALL,
+                                  wxLIST_STATE_SELECTED);
+   if (item == -1 || item == 0 || item + 1 == mList->GetItemCount()) {
+      return;
+   }
+
+   wxString commandP, paramsP, commandC, paramsC;
+   wxListItem info;
+
+   info.SetMask(wxLIST_MASK_TEXT);
+   info.SetId(item - 1);
+
+   info.SetColumn(ActionColumn);
+   mList->GetItem(info);
+   commandP = info.GetText();
+
+   info.SetColumn(ParamsColumn);
+   mList->GetItem(info);
+   paramsP = info.GetText();
+
+   info.SetId(item);
+
+   info.SetColumn(ActionColumn);
+   mList->GetItem(info);
+   commandC = info.GetText();
+
+   info.SetColumn(ParamsColumn);
+   mList->GetItem(info);
+   paramsC = info.GetText();
+
+   SetItem(item - 1, commandC, paramsC);
+   SetItem(item, commandP, paramsP);
+
+   mList->SetItemState(item - 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
+}
+
+///
+void BatchPrefs::OnDown(wxCommandEvent &event)
+{
+   long item = mList->GetNextItem(-1,
+                                  wxLIST_NEXT_ALL,
+                                  wxLIST_STATE_SELECTED);
+   if (item == -1 || item + 2 >= mList->GetItemCount()) {
+      return;
+   }
+
+   wxString commandN, paramsN, commandC, paramsC;
+   wxListItem info;
+
+   info.SetMask(wxLIST_MASK_TEXT);
+   info.SetId(item + 1);
+
+   info.SetColumn(ActionColumn);
+   mList->GetItem(info);
+   commandN = info.GetText();
+
+   info.SetColumn(ParamsColumn);
+   mList->GetItem(info);
+   paramsN = info.GetText();
+
+   info.SetId(item);
+
+   info.SetColumn(ActionColumn);
+   mList->GetItem(info);
+   commandC = info.GetText();
+
+   info.SetColumn(ParamsColumn);
+   mList->GetItem(info);
+   paramsC = info.GetText();
+
+   SetItem(item, commandN, paramsN);
+   SetItem(item + 1, commandC, paramsC);
+
+   mList->SetItemState(item + 1, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
 }
 
 /// Loads a command chain from a file.
-void BatchPrefs::OnLoad(wxCommandEvent &event)
+void BatchPrefs::OnImport(wxCommandEvent &event)
 {
-   mBatchCommands.LoadChain( this );
+   mBatchCommands.ImportChain(this, mActiveChain);
    PopulateList();
 }
 
 /// Saves the current command chain to a file.
-void BatchPrefs::OnSave(wxCommandEvent &event)
+void BatchPrefs::OnExport(wxCommandEvent &event)
 {
-   mBatchCommands.SaveChain( this );
+   mBatchCommands.ExportChain(this, mActiveChain);
    PopulateList();
 }
 
-/// JKC: This looks like the start of some code for dragging command chains
-/// into the list box...  Is anyone working on it? (June/2006)
-void BatchPrefs::OnDrag(wxListEvent &event)
+/// Select the empty Command chain.
+void BatchPrefs::OnDefaults(wxCommandEvent &event)
 {
-   event.Allow();
-//   wxLogDebug( "From %i", event.GetItem() );
-//   mDragStart = event.GetItem();
+   mChain = mBatchCommands.RestoreChain(mActiveChain);
+   PopulateList();
 }
 
-/// See comment in OnDrag
-void BatchPrefs::OnDragEnd(wxListEvent &event)
+/// An item in the chains list has been selected.
+void BatchPrefs::OnChainSelected(wxListEvent &event)
 {
-   int i;
-   i=7;// place for a breakpoint?
+   int itemNo = event.GetIndex();
+
+   mActiveChain = mChains->GetItemText(itemNo);
+   mChain = mBatchCommands.GetChain(mActiveChain);
+
+   if (mBatchCommands.IsFixed(mActiveChain)) {
+      mRemove->Disable();
+      mRename->Disable();
+      mDefaults->Enable();
+   }
+   else {
+      mRemove->Enable();
+      mRename->Enable();
+      mDefaults->Disable();
+   }
+
+   PopulateList();
+}
+
+///
+void BatchPrefs::OnChainsBeginEdit(wxListEvent &event)
+{
+   int itemNo = event.GetIndex();
+
+   wxString chain = mChains->GetItemText(itemNo);
+
+   if (mBatchCommands.IsFixed(mActiveChain)) {
+      wxBell();
+      event.Veto();
+   }
+}
+
+///
+void BatchPrefs::OnChainsEndEdit(wxListEvent &event)
+{
+   if (event.IsEditCancelled()) {
+      return;
+   }
+
+   wxString newname = event.GetLabel();
+
+   mChain = mBatchCommands.RenameChain(mActiveChain, newname);
+   mActiveChain = newname;
 }
 
 /// An item in the list has been selected.
@@ -259,11 +487,11 @@
    info.SetMask( wxLIST_MASK_TEXT );
 
    info.SetColumn( ActionColumn );
-   mList->GetItem( info ); 
+   mList->GetItem( info );
    command = info.GetText();
 
    info.SetColumn( ParamsColumn );
-   mList->GetItem( info ); 
+   mList->GetItem( info );
    params = info.GetText();
    
    Dlg.SetCommandAndParams( command, params );
@@ -294,19 +522,39 @@
    ShuttleGui S( this, eIsSavingToPrefs );
    PopulateOrExchange( S );
 
+   gPrefs->Write(wxT("/Batch/ActiveChain"), mActiveChain);
+   mBatchCommands.WriteChains();
+   mBatchCommands.FlushChains();
+
    unsigned int j;
    for(j = 0; j < gAudacityProjects.GetCount(); j++)
    {
       gAudacityProjects[j]->UpdateBatchPrefs();
    }
-   mBatchCommands.WriteChain();
+
    return true;
 }
 
+///
+void BatchPrefs::Cancel()
+{
+   mBatchCommands.FlushChains();
+}
+
 BatchPrefs::~BatchPrefs()
 {
 }
 
+/// Add one item into mList
+void BatchPrefs::AddItem( wxString const & Action, wxString const & Params)
+{
+   int i=mList->GetItemCount();
+   mList->InsertItem( i, wxT("") );
+   mList->SetItem( i, ItemNumberColumn, wxString::Format(wxT(" %02i"),i+1) );
+   mList->SetItem( i, ActionColumn, Action );
+   mList->SetItem( i, ParamsColumn, Params );
+}
+
 /// Sets one item in mList to a command/parameter pair.
 void BatchPrefs::SetItem(int itemNo, const wxString command, const wxString 
params)
 {
@@ -323,8 +571,7 @@
       if( (itemNo+1) >= mList->GetItemCount() )
          return;
 
-      mBatchCommands.mCommandChain.RemoveAt( itemNo );
-      mBatchCommands.mParamsChain.RemoveAt( itemNo );
+      mChain->RemoveAt( itemNo );
       PopulateList();
       return;
    }
@@ -332,20 +579,20 @@
    // Set the item in the list.
    mList->SetItem( itemNo ,ActionColumn, command ); 
    mList->SetItem( itemNo ,ParamsColumn, params );
+
    // IF at end of list THEN extend list
    // else replace item.
    if( (itemNo+1) >= mList->GetItemCount() )
    {
       // Add new rogue
       AddItem( _("- END -"),wxT(""));
-      mBatchCommands.mCommandChain.Add( command );
-      mBatchCommands.mParamsChain.Add( params );
+      mChain->Add( mBatchCommands.Join( command, params ) );
    }
    else
    {
-      mBatchCommands.mCommandChain[itemNo] = command;
-      mBatchCommands.mParamsChain[itemNo] = params;
+      (*mChain)[itemNo] = mBatchCommands.Join( command, params );
    }
+
    mList->Refresh(false);
 }
 


-------------------------------------------------------------------------
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