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>
25 #include <gtkmm2ext/window_title.h>
27 #include "ardour/utils.h"
28 #include "ardour/configuration.h"
29 #include "ardour/session.h"
30 #include "pbd/memento_command.h"
32 #include "ardour_ui.h"
34 #include "location_ui.h"
37 #include "gui_thread.h"
42 using namespace ARDOUR;
45 using namespace Gtkmm2ext;
47 LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
48 : location(0), session(0),
49 item_table (1, 7, false),
50 start_set_button (_("Use PH")),
51 start_go_button (_("Go")),
52 start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true),
53 end_set_button (_("Use PH")),
54 end_go_button (_("Go")),
55 end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true),
56 length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, true),
57 cd_check_button (_("CD")),
58 hide_check_button (_("Hidden")),
59 remove_button (_("Remove")),
60 scms_check_button (_("SCMS")),
61 preemph_check_button (_("Pre-Emphasis"))
65 i_am_the_modifier = 0;
67 number_label.set_name ("LocationEditNumberLabel");
68 name_label.set_name ("LocationEditNameLabel");
69 name_entry.set_name ("LocationEditNameEntry");
70 start_set_button.set_name ("LocationEditSetButton");
71 start_go_button.set_name ("LocationEditGoButton");
72 end_set_button.set_name ("LocationEditSetButton");
73 end_go_button.set_name ("LocationEditGoButton");
74 cd_check_button.set_name ("LocationEditCdButton");
75 hide_check_button.set_name ("LocationEditHideButton");
76 remove_button.set_name ("LocationEditRemoveButton");
77 isrc_label.set_name ("LocationEditNumberLabel");
78 isrc_entry.set_name ("LocationEditNameEntry");
79 scms_check_button.set_name ("LocationEditCdButton");
80 preemph_check_button.set_name ("LocationEditCdButton");
81 performer_label.set_name ("LocationEditNumberLabel");
82 performer_entry.set_name ("LocationEditNameEntry");
83 composer_label.set_name ("LocationEditNumberLabel");
84 composer_entry.set_name ("LocationEditNameEntry");
86 ARDOUR_UI::instance()->tooltips().set_tip(start_set_button, _("Set value to Playhead"));
87 ARDOUR_UI::instance()->tooltips().set_tip(end_set_button, _("Set value to Playhead"));
89 isrc_label.set_text ("ISRC: ");
90 isrc_label.set_size_request (30, -1);
91 performer_label.set_text ("Performer: ");
92 performer_label.set_size_request (60, -1);
93 composer_label.set_text ("Composer: ");
94 composer_label.set_size_request (60, -1);
96 isrc_entry.set_size_request (112, -1);
97 isrc_entry.set_max_length(12);
98 isrc_entry.set_editable (true);
100 performer_entry.set_size_request (100, -1);
101 performer_entry.set_editable (true);
103 composer_entry.set_size_request (100, -1);
104 composer_entry.set_editable (true);
106 cd_track_details_hbox.pack_start (isrc_label, false, false);
107 cd_track_details_hbox.pack_start (isrc_entry, false, false);
108 cd_track_details_hbox.pack_start (scms_check_button, false, false);
109 cd_track_details_hbox.pack_start (preemph_check_button, false, false);
110 cd_track_details_hbox.pack_start (performer_label, false, false);
111 cd_track_details_hbox.pack_start (performer_entry, true, true);
112 cd_track_details_hbox.pack_start (composer_label, false, false);
113 cd_track_details_hbox.pack_start (composer_entry, true, true);
115 isrc_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::isrc_entry_changed));
116 performer_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::performer_entry_changed));
117 composer_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::composer_entry_changed));
118 scms_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::scms_toggled));
119 preemph_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::preemph_toggled));
125 item_table.attach (number_label, 0, 1, 0, 1, FILL, FILL, 3, 0);
127 start_hbox.pack_start (start_go_button, false, false);
128 start_hbox.pack_start (start_clock, false, false);
129 start_hbox.pack_start (start_set_button, false, false);
131 item_table.attach (start_hbox, 2, 3, 0, 1, FILL, FILL, 4, 0);
134 start_set_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::set_button_pressed), LocStart));
135 start_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocStart));
136 start_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocStart));
137 start_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocStart));
140 end_hbox.pack_start (end_go_button, false, false);
141 end_hbox.pack_start (end_clock, false, false);
142 end_hbox.pack_start (end_set_button, false, false);
144 //item_table.attach (end_hbox, 2, 3, 0, 1, 0, 0, 4, 0);
146 end_set_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::set_button_pressed), LocEnd));
147 end_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocEnd));
148 end_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocEnd));
149 end_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocEnd));
151 // item_table.attach (length_clock, 3, 4, 0, 1, 0, 0, 4, 0);
152 length_clock.ValueChanged.connect (bind ( mem_fun(*this, &LocationEditRow::clock_changed), LocLength));
153 length_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocLength));
155 // item_table.attach (cd_check_button, 4, 5, 0, 1, 0, Gtk::FILL, 4, 0);
156 // item_table.attach (hide_check_button, 5, 6, 0, 1, 0, Gtk::FILL, 4, 0);
157 // item_table.attach (remove_button, 7, 8, 0, 1, 0, Gtk::FILL, 4, 0);
159 cd_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::cd_toggled));
160 hide_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::hide_toggled));
162 remove_button.signal_clicked().connect(mem_fun(*this, &LocationEditRow::remove_button_pressed));
164 pack_start(item_table, true, true);
170 LocationEditRow::~LocationEditRow()
173 start_changed_connection.disconnect();
174 end_changed_connection.disconnect();
175 name_changed_connection.disconnect();
176 changed_connection.disconnect();
177 flags_changed_connection.disconnect();
182 LocationEditRow::set_session (Session *sess)
186 if (!session) return;
188 start_clock.set_session (session);
189 end_clock.set_session (session);
190 length_clock.set_session (session);
195 LocationEditRow::set_number (int num)
200 number_label.set_text (string_compose ("%1", number));
205 LocationEditRow::set_location (Location *loc)
208 start_changed_connection.disconnect();
209 end_changed_connection.disconnect();
210 name_changed_connection.disconnect();
211 changed_connection.disconnect();
212 flags_changed_connection.disconnect();
217 if (!location) return;
219 if (!hide_check_button.get_parent()) {
220 item_table.attach (hide_check_button, 6, 7, 0, 1, FILL, Gtk::FILL, 4, 0);
222 hide_check_button.set_active (location->is_hidden());
224 if (location->is_auto_loop() || location-> is_auto_punch()) {
225 // use label instead of entry
227 name_label.set_text (location->name());
228 name_label.set_size_request (80, -1);
230 if (!name_label.get_parent()) {
231 item_table.attach (name_label, 1, 2, 0, 1, FILL, FILL, 4, 0);
238 name_entry.set_text (location->name());
239 name_entry.set_size_request (100, -1);
240 name_entry.set_editable (true);
241 name_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::name_entry_changed));
243 if (!name_entry.get_parent()) {
244 item_table.attach (name_entry, 1, 2, 0, 1, FILL | EXPAND, FILL, 4, 0);
248 if (!cd_check_button.get_parent()) {
249 item_table.attach (cd_check_button, 5, 6, 0, 1, FILL, FILL, 4, 0);
251 if (!remove_button.get_parent()) {
252 item_table.attach (remove_button, 7, 8, 0, 1, FILL, FILL, 4, 0);
255 /* XXX i can't find a way to hide the button without messing up
256 the row spacing, so make it insensitive (paul).
259 if (location->is_end() || location->is_start()) {
260 remove_button.set_sensitive (false);
263 cd_check_button.set_active (location->is_cd_marker());
264 cd_check_button.show();
266 if (location->start() == session->current_start_frame()) {
267 cd_check_button.set_sensitive (false);
269 cd_check_button.set_sensitive (true);
272 hide_check_button.show();
275 start_clock.set (location->start(), true);
278 if (!location->is_mark()) {
279 if (!end_hbox.get_parent()) {
280 item_table.attach (end_hbox, 3, 4, 0, 1, FILL, FILL, 4, 0);
282 if (!length_clock.get_parent()) {
283 item_table.attach (length_clock, 4, 5, 0, 1, FILL, FILL, 4, 0);
286 end_clock.set (location->end(), true);
287 length_clock.set (location->length(), true);
289 end_set_button.show();
290 end_go_button.show();
296 end_set_button.hide();
297 end_go_button.hide();
303 start_clock.set_sensitive (!location->locked());
304 end_clock.set_sensitive (!location->locked());
305 length_clock.set_sensitive (!location->locked());
307 start_changed_connection = location->start_changed.connect (mem_fun(*this, &LocationEditRow::start_changed));
308 end_changed_connection = location->end_changed.connect (mem_fun(*this, &LocationEditRow::end_changed));
309 name_changed_connection = location->name_changed.connect (mem_fun(*this, &LocationEditRow::name_changed));
310 changed_connection = location->changed.connect (mem_fun(*this, &LocationEditRow::location_changed));
311 flags_changed_connection = location->FlagsChanged.connect (mem_fun(*this, &LocationEditRow::flags_changed));
315 LocationEditRow::name_entry_changed ()
317 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::name_entry_changed));
318 if (i_am_the_modifier || !location) return;
320 location->set_name (name_entry.get_text());
325 LocationEditRow::isrc_entry_changed ()
327 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::isrc_entry_changed));
329 if (i_am_the_modifier || !location) return;
331 if (isrc_entry.get_text() != "" ) {
333 location->cd_info["isrc"] = isrc_entry.get_text();
336 location->cd_info.erase("isrc");
341 LocationEditRow::performer_entry_changed ()
343 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::performer_entry_changed));
345 if (i_am_the_modifier || !location) return;
347 if (performer_entry.get_text() != "") {
348 location->cd_info["performer"] = performer_entry.get_text();
350 location->cd_info.erase("performer");
355 LocationEditRow::composer_entry_changed ()
357 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::composer_entry_changed));
359 if (i_am_the_modifier || !location) return;
361 if (composer_entry.get_text() != "") {
362 location->cd_info["composer"] = composer_entry.get_text();
364 location->cd_info.erase("composer");
370 LocationEditRow::set_button_pressed (LocationPart part)
372 if (!location) return;
376 location->set_start (session->transport_frame ());
379 location->set_end (session->transport_frame ());
387 LocationEditRow::go_button_pressed (LocationPart part)
389 if (!location) return;
393 ARDOUR_UI::instance()->do_transport_locate (location->start());
396 ARDOUR_UI::instance()->do_transport_locate (location->end());
404 LocationEditRow::clock_changed (LocationPart part)
406 if (i_am_the_modifier || !location) return;
410 location->set_start (start_clock.current_time());
413 location->set_end (end_clock.current_time());
416 location->set_end (location->start() + length_clock.current_duration());
424 LocationEditRow::change_aborted (LocationPart part)
426 if (i_am_the_modifier || !location) return;
428 set_location(location);
432 LocationEditRow::cd_toggled ()
434 if (i_am_the_modifier || !location) {
438 //if (cd_check_button.get_active() == location->is_cd_marker()) {
442 if (cd_check_button.get_active()) {
443 if (location->start() <= session->current_start_frame()) {
444 error << _("You cannot put a CD marker at the start of the session") << endmsg;
445 cd_check_button.set_active (false);
450 location->set_cd (cd_check_button.get_active(), this);
452 if (location->is_cd_marker() && !(location->is_mark())) {
454 if (location->cd_info.find("isrc") != location->cd_info.end()) {
455 isrc_entry.set_text(location->cd_info["isrc"]);
457 if (location->cd_info.find("performer") != location->cd_info.end()) {
458 performer_entry.set_text(location->cd_info["performer"]);
460 if (location->cd_info.find("composer") != location->cd_info.end()) {
461 composer_entry.set_text(location->cd_info["composer"]);
463 if (location->cd_info.find("scms") != location->cd_info.end()) {
464 scms_check_button.set_active(true);
466 if (location->cd_info.find("preemph") != location->cd_info.end()) {
467 preemph_check_button.set_active(true);
470 if (!cd_track_details_hbox.get_parent()) {
471 item_table.attach (cd_track_details_hbox, 1, 8, 1, 2, FILL | EXPAND, FILL, 4, 0);
473 // item_table.resize(2, 7);
474 cd_track_details_hbox.show_all();
476 } else if (cd_track_details_hbox.get_parent()){
478 item_table.remove (cd_track_details_hbox);
479 // item_table.resize(1, 7);
480 redraw_ranges(); /* EMIT_SIGNAL */
485 LocationEditRow::hide_toggled ()
487 if (i_am_the_modifier || !location) return;
489 location->set_hidden (hide_check_button.get_active(), this);
493 LocationEditRow::remove_button_pressed ()
495 if (!location) return;
497 remove_requested(location); /* EMIT_SIGNAL */
503 LocationEditRow::scms_toggled ()
505 if (i_am_the_modifier || !location) return;
507 if (scms_check_button.get_active()) {
508 location->cd_info["scms"] = "on";
510 location->cd_info.erase("scms");
516 LocationEditRow::preemph_toggled ()
518 if (i_am_the_modifier || !location) return;
520 if (preemph_check_button.get_active()) {
521 location->cd_info["preemph"] = "on";
523 location->cd_info.erase("preemph");
528 LocationEditRow::end_changed (ARDOUR::Location *loc)
530 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::end_changed), loc));
532 if (!location) return;
534 // update end and length
537 end_clock.set (location->end());
538 length_clock.set (location->length());
544 LocationEditRow::start_changed (ARDOUR::Location *loc)
546 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::start_changed), loc));
548 if (!location) return;
550 // update end and length
553 start_clock.set (location->start());
555 if (location->start() == session->current_start_frame()) {
556 cd_check_button.set_sensitive (false);
558 cd_check_button.set_sensitive (true);
565 LocationEditRow::name_changed (ARDOUR::Location *loc)
567 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::name_changed), loc));
569 if (!location) return;
571 // update end and length
574 name_entry.set_text(location->name());
575 name_label.set_text(location->name());
582 LocationEditRow::location_changed (ARDOUR::Location *loc)
584 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::location_changed), loc));
586 if (!location) return;
590 start_clock.set (location->start());
591 end_clock.set (location->end());
592 length_clock.set (location->length());
594 start_clock.set_sensitive (!location->locked());
595 end_clock.set_sensitive (!location->locked());
596 length_clock.set_sensitive (!location->locked());
603 LocationEditRow::flags_changed (ARDOUR::Location *loc, void *src)
605 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::flags_changed), loc, src));
607 if (!location) return;
611 cd_check_button.set_active (location->is_cd_marker());
612 hide_check_button.set_active (location->is_hidden());
618 LocationEditRow::focus_name() {
619 name_entry.grab_focus();
623 LocationUI::LocationUI ()
624 : ArdourDialog ("locations dialog"),
625 add_location_button (_("Add New Location")),
626 add_range_button (_("Add New Range"))
628 i_am_the_modifier = 0;
630 WindowTitle title(Glib::get_application_name());
631 title += _("Locations");
633 set_title(title.get_string());
634 set_wmclass(X_("ardour_locations"), "Ardour");
636 set_name ("LocationWindow");
638 get_vbox()->pack_start (location_hpacker);
640 location_vpacker.set_spacing (5);
642 location_vpacker.pack_start (loop_edit_row, false, false);
643 location_vpacker.pack_start (punch_edit_row, false, false);
645 location_rows.set_name("LocationLocRows");
646 location_rows_scroller.add (location_rows);
647 location_rows_scroller.set_name ("LocationLocRowsScroller");
648 location_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
649 location_rows_scroller.set_size_request (-1, 130);
653 loc_frame_box.set_spacing (5);
654 loc_frame_box.set_border_width (5);
655 loc_frame_box.set_name("LocationFrameBox");
657 loc_frame_box.pack_start (location_rows_scroller, true, true);
659 add_location_button.set_name ("LocationAddLocationButton");
660 loc_frame_box.pack_start (add_location_button, false, false);
662 loc_frame.set_name ("LocationLocEditorFrame");
663 loc_frame.set_label (_("Location (CD index) markers"));
664 loc_frame.add (loc_frame_box);
665 loc_range_panes.pack1(loc_frame, true, false);
668 range_rows.set_name("LocationRangeRows");
669 range_rows_scroller.add (range_rows);
670 range_rows_scroller.set_name ("LocationRangeRowsScroller");
671 range_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
672 range_rows_scroller.set_size_request (-1, 130);
674 range_frame_box.set_spacing (5);
675 range_frame_box.set_name("LocationFrameBox");
676 range_frame_box.set_border_width (5);
677 range_frame_box.pack_start (range_rows_scroller, true, true);
679 add_range_button.set_name ("LocationAddRangeButton");
680 range_frame_box.pack_start (add_range_button, false, false);
682 range_frame.set_name ("LocationRangeEditorFrame");
683 range_frame.set_label (_("Range (CD track) markers"));
684 range_frame.add (range_frame_box);
685 loc_range_panes.pack2(range_frame, true, false);
686 location_vpacker.pack_start (loc_range_panes, true, true);
688 location_hpacker.pack_start (location_vpacker, true, true);
690 add_location_button.signal_clicked().connect (mem_fun(*this, &LocationUI::add_new_location));
691 add_range_button.signal_clicked().connect (mem_fun(*this, &LocationUI::add_new_range));
693 //add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK|Gdk::BUTTON_RELEASE_MASK);
698 LocationUI::~LocationUI()
702 void LocationUI::on_show()
704 ArdourDialog::on_show();
705 refresh_location_list();
709 gint LocationUI::do_location_remove (ARDOUR::Location *loc)
711 /* this is handled internally by Locations, but there's
712 no point saving state etc. when we know the marker
720 session->begin_reversible_command (_("remove marker"));
721 XMLNode &before = session->locations()->get_state();
722 session->locations()->remove (loc);
723 XMLNode &after = session->locations()->get_state();
724 session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
725 session->commit_reversible_command ();
730 void LocationUI::location_remove_requested (ARDOUR::Location *loc)
732 // must do this to prevent problems when destroying
733 // the effective sender of this event
735 Glib::signal_idle().connect (bind (mem_fun(*this, &LocationUI::do_location_remove), loc));
739 void LocationUI::location_redraw_ranges ()
749 LocationUI::location_added (Location* location)
751 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::location_added), location));
753 if (location->is_auto_punch()) {
754 punch_edit_row.set_location(location);
756 else if (location->is_auto_loop()) {
757 loop_edit_row.set_location(location);
760 refresh_location_list ();
765 LocationUI::location_removed (Location* location)
767 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::location_removed), location));
769 if (location->is_auto_punch()) {
770 punch_edit_row.set_location(0);
772 else if (location->is_auto_loop()) {
773 loop_edit_row.set_location(0);
776 refresh_location_list ();
780 struct LocationSortByStart {
781 bool operator() (Location *a, Location *b) {
782 return a->start() < b->start();
787 LocationUI::map_locations (Locations::LocationList& locations)
789 Locations::LocationList::iterator i;
793 Locations::LocationList temp = locations;
794 LocationSortByStart cmp;
799 Box_Helpers::BoxList & loc_children = location_rows.children();
800 Box_Helpers::BoxList & range_children = range_rows.children();
801 LocationEditRow * erow;
803 for (n = 0, i = locations.begin(); i != locations.end(); ++n, ++i) {
807 if (location->is_mark()) {
809 erow = manage (new LocationEditRow(session, location, mark_n));
810 erow->remove_requested.connect (mem_fun(*this, &LocationUI::location_remove_requested));
811 erow->redraw_ranges.connect (mem_fun(*this, &LocationUI::location_redraw_ranges));
812 loc_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
813 if (location == newest_location) {
818 else if (location->is_auto_punch()) {
819 punch_edit_row.set_session (session);
820 punch_edit_row.set_location (location);
821 punch_edit_row.show_all();
823 else if (location->is_auto_loop()) {
824 loop_edit_row.set_session (session);
825 loop_edit_row.set_location (location);
826 loop_edit_row.show_all();
829 erow = manage (new LocationEditRow(session, location));
830 erow->remove_requested.connect (mem_fun(*this, &LocationUI::location_remove_requested));
831 range_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
835 range_rows.show_all();
836 location_rows.show_all();
840 LocationUI::add_new_location()
845 nframes_t where = session->audible_frame();
846 session->locations()->next_available_name(markername,"mark");
847 Location *location = new Location (where, where, markername, Location::IsMark);
848 if (Config->get_name_new_markers()) {
849 newest_location = location;
851 session->begin_reversible_command (_("add marker"));
852 XMLNode &before = session->locations()->get_state();
853 session->locations()->add (location, true);
854 XMLNode &after = session->locations()->get_state();
855 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
856 session->commit_reversible_command ();
862 LocationUI::add_new_range()
867 nframes_t where = session->audible_frame();
868 session->locations()->next_available_name(rangename,"unnamed");
869 Location *location = new Location (where, where, rangename, Location::IsRangeMarker);
870 session->begin_reversible_command (_("add range marker"));
871 XMLNode &before = session->locations()->get_state();
872 session->locations()->add (location, true);
873 XMLNode &after = session->locations()->get_state();
874 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
875 session->commit_reversible_command ();
881 LocationUI::refresh_location_list_s (Change ignored)
883 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::refresh_location_list_s), ignored));
885 refresh_location_list ();
889 LocationUI::refresh_location_list ()
891 ENSURE_GUI_THREAD(mem_fun(*this, &LocationUI::refresh_location_list));
892 using namespace Box_Helpers;
894 // this is just too expensive to do when window is not shown
895 if (!is_visible()) return;
897 BoxList & loc_children = location_rows.children();
898 BoxList & range_children = range_rows.children();
900 loc_children.clear();
901 range_children.clear();
904 session->locations()->apply (*this, &LocationUI::map_locations);
910 LocationUI::set_session(ARDOUR::Session* sess)
912 ArdourDialog::set_session (sess);
915 session->locations()->changed.connect (mem_fun(*this, &LocationUI::refresh_location_list));
916 session->locations()->StateChanged.connect (mem_fun(*this, &LocationUI::refresh_location_list_s));
917 session->locations()->added.connect (mem_fun(*this, &LocationUI::location_added));
918 session->locations()->removed.connect (mem_fun(*this, &LocationUI::location_removed));
919 session->GoingAway.connect (mem_fun(*this, &LocationUI::session_gone));
921 refresh_location_list ();
925 LocationUI::session_gone()
927 ENSURE_GUI_THREAD(mem_fun(*this, &LocationUI::session_gone));
931 using namespace Box_Helpers;
932 BoxList & loc_children = location_rows.children();
933 BoxList & range_children = range_rows.children();
935 loc_children.clear();
936 range_children.clear();
938 loop_edit_row.set_session (0);
939 loop_edit_row.set_location (0);
941 punch_edit_row.set_session (0);
942 punch_edit_row.set_location (0);
944 ArdourDialog::session_gone ();
948 LocationUI::on_delete_event (GdkEventAny* ev)