closing in on pin management.
[ardour.git] / gtk2_ardour / location_ui.cc
index 538d7315bd3f97658b1790011cb5d44e16b9f70e..4a2fc45a4770c354b54b439b21febcfa50bfc3b1 100644 (file)
@@ -33,6 +33,9 @@
 #include "location_ui.h"
 #include "prompter.h"
 #include "utils.h"
+#include "public_editor.h"
+#include "tooltips.h"
+#include "ui_config.h"
 
 #include "i18n.h"
 
@@ -313,20 +316,20 @@ LocationEditRow::set_location (Location *loc)
                        show_cd_track_details ();
                }
 
-               ARDOUR_UI::instance()->set_tip (remove_button, _("Remove this range"));
-               ARDOUR_UI::instance()->set_tip (start_clock, _("Start time - middle click to locate here"));
-               ARDOUR_UI::instance()->set_tip (end_clock, _("End time - middle click to locate here"));
-               ARDOUR_UI::instance()->set_tip (length_clock, _("Length"));
+               set_tooltip (remove_button, _("Remove this range"));
+               set_tooltip (start_clock, _("Start time - middle click to locate here"));
+               set_tooltip (end_clock, _("End time - middle click to locate here"));
+               set_tooltip (length_clock, _("Length"));
+
+               set_tooltip (start_to_playhead_button, _("Set range start from playhead location"));
+               set_tooltip (end_to_playhead_button, _("Set range end from playhead location"));
 
-               ARDOUR_UI::instance()->tooltips().set_tip (start_to_playhead_button, _("Set range start from playhead location"));
-               ARDOUR_UI::instance()->tooltips().set_tip (end_to_playhead_button, _("Set range end from playhead location"));
-               
        } else {
 
-               ARDOUR_UI::instance()->set_tip (remove_button, _("Remove this marker"));
-               ARDOUR_UI::instance()->set_tip (start_clock, _("Position - middle click to locate here"));
+               set_tooltip (remove_button, _("Remove this marker"));
+               set_tooltip (start_clock, _("Position - middle click to locate here"));
 
-               ARDOUR_UI::instance()->tooltips().set_tip (start_to_playhead_button, _("Set marker time from playhead location"));
+               set_tooltip (start_to_playhead_button, _("Set marker time from playhead location"));
 
                end_clock.hide();
                length_clock.hide();
@@ -342,7 +345,7 @@ LocationEditRow::set_location (Location *loc)
         location->StartChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::start_changed, this), gui_context());
         location->EndChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::end_changed, this), gui_context());
         location->Changed.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::location_changed, this), gui_context());
-        location->FlagsChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::flags_changed, this), gui_context()); 
+        location->FlagsChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::flags_changed, this), gui_context());
         location->LockChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::lock_changed, this), gui_context());
         location->PositionLockStyleChanged.connect (connections, invalidator (*this), boost::bind (&LocationEditRow::position_lock_style_changed, this), gui_context());
 }
@@ -838,7 +841,9 @@ LocationUI::LocationUI ()
 
 LocationUI::~LocationUI()
 {
-        delete _clock_group;
+       loop_edit_row.unset_clock_group ();
+       punch_edit_row.unset_clock_group ();
+       delete _clock_group;
 }
 
 gint
@@ -853,12 +858,12 @@ LocationUI::do_location_remove (ARDOUR::Location *loc)
                return FALSE;
        }
 
-       _session->begin_reversible_command (_("remove marker"));
+       PublicEditor::instance().begin_reversible_command (_("remove marker"));
        XMLNode &before = _session->locations()->get_state();
        _session->locations()->remove (loc);
        XMLNode &after = _session->locations()->get_state();
        _session->add_command(new MementoCommand<Locations>(*(_session->locations()), &before, &after));
-       _session->commit_reversible_command ();
+       PublicEditor::instance().commit_reversible_command ();
 
        return FALSE;
 }
@@ -898,7 +903,7 @@ LocationUI::location_added (Location* location)
                loc.sort (LocationSortByStart ());
 
                LocationEditRow* erow = manage (new LocationEditRow (_session, location));
