AudioUnit work.
[ardour.git] / gtk2_ardour / location_ui.cc
index a6957a90175202023dbe281d1ca722d181e2c549..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;
 
@@ -108,17 +110,8 @@ LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
        cd_track_details_hbox.pack_start (composer_entry, true, true);
 
        isrc_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::isrc_entry_changed)); 
-       isrc_entry.signal_focus_in_event().connect (mem_fun(*this, &LocationEditRow::entry_focus_event));
-       isrc_entry.signal_focus_out_event().connect (mem_fun(*this, &LocationEditRow::entry_focus_event));
-
        performer_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::performer_entry_changed));
-       performer_entry.signal_focus_in_event().connect (mem_fun(*this, &LocationEditRow::entry_focus_event));
-       performer_entry.signal_focus_out_event().connect (mem_fun(*this, &LocationEditRow::entry_focus_event));
-
        composer_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::composer_entry_changed));
-       composer_entry.signal_focus_in_event().connect (mem_fun(*this, &LocationEditRow::entry_focus_event));
-       composer_entry.signal_focus_out_event().connect (mem_fun(*this, &LocationEditRow::entry_focus_event));
-
        scms_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::scms_toggled));
        preemph_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::preemph_toggled));
 
@@ -240,8 +233,6 @@ LocationEditRow::set_location (Location *loc)
                name_entry.set_size_request (100, -1);
                name_entry.set_editable (true);
                name_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::name_entry_changed));  
-               name_entry.signal_focus_in_event().connect (mem_fun(*this, &LocationEditRow::entry_focus_event));
-               name_entry.signal_focus_out_event().connect (mem_fun(*this, &LocationEditRow::entry_focus_event));
 
                if (!name_entry.get_parent()) {
                        item_table.attach (name_entry, 1, 2, 0, 1, FILL | EXPAND, FILL, 4, 0);
@@ -302,18 +293,6 @@ LocationEditRow::set_location (Location *loc)
        
 }
 
-gint
-LocationEditRow::entry_focus_event (GdkEventFocus* ev)
-{
-       if (ev->in) {
-               ARDOUR_UI::instance()->allow_focus (true);
-       } else {
-               ARDOUR_UI::instance()->allow_focus (false);
-       }
-       return TRUE;
-}
-
-
 void
 LocationEditRow::name_entry_changed ()
 {
@@ -598,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);
 
@@ -679,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;
@@ -797,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 ();
        }
        
@@ -810,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 ();
        }
 }
@@ -880,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;
+}