X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Flocation_ui.cc;h=9613aaccb50d193e42e063479e8204daf9d3a0e3;hb=d8e93be2ee68fc6a18a7ca17d36ffc67c94207b3;hp=1bb251999c587760625177527b8ff55a341eea94;hpb=157c2a866c166b94b65da442b8c54f5ffa8d6a53;p=ardour.git diff --git a/gtk2_ardour/location_ui.cc b/gtk2_ardour/location_ui.cc index 1bb251999c..9613aaccb5 100644 --- a/gtk2_ardour/location_ui.cc +++ b/gtk2_ardour/location_ui.cc @@ -21,7 +21,6 @@ #include #include -#include #include "ardour/utils.h" #include "ardour/configuration.h" @@ -226,7 +225,7 @@ LocationEditRow::set_location (Location *loc) item_table.attach (remove_button, 6, 7, 0, 1, FILL, FILL, 4, 0); } - if (location->is_end() || location->is_start()) { + if (location->is_session_range()) { remove_button.set_sensitive (false); } @@ -282,11 +281,11 @@ LocationEditRow::set_location (Location *loc) end_clock.set_sensitive (!location->locked()); length_clock.set_sensitive (!location->locked()); - location->start_changed.connect (connections, ui_bind (&LocationEditRow::start_changed, this, _1), gui_context()); - location->end_changed.connect (connections, ui_bind (&LocationEditRow::end_changed, this, _1), gui_context()); - location->name_changed.connect (connections, ui_bind (&LocationEditRow::name_changed, this, _1), gui_context()); - location->changed.connect (connections, ui_bind (&LocationEditRow::location_changed, this, _1), gui_context()); - location->FlagsChanged.connect (connections, ui_bind (&LocationEditRow::flags_changed, this, _1, _2), gui_context()); + location->start_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::start_changed, this, _1), gui_context()); + location->end_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::end_changed, this, _1), gui_context()); + location->name_changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::name_changed, this, _1), gui_context()); + location->changed.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::location_changed, this, _1), gui_context()); + location->FlagsChanged.connect (connections, invalidator (*this), ui_bind (&LocationEditRow::flags_changed, this, _1, _2), gui_context()); } void @@ -453,9 +452,11 @@ LocationEditRow::hide_toggled () void LocationEditRow::remove_button_pressed () { - if (!location) return; + if (!location) { + return; + } - remove_requested(location); /* EMIT_SIGNAL */ + remove_requested (location); /* EMIT_SIGNAL */ } @@ -671,7 +672,7 @@ LocationUI::do_location_remove (ARDOUR::Location *loc) cannot be removed. */ - if (loc->is_end()) { + if (loc->is_session_range()) { return FALSE; } @@ -709,11 +710,9 @@ LocationUI::location_added (Location* location) if (location->is_auto_punch()) { punch_edit_row.set_location(location); - } - else if (location->is_auto_loop()) { + } else if (location->is_auto_loop()) { loop_edit_row.set_location(location); - } - else { + } else { refresh_location_list (); } } @@ -725,12 +724,17 @@ LocationUI::location_removed (Location* location) if (location->is_auto_punch()) { punch_edit_row.set_location(0); - } - else if (location->is_auto_loop()) { + } else if (location->is_auto_loop()) { loop_edit_row.set_location(0); - } - else { - refresh_location_list (); + } else if (location->is_range_marker() || location->is_mark()) { + Box_Helpers::BoxList& children = location->is_range_marker() ? range_rows.children () : location_rows.children (); + for (Box_Helpers::BoxList::iterator i = children.begin(); i != children.end(); ++i) { + LocationEditRow* r = dynamic_cast (i->get_widget()); + if (r && r->get_location() == location) { + children.erase (i); + break; + } + } } } @@ -744,7 +748,6 @@ void LocationUI::map_locations (Locations::LocationList& locations) { Locations::LocationList::iterator i; - Location* location; gint n; int mark_n = 0; Locations::LocationList temp = locations; @@ -753,38 +756,32 @@ LocationUI::map_locations (Locations::LocationList& locations) temp.sort (cmp); locations = temp; - Box_Helpers::BoxList & loc_children = location_rows.children(); - Box_Helpers::BoxList & range_children = range_rows.children(); - LocationEditRow * erow; - for (n = 0, i = locations.begin(); i != locations.end(); ++n, ++i) { - location = *i; + Location* location = *i; if (location->is_mark()) { - mark_n++; - erow = manage (new LocationEditRow(_session, location, mark_n)); + LocationEditRow* erow = manage (new LocationEditRow (_session, location, mark_n)); erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested)); - erow->redraw_ranges.connect (sigc::mem_fun(*this, &LocationUI::location_redraw_ranges)); + erow->redraw_ranges.connect (sigc::mem_fun(*this, &LocationUI::location_redraw_ranges)); + Box_Helpers::BoxList & loc_children = location_rows.children(); loc_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START)); if (location == newest_location) { newest_location = 0; erow->focus_name(); } - } - else if (location->is_auto_punch()) { + } else if (location->is_auto_punch()) { punch_edit_row.set_session (_session); punch_edit_row.set_location (location); punch_edit_row.show_all(); - } - else if (location->is_auto_loop()) { + } else if (location->is_auto_loop()) { loop_edit_row.set_session (_session); loop_edit_row.set_location (location); loop_edit_row.show_all(); - } - else { - erow = manage (new LocationEditRow(_session, location)); + } else { + LocationEditRow* erow = manage (new LocationEditRow(_session, location)); erow->remove_requested.connect (sigc::mem_fun(*this, &LocationUI::location_remove_requested)); + Box_Helpers::BoxList & range_children = range_rows.children(); range_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START)); } } @@ -860,10 +857,10 @@ LocationUI::set_session(ARDOUR::Session* s) SessionHandlePtr::set_session (s); if (_session) { - _session->locations()->changed.connect (_session_connections, boost::bind (&LocationUI::refresh_location_list, this), gui_context()); - _session->locations()->StateChanged.connect (_session_connections, boost::bind (&LocationUI::refresh_location_list, this), gui_context()); - _session->locations()->added.connect (_session_connections, ui_bind (&LocationUI::location_added, this, _1), gui_context()); - _session->locations()->removed.connect (_session_connections, ui_bind (&LocationUI::location_removed, this, _1), gui_context()); + _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), ui_bind (&LocationUI::location_added, this, _1), gui_context()); + _session->locations()->removed.connect (_session_connections, invalidator (*this), ui_bind (&LocationUI::location_removed, this, _1), gui_context()); } loop_edit_row.set_session (s); @@ -872,6 +869,17 @@ 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() { @@ -896,9 +904,8 @@ LocationUI::session_going_away() /*------------------------*/ LocationUIWindow::LocationUIWindow () - : ArdourDialog ("locations dialog") + : ArdourDialog (_("Locations")) { - set_title (_("Locations")); set_wmclass(X_("ardour_locations"), "Ardour"); set_name ("LocationWindow");