-               
+
                 erow->set_clock_group (*_clock_group);
                erow->remove_requested.connect (sigc::mem_fun (*this, &LocationUI::location_remove_requested));
 
@@ -959,7 +964,7 @@ LocationUI::location_removed (Location* location)
 }
 
 void
-LocationUI::map_locations (Locations::LocationList& locations)
+LocationUI::map_locations (const Locations::LocationList& locations)
 {
        Locations::LocationList::iterator i;
        gint n;
@@ -968,9 +973,8 @@ LocationUI::map_locations (Locations::LocationList& locations)
        LocationSortByStart cmp;
 
        temp.sort (cmp);
-       locations = temp;
 
-       for (n = 0, i = locations.begin(); i != locations.end(); ++n, ++i) {
+       for (n = 0, i = temp.begin(); i != temp.end(); ++n, ++i) {
 
                Location* location = *i;
 
@@ -1015,15 +1019,15 @@ LocationUI::add_new_location()
                framepos_t where = _session->audible_frame();
                _session->locations()->next_available_name(markername,"mark");
                Location *location = new Location (*_session, where, where, markername, Location::IsMark);
-               if (Config->get_name_new_markers()) {
+               if (UIConfiguration::instance().get_name_new_markers()) {
                        newest_location = location;
                }
-               _session->begin_reversible_command (_("add marker"));
+               PublicEditor::instance().begin_reversible_command (_("add marker"));
                XMLNode &before = _session->locations()->get_state();
                _session->locations()->add (location, true);
                XMLNode &after = _session->locations()->get_state();
                _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
-               _session->commit_reversible_command ();
+               PublicEditor::instance().commit_reversible_command ();
        }
 
 }
@@ -1037,12 +1041,12 @@ LocationUI::add_new_range()
                framepos_t where = _session->audible_frame();
                _session->locations()->next_available_name(rangename,"unnamed");
                Location *location = new Location (*_session, where, where, rangename, Location::IsRangeMarker);
-               _session->begin_reversible_command (_("add range marker"));
+               PublicEditor::instance().begin_reversible_command (_("add range marker"));
                XMLNode &before = _session->locations()->get_state();
                _session->locations()->add (location, true);
                XMLNode &after = _session->locations()->get_state();
                _session->add_command (new MementoCommand<Locations>(*(_session->locations()), &before, &after));
-               _session->commit_reversible_command ();
+               PublicEditor::instance().commit_reversible_command ();
        }
 }
 
@@ -1074,10 +1078,10 @@ LocationUI::set_session(ARDOUR::Session* s)
        SessionHandlePtr::set_session (s);
 
        if (_session) {
-               _session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::locations_changed, this, _1), gui_context());
-               _session->locations()->StateChanged.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::refresh_location_list, this), gui_context());
                _session->locations()->added.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::location_added, this, _1), gui_context());
                _session->locations()->removed.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::location_removed, this, _1), gui_context());
+               _session->locations()->changed.connect (_session_connections, invalidator (*this), boost::bind (&LocationUI::refresh_location_list, this), gui_context());
+
                _clock_group->set_clock_mode (clock_mode_from_session_instant_xml ());
        }
 
@@ -1087,17 +1091,6 @@ LocationUI::set_session(ARDOUR::Session* s)
        refresh_location_list ();
 }
 
-void
-LocationUI::locations_changed (Locations::Change c)
-{
-       /* removal is signalled by both a removed and a changed signal emission from Locations,
-          so we don't need to refresh the list on a removal
-       */
-       if (c != Locations::REMOVAL) {
-               refresh_location_list ();
-       }
-}
-
 void
 LocationUI::session_going_away()
 {
@@ -1139,7 +1132,7 @@ LocationUI::clock_mode_from_session_instant_xml () const
        if (!p) {
                return ARDOUR_UI::instance()->secondary_clock->mode();
        }
-             
+
        return (AudioClock::Mode) string_2_enum (p->value (), AudioClock::Mode);
 }