make "New Session" open NSD on the right page
[ardour.git] / gtk2_ardour / redirect_automation_time_axis.cc
index 3a38062529365fe9ff45a9085b2dc51f52a214b2..acffda4ff19034aaadc520d777943de22d75dde2 100644 (file)
     along with this program; if not, write to the Free Software
     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
-    $Id$
 */
 
 #include <ardour/redirect.h>
 #include <ardour/session.h>
 #include <cstdlib>
+#include <pbd/memento_command.h>
 
 #include "redirect_automation_time_axis.h"
 #include "automation_line.h"
+#include "canvas_impl.h"
 
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 
-RedirectAutomationTimeAxisView::RedirectAutomationTimeAxisView (Session& s, Route& r, PublicEditor& e, TimeAxisView& parent, Widget* p, std::string n,
+RedirectAutomationTimeAxisView::RedirectAutomationTimeAxisView (Session& s, boost::shared_ptr<Route> r, 
+                                                               PublicEditor& e, TimeAxisView& parent, Canvas& canvas, std::string n,
                                                                uint32_t prt, Redirect& rd, string state_name)
 
        : AxisView (s),
-         AutomationTimeAxisView (s, r, e, parent, p, n, state_name, rd.name()),
+         AutomationTimeAxisView (s, r, e, parent, canvas, n, state_name, rd.name()),
          redirect (rd),
          port (prt)
        
@@ -70,7 +73,7 @@ RedirectAutomationTimeAxisView::~RedirectAutomationTimeAxisView ()
 }
 
 void
-RedirectAutomationTimeAxisView::add_automation_event (GnomeCanvasItem* item, GdkEvent* event, jack_nframes_t when, double y)
+RedirectAutomationTimeAxisView::add_automation_event (ArdourCanvas::Item* item, GdkEvent* event, nframes_t when, double y)
 {
        double x = 0;
 
@@ -95,9 +98,10 @@ RedirectAutomationTimeAxisView::add_automation_event (GnomeCanvasItem* item, Gdk
                lines.front()->view_to_model_y (y);
                
                _session.begin_reversible_command (description);
-               _session.add_undo (alist.get_memento());
+                XMLNode &before = alist.get_state();
                alist.add (when, y);
-               _session.add_redo_no_execute (alist.get_memento());
+                XMLNode &after = alist.get_state();
+                _session.add_command(new MementoCommand<AutomationList>(alist, &before, &after));
                _session.commit_reversible_command ();
                _session.set_dirty ();
        }