2 Copyright (C) 2000 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <gtkmm2ext/utils.h>
24 #include <gtkmm2ext/stop_signal.h>
26 #include <ardour/utils.h>
27 #include <ardour/configuration.h>
28 #include <ardour/session.h>
29 #include <pbd/memento_command.h>
31 #include "ardour_ui.h"
33 #include "location_ui.h"
36 #include "gui_thread.h"
40 using namespace ARDOUR;
43 using namespace Gtkmm2ext;
45 LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
46 : location(0), session(0),
47 item_table (1, 7, false),
48 start_set_button (_("Use PH")),
49 start_go_button (_("Go")),
50 start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true),
51 end_set_button (_("Use PH")),
52 end_go_button (_("Go")),
53 end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true),
54 length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, true),
55 cd_check_button (_("CD")),
56 hide_check_button (_("Hidden")),
57 remove_button (_("Remove")),
58 scms_check_button (_("SCMS")),
59 preemph_check_button (_("Pre-Emphasis"))
63 i_am_the_modifier = 0;
65 number_label.set_name ("LocationEditNumberLabel");
66 name_label.set_name ("LocationEditNameLabel");
67 name_entry.set_name ("LocationEditNameEntry");
68 start_set_button.set_name ("LocationEditSetButton");
69 start_go_button.set_name ("LocationEditGoButton");
70 end_set_button.set_name ("LocationEditSetButton");
71 end_go_button.set_name ("LocationEditGoButton");
72 cd_check_button.set_name ("LocationEditCdButton");
73 hide_check_button.set_name ("LocationEditHideButton");
74 remove_button.set_name ("LocationEditRemoveButton");
75 isrc_label.set_name ("LocationEditNumberLabel");
76 isrc_entry.set_name ("LocationEditNameEntry");
77 scms_check_button.set_name ("LocationEditCdButton");
78 preemph_check_button.set_name ("LocationEditCdButton");
79 performer_label.set_name ("LocationEditNumberLabel");
80 performer_entry.set_name ("LocationEditNameEntry");
81 composer_label.set_name ("LocationEditNumberLabel");
82 composer_entry.set_name ("LocationEditNameEntry");
84 ARDOUR_UI::instance()->tooltips().set_tip(start_set_button, _("Set value to Playhead"));
85 ARDOUR_UI::instance()->tooltips().set_tip(end_set_button, _("Set value to Playhead"));
87 isrc_label.set_text ("ISRC: ");
88 isrc_label.set_size_request (30, -1);
89 performer_label.set_text ("Performer: ");
90 performer_label.set_size_request (60, -1);
91 composer_label.set_text ("Composer: ");
92 composer_label.set_size_request (60, -1);
94 isrc_entry.set_size_request (112, -1);
95 isrc_entry.set_max_length(12);
96 isrc_entry.set_editable (true);
98 performer_entry.set_size_request (100, -1);
99 performer_entry.set_editable (true);
101 composer_entry.set_size_request (100, -1);
102 composer_entry.set_editable (true);
104 cd_track_details_hbox.pack_start (isrc_label, false, false);
105 cd_track_details_hbox.pack_start (isrc_entry, false, false);
106 cd_track_details_hbox.pack_start (scms_check_button, false, false);
107 cd_track_details_hbox.pack_start (preemph_check_button, false, false);
108 cd_track_details_hbox.pack_start (performer_label, false, false);
109 cd_track_details_hbox.pack_start (performer_entry, true, true);
110 cd_track_details_hbox.pack_start (composer_label, false, false);
111 cd_track_details_hbox.pack_start (composer_entry, true, true);
113 isrc_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::isrc_entry_changed));
114 performer_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::performer_entry_changed));
115 composer_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::composer_entry_changed));
116 scms_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::scms_toggled));
117 preemph_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::preemph_toggled));
123 item_table.attach (number_label, 0, 1, 0, 1, FILL, FILL, 3, 0);
125 start_hbox.pack_start (start_go_button, false, false);
126 start_hbox.pack_start (start_clock, false, false);
127 start_hbox.pack_start (start_set_button, false, false);
129 item_table.attach (start_hbox, 2, 3, 0, 1, FILL, FILL, 4, 0);
132 start_set_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::set_button_pressed), LocStart));
133 start_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocStart));
134 start_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocStart));
135 start_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocStart));
138 end_hbox.pack_start (end_go_button, false, false);
139 end_hbox.pack_start (end_clock, false, false);
140 end_hbox.pack_start (end_set_button, false, false);
142 //item_table.attach (end_hbox, 2, 3, 0, 1, 0, 0, 4, 0);
144 end_set_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::set_button_pressed), LocEnd));
145 end_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocEnd));
146 end_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocEnd));
147 end_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocEnd));
149 // item_table.attach (length_clock, 3, 4, 0, 1, 0, 0, 4, 0);
150 length_clock.ValueChanged.connect (bind ( mem_fun(*this, &LocationEditRow::clock_changed), LocLength));
151 length_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocLength));
153 // item_table.attach (cd_check_button, 4, 5, 0, 1, 0, Gtk::FILL, 4, 0);
154 // item_table.attach (hide_check_button, 5, 6, 0, 1, 0, Gtk::FILL, 4, 0);
155 // item_table.attach (remove_button, 7, 8, 0, 1, 0, Gtk::FILL, 4, 0);
157 cd_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::cd_toggled));
158 hide_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::hide_toggled));
160 remove_button.signal_clicked().connect(mem_fun(*this, &LocationEditRow::remove_button_pressed));
162 pack_start(item_table, true, true);
168 LocationEditRow::~LocationEditRow()
171 start_changed_connection.disconnect();
172 end_changed_connection.disconnect();
173 name_changed_connection.disconnect();
174 changed_connection.disconnect();
175 flags_changed_connection.disconnect();
180 LocationEditRow::set_session (Session *sess)
184 if (!session) return;
186 start_clock.set_session (session);
187 end_clock.set_session (session);
188 length_clock.set_session (session);
193 LocationEditRow::set_number (int num)
198 number_label.set_text (string_compose ("%1", number));
203 LocationEditRow::set_location (Location *loc)
206 start_changed_connection.disconnect();
207 end_changed_connection.disconnect();
208 name_changed_connection.disconnect();
209 changed_connection.disconnect();
210 flags_changed_connection.disconnect();
215 if (!location) return;
217 if (!hide_check_button.get_parent()) {
218 item_table.attach (hide_check_button, 6, 7, 0, 1, FILL, Gtk::FILL, 4, 0);
220 hide_check_button.set_active (location->is_hidden());
222 if (location->is_auto_loop() || location-> is_auto_punch()) {
223 // use label instead of entry
225 name_label.set_text (location->name());
226 name_label.set_size_request (80, -1);
228 if (!name_label.get_parent()) {
229 item_table.attach (name_label, 1, 2, 0, 1, FILL, FILL, 4, 0);
236 name_entry.set_text (location->name());
237 name_entry.set_size_request (100, -1);
238 name_entry.set_editable (true);
239 name_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::name_entry_changed));
241 if (!name_entry.get_parent()) {
242 item_table.attach (name_entry, 1, 2, 0, 1, FILL | EXPAND, FILL, 4, 0);
246 if (!cd_check_button.get_parent()) {
247 item_table.attach (cd_check_button, 5, 6, 0, 1, FILL, FILL, 4, 0);
249 if (!remove_button.get_parent()) {
250 item_table.attach (remove_button, 7, 8, 0, 1, FILL, FILL, 4, 0);
253 /* XXX i can't find a way to hide the button without messing up
254 the row spacing, so make it insensitive (paul).
257 if (location->is_end() || location->is_start()) {
258 remove_button.set_sensitive (false);
261 cd_check_button.set_active (location->is_cd_marker());
262 cd_check_button.show();
264 if (location->start() == session->current_start_frame()) {
265 cd_check_button.set_sensitive (false);
267 cd_check_button.set_sensitive (true);
270 hide_check_button.show();
273 start_clock.set (location->start(), true);
276 if (!location->is_mark()) {
277 if (!end_hbox.get_parent()) {
278 item_table.attach (end_hbox, 3, 4, 0, 1, FILL, FILL, 4, 0);
280 if (!length_clock.get_parent()) {
281 item_table.attach (length_clock, 4, 5, 0, 1, FILL, FILL, 4, 0);
284 end_clock.set (location->end(), true);
285 length_clock.set (location->length(), true);
287 end_set_button.show();
288 end_go_button.show();
294 end_set_button.hide();
295 end_go_button.hide();
301 start_clock.set_sensitive (!location->locked());
302 end_clock.set_sensitive (!location->locked());
303 length_clock.set_sensitive (!location->locked());
305 start_changed_connection = location->start_changed.connect (mem_fun(*this, &LocationEditRow::start_changed));
306 end_changed_connection = location->end_changed.connect (mem_fun(*this, &LocationEditRow::end_changed));
307 name_changed_connection = location->name_changed.connect (mem_fun(*this, &LocationEditRow::name_changed));
308 changed_connection = location->changed.connect (mem_fun(*this, &LocationEditRow::location_changed));
309 flags_changed_connection = location->FlagsChanged.connect (mem_fun(*this, &LocationEditRow::flags_changed));
313 LocationEditRow::name_entry_changed ()
315 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::name_entry_changed));
316 if (i_am_the_modifier || !location) return;
318 location->set_name (name_entry.get_text());
323 LocationEditRow::isrc_entry_changed ()
325 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::isrc_entry_changed));
327 if (i_am_the_modifier || !location) return;
329 if (isrc_entry.get_text() != "" ) {
331 location->cd_info["isrc"] = isrc_entry.get_text();
334 location->cd_info.erase("isrc");
339 LocationEditRow::performer_entry_changed ()
341 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::performer_entry_changed));
343 if (i_am_the_modifier || !location) return;
345 if (performer_entry.get_text() != "") {
346 location->cd_info["performer"] = performer_entry.get_text();
348 location->cd_info.erase("performer");
353 LocationEditRow::composer_entry_changed ()
355 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::composer_entry_changed));
357 if (i_am_the_modifier || !location) return;
359 if (composer_entry.get_text() != "") {
360 location->cd_info["composer"] = composer_entry.get_text();
362 location->cd_info.erase("composer");
368 LocationEditRow::set_button_pressed (LocationPart part)
370 if (!location) return;
374 location->set_start (session->transport_frame ());
377 location->set_end (session->transport_frame ());
385 LocationEditRow::go_button_pressed (LocationPart part)
387 if (!location) return;
391 ARDOUR_UI::instance()->do_transport_locate (location->start());
394 ARDOUR_UI::instance()->do_transport_locate (location->end());
402 LocationEditRow::clock_changed (LocationPart part)
404 if (i_am_the_modifier || !location) return;
408 location->set_start (start_clock.current_time());
411 location->set_end (end_clock.current_time());
414 location->set_end (location->start() + length_clock.current_duration());
422 LocationEditRow::change_aborted (LocationPart part)
424 if (i_am_the_modifier || !location) return;
426 set_location(location);
430 LocationEditRow::cd_toggled ()
432 if (i_am_the_modifier || !location) {
436 //if (cd_check_button.get_active() == location->is_cd_marker()) {
440 if (cd_check_button.get_active()) {
441 if (location->start() <= session->current_start_frame()) {
442 error << _("You cannot put a CD marker at the start of the session") << endmsg;
443 cd_check_button.set_active (false);
448 location->set_cd (cd_check_button.get_active(), this);
450 if (location->is_cd_marker() && !(location->is_mark())) {
452 if (location->cd_info.find("isrc") != location->cd_info.end()) {
453 isrc_entry.set_text(location->cd_info["isrc"]);
455 if (location->cd_info.find("performer") != location->cd_info.end()) {
456 performer_entry.set_text(location->cd_info["performer"]);
458 if (location->cd_info.find("composer") != location->cd_info.end()) {
459 composer_entry.set_text(location->cd_info["composer"]);
461 if (location->cd_info.find("scms") != location->cd_info.end()) {
462 scms_check_button.set_active(true);
464 if (location->cd_info.find("preemph") != location->cd_info.end()) {
465 preemph_check_button.set_active(true);
468 if (!cd_track_details_hbox.get_parent()) {
469 item_table.attach (cd_track_details_hbox, 1, 8, 1, 2, FILL | EXPAND, FILL, 4, 0);
471 // item_table.resize(2, 7);
472 cd_track_details_hbox.show_all();
474 } else if (cd_track_details_hbox.get_parent()){
476 item_table.remove (cd_track_details_hbox);
477 // item_table.resize(1, 7);
478 redraw_ranges(); /* EMIT_SIGNAL */
483 LocationEditRow::hide_toggled ()
485 if (i_am_the_modifier || !location) return;
487 location->set_hidden (hide_check_button.get_active(), this);
491 LocationEditRow::remove_button_pressed ()
493 if (!location) return;
495 remove_requested(location); /* EMIT_SIGNAL */
501 LocationEditRow::scms_toggled ()
503 if (i_am_the_modifier || !location) return;
505 if (scms_check_button.get_active()) {
506 location->cd_info["scms"] = "on";
508 location->cd_info.erase("scms");
514 LocationEditRow::preemph_toggled ()
516 if (i_am_the_modifier || !location) return;
518 if (preemph_check_button.get_active()) {
519 location->cd_info["preemph"] = "on";
521 location->cd_info.erase("preemph");
526 LocationEditRow::end_changed (ARDOUR::Location *loc)
528 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::end_changed), loc));
530 if (!location) return;
532 // update end and length
535 end_clock.set (location->end());
536 length_clock.set (location->length());
542 LocationEditRow::start_changed (ARDOUR::Location *loc)
544 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::start_changed), loc));
546 if (!location) return;
548 // update end and length
551 start_clock.set (location->start());
553 if (location->start() == session->current_start_frame()) {
554 cd_check_button.set_sensitive (false);
556 cd_check_button.set_sensitive (true);
563 LocationEditRow::name_changed (ARDOUR::Location *loc)
565 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::name_changed), loc));
567 if (!location) return;
569 // update end and length
572 name_entry.set_text(location->name());
573 name_label.set_text(location->name());
580 LocationEditRow::location_changed (ARDOUR::Location *loc)
582 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::location_changed), loc));
584 if (!location) return;
588 start_clock.set (location->start());
589 end_clock.set (location->end());
590 length_clock.set (location->length());
592 start_clock.set_sensitive (!location->locked());
593 end_clock.set_sensitive (!location->locked());
594 length_clock.set_sensitive (!location->locked());
601 LocationEditRow::flags_changed (ARDOUR::Location *loc, void *src)
603 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::flags_changed), loc, src));
605 if (!location) return;
609 cd_check_button.set_active (location->is_cd_marker());
610 hide_check_button.set_active (location->is_hidden());
616 LocationEditRow::focus_name() {
617 name_entry.grab_focus();
621 LocationUI::LocationUI ()
622 : ArdourDialog ("locations dialog"),
623 add_location_button (_("Add New Location")),
624 add_range_button (_("Add New Range"))
626 i_am_the_modifier = 0;
628 set_title(_("Locations"));
630 set_wmclass(X_("ardour_locations"), "Ardour");
632 set_name ("LocationWindow");
634 get_vbox()->pack_start (location_hpacker);
636 location_vpacker.set_border_width (10);
637 location_vpacker.set_spacing (5);
639 location_vpacker.pack_start (loop_edit_row, false, false);
640 location_vpacker.pack_start (punch_edit_row, false, false);
642 location_rows.set_name("LocationLocRows");
643 location_rows_scroller.add (location_rows);
644 location_rows_scroller.set_name ("LocationLocRowsScroller");
645 location_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
646 location_rows_scroller.set_size_request (-1, 130);
650 loc_frame_box.set_spacing (5);
651 loc_frame_box.set_border_width (5);
652 loc_frame_box.set_name("LocationFrameBox");
654 loc_frame_box.pack_start (location_rows_scroller, true, true);
656 add_location_button.set_name ("LocationAddLocationButton");
657 loc_frame_box.pack_start (add_location_button, false, false);
659 loc_frame.set_name ("LocationLocEditorFrame");
660 loc_frame.set_label (_("Location (CD Index) Markers"));
661 loc_frame.add (loc_frame_box);
662 loc_range_panes.pack1(loc_frame, true, false);
665 range_rows.set_name("LocationRangeRows");
666 range_rows_scroller.add (range_rows);
667 range_rows_scroller.set_name ("LocationRangeRowsScroller");
668 range_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
669 range_rows_scroller.set_size_request (-1, 130);
671 range_frame_box.set_spacing (5);
672 range_frame_box.set_name("LocationFrameBox");
673 range_frame_box.set_border_width (5);
674 range_frame_box.pack_start (range_rows_scroller, true, true);
676 add_range_button.set_name ("LocationAddRangeButton");
677 range_frame_box.pack_start (add_range_button, false, false);
679 range_frame.set_name ("LocationRangeEditorFrame");
680 range_frame.set_label (_("Range (CD Track) Markers"));
681 range_frame.add (range_frame_box);
682 loc_range_panes.pack2(range_frame, true, false);
683 location_vpacker.pack_start (loc_range_panes, true, true);
685 location_hpacker.pack_start (location_vpacker, true, true);
687 add_location_button.signal_clicked().connect (mem_fun(*this, &LocationUI::add_new_location));
688 add_range_button.signal_clicked().connect (mem_fun(*this, &LocationUI::add_new_range));
690 //add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_RELEASE_MASK);
695 LocationUI::~LocationUI()
699 void LocationUI::on_show()
701 ArdourDialog::on_show();
702 refresh_location_list();
706 gint LocationUI::do_location_remove (ARDOUR::Location *loc)
708 /* this is handled internally by Locations, but there's
709 no point saving state etc. when we know the marker
717 session->begin_reversible_command (_("remove marker"));
718 XMLNode &before = session->locations()->get_state();
719 session->locations()->remove (loc);
720 XMLNode &after = session->locations()->get_state();
721 session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
722 session->commit_reversible_command ();
727 void LocationUI::location_remove_requested (ARDOUR::Location *loc)
729 // must do this to prevent problems when destroying
730 // the effective sender of this event
732 Glib::signal_idle().connect (bind (mem_fun(*this, &LocationUI::do_location_remove), loc));
736 void LocationUI::location_redraw_ranges ()
746 LocationUI::location_added (Location* location)
748 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::location_added), location));
750 if (location->is_auto_punch()) {
751 punch_edit_row.set_location(location);
753 else if (location->is_auto_loop()) {
754 loop_edit_row.set_location(location);
757 refresh_location_list ();
762 LocationUI::location_removed (Location* location)
764 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::location_removed), location));
766 if (location->is_auto_punch()) {
767 punch_edit_row.set_location(0);
769 else if (location->is_auto_loop()) {
770 loop_edit_row.set_location(0);
773 refresh_location_list ();
777 struct LocationSortByStart {
778 bool operator() (Location *a, Location *b) {
779 return a->start() < b->start();
784 LocationUI::map_locations (Locations::LocationList& locations)
786 Locations::LocationList::iterator i;
790 Locations::LocationList temp = locations;
791 LocationSortByStart cmp;
796 Box_Helpers::BoxList & loc_children = location_rows.children();
797 Box_Helpers::BoxList & range_children = range_rows.children();
798 LocationEditRow * erow;
800 for (n = 0, i = locations.begin(); i != locations.end(); ++n, ++i) {
804 if (location->is_mark()) {
806 erow = manage (new LocationEditRow(session, location, mark_n));
807 erow->remove_requested.connect (mem_fun(*this, &LocationUI::location_remove_requested));
808 erow->redraw_ranges.connect (mem_fun(*this, &LocationUI::location_redraw_ranges));
809 loc_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
810 if (location == newest_location) {
815 else if (location->is_auto_punch()) {
816 punch_edit_row.set_session (session);
817 punch_edit_row.set_location (location);
818 punch_edit_row.show_all();
820 else if (location->is_auto_loop()) {
821 loop_edit_row.set_session (session);
822 loop_edit_row.set_location (location);
823 loop_edit_row.show_all();
826 erow = manage (new LocationEditRow(session, location));
827 erow->remove_requested.connect (mem_fun(*this, &LocationUI::location_remove_requested));
828 range_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
832 range_rows.show_all();
833 location_rows.show_all();
837 LocationUI::add_new_location()
842 nframes_t where = session->audible_frame();
843 session->locations()->next_available_name(markername,"mark");
844 Location *location = new Location (where, where, markername, Location::IsMark);
845 if (Config->get_name_new_markers()) {
846 newest_location = location;
848 session->begin_reversible_command (_("add marker"));
849 XMLNode &before = session->locations()->get_state();
850 session->locations()->add (location, true);
851 XMLNode &after = session->locations()->get_state();
852 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
853 session->commit_reversible_command ();
859 LocationUI::add_new_range()
864 nframes_t where = session->audible_frame();
865 session->locations()->next_available_name(rangename,"unnamed");
866 Location *location = new Location (where, where, rangename, Location::IsRangeMarker);
867 session->begin_reversible_command (_("add range marker"));
868 XMLNode &before = session->locations()->get_state();
869 session->locations()->add (location, true);
870 XMLNode &after = session->locations()->get_state();
871 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
872 session->commit_reversible_command ();
878 LocationUI::refresh_location_list_s (Change ignored)
880 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::refresh_location_list_s), ignored));
882 refresh_location_list ();
886 LocationUI::refresh_location_list ()
888 ENSURE_GUI_THREAD(mem_fun(*this, &LocationUI::refresh_location_list));
889 using namespace Box_Helpers;
891 // this is just too expensive to do when window is not shown
892 if (!is_visible()) return;
894 BoxList & loc_children = location_rows.children();
895 BoxList & range_children = range_rows.children();
897 loc_children.clear();
898 range_children.clear();
901 session->locations()->apply (*this, &LocationUI::map_locations);
907 LocationUI::set_session(ARDOUR::Session* sess)
909 ArdourDialog::set_session (sess);
912 session->locations()->changed.connect (mem_fun(*this, &LocationUI::refresh_location_list));
913 session->locations()->StateChanged.connect (mem_fun(*this, &LocationUI::refresh_location_list_s));
914 session->locations()->added.connect (mem_fun(*this, &LocationUI::location_added));
915 session->locations()->removed.connect (mem_fun(*this, &LocationUI::location_removed));
916 session->GoingAway.connect (mem_fun(*this, &LocationUI::session_gone));
918 refresh_location_list ();
922 LocationUI::session_gone()
924 ENSURE_GUI_THREAD(mem_fun(*this, &LocationUI::session_gone));
928 using namespace Box_Helpers;
929 BoxList & loc_children = location_rows.children();
930 BoxList & range_children = range_rows.children();
932 loc_children.clear();
933 range_children.clear();
935 loop_edit_row.set_session (0);
936 loop_edit_row.set_location (0);
938 punch_edit_row.set_session (0);
939 punch_edit_row.set_location (0);
941 ArdourDialog::session_gone ();
945 LocationUI::on_delete_event (GdkEventAny* ev)