AudioUnit work.
[ardour.git] / gtk2_ardour / location_ui.cc
index 564cc4dca29296d3cdaf8a37c63ca071569491b0..deb4c1da36bf5408714863a7230f22361d83ddd2 100644 (file)
@@ -27,6 +27,7 @@
 #include <ardour/utils.h>
 #include <ardour/configuration.h>
 #include <ardour/session.h>
+#include <pbd/memento_command.h>
 
 #include "ardour_ui.h"
 #include "prompter.h"
@@ -38,6 +39,7 @@
 #include "i18n.h"
 
 using namespace ARDOUR;
+using namespace PBD;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 
@@ -575,15 +577,12 @@ LocationUI::LocationUI ()
        set_wmclass(_("ardour_locations"), "Ardour");
 
        set_name ("LocationWindow");
-       signal_delete_event().connect (bind (ptr_fun (just_hide_it), static_cast<Window*>(this)));
-
-       add (location_hpacker);
 
+       get_vbox()->pack_start (location_hpacker);
 
        location_vpacker.set_border_width (10);
        location_vpacker.set_spacing (5);
 
-
        location_vpacker.pack_start (loop_edit_row, false, false);
        location_vpacker.pack_start (punch_edit_row, false, false);
 
@@ -656,9 +655,10 @@ gint LocationUI::do_location_remove (ARDOUR::Location *loc)
        }
 
        session->begin_reversible_command (_("remove marker"));
-       session->add_undo (session->locations()->get_memento());
+       XMLNode &before = session->locations()->get_state();
        session->locations()->remove (loc);
-       session->add_redo_no_execute (session->locations()->get_memento());
+       XMLNode &after = session->locations()->get_state();
+       session->add_command(new MementoCommand<Locations>(*(session->locations()), before, after));
        session->commit_reversible_command ();
 
        return FALSE;
@@ -774,9 +774,10 @@ LocationUI::add_new_location()
                jack_nframes_t where = session->audible_frame();
                Location *location = new Location (where, where, "mark", Location::IsMark);
                session->begin_reversible_command (_("add marker"));
-               session->add_undo (session->locations()->get_memento());
+               XMLNode &before = session->locations()->get_state();
                session->locations()->add (location, true);
-               session->add_redo_no_execute (session->locations()->get_memento());
+               XMLNode &after = session->locations()->get_state();
+               session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
                session->commit_reversible_command ();
        }
        
@@ -787,11 +788,13 @@ LocationUI::add_new_range()
 {
        if (session) {
                jack_nframes_t where = session->audible_frame();
-               Location *location = new Location (where, where, "unnamed");
+               Location *location = new Location (where, where, "unnamed", 
+                                                                                       Location::IsRangeMarker);
                session->begin_reversible_command (_("add range marker"));
-               session->add_undo (session->locations()->get_memento());
+               XMLNode &before = session->locations()->get_state();
                session->locations()->add (location, true);
-               session->add_redo_no_execute (session->locations()->get_memento());
+               XMLNode &after = session->locations()->get_state();
+               session->add_command (new MementoCommand<Locations>(*(session->locations()), before, after));
                session->commit_reversible_command ();
        }
 }
@@ -857,7 +860,13 @@ LocationUI::session_gone()
 
        punch_edit_row.set_session (0);
        punch_edit_row.set_location (0);
-       
-       ArdourDialog::session_gone();
+
+       ArdourDialog::session_gone ();
 }
 
+bool
+LocationUI::on_delete_event (GdkEventAny* ev)
+{
+       hide ();
+       return true;
+}