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"
41 using namespace ARDOUR;
44 using namespace Gtkmm2ext;
46 LocationEditRow::LocationEditRow(Session * sess, Location * loc, int32_t num)
47 : location(0), session(0),
48 item_table (1, 6, false),
49 start_clock (X_("locationstart"), true, X_("LocationEditRowClock"), true, false),
50 end_clock (X_("locationend"), true, X_("LocationEditRowClock"), true, false),
51 length_clock (X_("locationlength"), true, X_("LocationEditRowClock"), true, false, true),
52 cd_check_button (_("CD")),
53 hide_check_button (_("Hide")),
54 scms_check_button (_("SCMS")),
55 preemph_check_button (_("Pre-Emphasis"))
58 i_am_the_modifier = 0;
60 start_go_button.set_image (*manage (new Image (Stock::JUMP_TO, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
61 end_go_button.set_image (*manage (new Image (Stock::JUMP_TO, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
62 remove_button.set_image (*manage (new Image (Stock::REMOVE, Gtk::ICON_SIZE_SMALL_TOOLBAR)));
64 number_label.set_name ("LocationEditNumberLabel");
65 name_label.set_name ("LocationEditNameLabel");
66 name_entry.set_name ("LocationEditNameEntry");
67 start_go_button.set_name ("LocationEditGoButton");
68 end_go_button.set_name ("LocationEditGoButton");
69 cd_check_button.set_name ("LocationEditCdButton");
70 hide_check_button.set_name ("LocationEditHideButton");
71 remove_button.set_name ("LocationEditRemoveButton");
72 isrc_label.set_name ("LocationEditNumberLabel");
73 isrc_entry.set_name ("LocationEditNameEntry");
74 scms_check_button.set_name ("LocationEditCdButton");
75 preemph_check_button.set_name ("LocationEditCdButton");
76 performer_label.set_name ("LocationEditNumberLabel");
77 performer_entry.set_name ("LocationEditNameEntry");
78 composer_label.set_name ("LocationEditNumberLabel");
79 composer_entry.set_name ("LocationEditNameEntry");
81 isrc_label.set_text ("ISRC: ");
82 isrc_label.set_size_request (30, -1);
83 performer_label.set_text ("Performer: ");
84 performer_label.set_size_request (60, -1);
85 composer_label.set_text ("Composer: ");
86 composer_label.set_size_request (60, -1);
88 isrc_entry.set_size_request (112, -1);
89 isrc_entry.set_max_length(12);
90 isrc_entry.set_editable (true);
92 performer_entry.set_size_request (100, -1);
93 performer_entry.set_editable (true);
95 composer_entry.set_size_request (100, -1);
96 composer_entry.set_editable (true);
98 name_label.set_alignment (0, 0.5);
100 cd_track_details_hbox.pack_start (isrc_label, false, false);
101 cd_track_details_hbox.pack_start (isrc_entry, false, false);
102 cd_track_details_hbox.pack_start (scms_check_button, false, false);
103 cd_track_details_hbox.pack_start (preemph_check_button, false, false);
104 cd_track_details_hbox.pack_start (performer_label, false, false);
105 cd_track_details_hbox.pack_start (performer_entry, true, true);
106 cd_track_details_hbox.pack_start (composer_label, false, false);
107 cd_track_details_hbox.pack_start (composer_entry, true, true);
109 isrc_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::isrc_entry_changed));
110 performer_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::performer_entry_changed));
111 composer_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::composer_entry_changed));
112 scms_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::scms_toggled));
113 preemph_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::preemph_toggled));
117 // start_hbox.pack_start (start_go_button, false, false);
118 start_hbox.pack_start (start_clock, false, false);
120 /* this is always in this location, no matter what the location is */
122 item_table.attach (start_hbox, 1, 2, 0, 1, FILL, FILL, 4, 0);
124 start_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocStart));
125 start_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocStart));
126 start_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocStart));
128 // end_hbox.pack_start (end_go_button, false, false);
129 end_hbox.pack_start (end_clock, false, false);
131 end_go_button.signal_clicked().connect(bind (mem_fun (*this, &LocationEditRow::go_button_pressed), LocEnd));
132 end_clock.ValueChanged.connect (bind (mem_fun (*this, &LocationEditRow::clock_changed), LocEnd));
133 end_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocEnd));
135 length_clock.ValueChanged.connect (bind ( mem_fun(*this, &LocationEditRow::clock_changed), LocLength));
136 length_clock.ChangeAborted.connect (bind (mem_fun (*this, &LocationEditRow::change_aborted), LocLength));
138 cd_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::cd_toggled));
139 hide_check_button.signal_toggled().connect(mem_fun(*this, &LocationEditRow::hide_toggled));
141 remove_button.signal_clicked().connect(mem_fun(*this, &LocationEditRow::remove_button_pressed));
143 pack_start(item_table, true, true);
149 LocationEditRow::~LocationEditRow()
152 start_changed_connection.disconnect();
153 end_changed_connection.disconnect();
154 name_changed_connection.disconnect();
155 changed_connection.disconnect();
156 flags_changed_connection.disconnect();
161 LocationEditRow::set_session (Session *sess)
165 if (!session) return;
167 start_clock.set_session (session);
168 end_clock.set_session (session);
169 length_clock.set_session (session);
174 LocationEditRow::set_number (int num)
179 number_label.set_text (string_compose ("%1", number));
184 LocationEditRow::set_location (Location *loc)
187 start_changed_connection.disconnect();
188 end_changed_connection.disconnect();
189 name_changed_connection.disconnect();
190 changed_connection.disconnect();
191 flags_changed_connection.disconnect();
196 if (!location) return;
198 if (!hide_check_button.get_parent()) {
199 item_table.attach (hide_check_button, 5, 6, 0, 1, FILL, Gtk::FILL, 4, 0);
201 hide_check_button.set_active (location->is_hidden());
203 if (location->is_auto_loop() || location-> is_auto_punch()) {
204 // use label instead of entry
206 name_label.set_text (location->name());
207 name_label.set_size_request (80, -1);
209 if (!name_label.get_parent()) {
210 item_table.attach (name_label, 0, 1, 0, 1, FILL, FILL, 4, 0);
217 name_entry.set_text (location->name());
218 name_entry.set_size_request (100, -1);
219 name_entry.set_editable (true);
220 name_entry.signal_changed().connect (mem_fun(*this, &LocationEditRow::name_entry_changed));
222 if (!name_entry.get_parent()) {
223 item_table.attach (name_entry, 0, 1, 0, 1, FILL | EXPAND, FILL, 4, 0);
227 if (!cd_check_button.get_parent()) {
228 item_table.attach (cd_check_button, 4, 5, 0, 1, FILL, FILL, 4, 0);
230 if (!remove_button.get_parent()) {
231 item_table.attach (remove_button, 6, 7, 0, 1, FILL, FILL, 4, 0);
234 if (location->is_end() || location->is_start()) {
235 remove_button.set_sensitive (false);
238 cd_check_button.set_active (location->is_cd_marker());
239 cd_check_button.show();
241 if (location->start() == session->current_start_frame()) {
242 cd_check_button.set_sensitive (false);
244 cd_check_button.set_sensitive (true);
247 hide_check_button.show();
250 start_clock.set (location->start(), true);
253 if (!location->is_mark()) {
254 if (!end_hbox.get_parent()) {
255 item_table.attach (end_hbox, 2, 3, 0, 1, FILL, FILL, 4, 0);
257 if (!length_clock.get_parent()) {
258 item_table.attach (length_clock, 3, 4, 0, 1, FILL, FILL, 4, 0);
261 end_clock.set (location->end(), true);
262 length_clock.set (location->length(), true);
264 end_go_button.show();
268 ARDOUR_UI::instance()->tooltips().set_tip (end_go_button, _("Jump to the end of this range"));
269 ARDOUR_UI::instance()->tooltips().set_tip (start_go_button, _("Jump to the start of this range"));
270 ARDOUR_UI::instance()->tooltips().set_tip (remove_button, _("Forget this range"));
271 ARDOUR_UI::instance()->tooltips().set_tip (start_clock, _("Start time"));
272 ARDOUR_UI::instance()->tooltips().set_tip (end_clock, _("End time"));
273 ARDOUR_UI::instance()->tooltips().set_tip (length_clock, _("Length"));
277 ARDOUR_UI::instance()->tooltips().set_tip (start_go_button, _("Jump to this marker"));
278 ARDOUR_UI::instance()->tooltips().set_tip (remove_button, _("Forget this marker"));
279 ARDOUR_UI::instance()->tooltips().set_tip (start_clock, _("Position"));
281 end_go_button.hide();
286 start_clock.set_sensitive (!location->locked());
287 end_clock.set_sensitive (!location->locked());
288 length_clock.set_sensitive (!location->locked());
290 start_changed_connection = location->start_changed.connect (mem_fun(*this, &LocationEditRow::start_changed));
291 end_changed_connection = location->end_changed.connect (mem_fun(*this, &LocationEditRow::end_changed));
292 name_changed_connection = location->name_changed.connect (mem_fun(*this, &LocationEditRow::name_changed));
293 changed_connection = location->changed.connect (mem_fun(*this, &LocationEditRow::location_changed));
294 flags_changed_connection = location->FlagsChanged.connect (mem_fun(*this, &LocationEditRow::flags_changed));
298 LocationEditRow::name_entry_changed ()
300 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::name_entry_changed));
301 if (i_am_the_modifier || !location) return;
303 location->set_name (name_entry.get_text());
308 LocationEditRow::isrc_entry_changed ()
310 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::isrc_entry_changed));
312 if (i_am_the_modifier || !location) return;
314 if (isrc_entry.get_text() != "" ) {
316 location->cd_info["isrc"] = isrc_entry.get_text();
319 location->cd_info.erase("isrc");
324 LocationEditRow::performer_entry_changed ()
326 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::performer_entry_changed));
328 if (i_am_the_modifier || !location) return;
330 if (performer_entry.get_text() != "") {
331 location->cd_info["performer"] = performer_entry.get_text();
333 location->cd_info.erase("performer");
338 LocationEditRow::composer_entry_changed ()
340 ENSURE_GUI_THREAD(mem_fun(*this, &LocationEditRow::composer_entry_changed));
342 if (i_am_the_modifier || !location) return;
344 if (composer_entry.get_text() != "") {
345 location->cd_info["composer"] = composer_entry.get_text();
347 location->cd_info.erase("composer");
353 LocationEditRow::go_button_pressed (LocationPart part)
355 if (!location) return;
359 ARDOUR_UI::instance()->do_transport_locate (location->start());
362 ARDOUR_UI::instance()->do_transport_locate (location->end());
370 LocationEditRow::clock_changed (LocationPart part)
372 if (i_am_the_modifier || !location) return;
376 location->set_start (start_clock.current_time());
379 location->set_end (end_clock.current_time());
382 location->set_end (location->start() + length_clock.current_duration());
390 LocationEditRow::change_aborted (LocationPart /*part*/)
392 if (i_am_the_modifier || !location) return;
394 set_location(location);
398 LocationEditRow::cd_toggled ()
400 if (i_am_the_modifier || !location) {
404 //if (cd_check_button.get_active() == location->is_cd_marker()) {
408 if (cd_check_button.get_active()) {
409 if (location->start() <= session->current_start_frame()) {
410 error << _("You cannot put a CD marker at the start of the session") << endmsg;
411 cd_check_button.set_active (false);
416 location->set_cd (cd_check_button.get_active(), this);
418 if (location->is_cd_marker() && !(location->is_mark())) {
420 if (location->cd_info.find("isrc") != location->cd_info.end()) {
421 isrc_entry.set_text(location->cd_info["isrc"]);
423 if (location->cd_info.find("performer") != location->cd_info.end()) {
424 performer_entry.set_text(location->cd_info["performer"]);
426 if (location->cd_info.find("composer") != location->cd_info.end()) {
427 composer_entry.set_text(location->cd_info["composer"]);
429 if (location->cd_info.find("scms") != location->cd_info.end()) {
430 scms_check_button.set_active(true);
432 if (location->cd_info.find("preemph") != location->cd_info.end()) {
433 preemph_check_button.set_active(true);
436 if (!cd_track_details_hbox.get_parent()) {
437 item_table.attach (cd_track_details_hbox, 0, 7, 1, 2, FILL | EXPAND, FILL, 4, 0);
439 // item_table.resize(2, 7);
440 cd_track_details_hbox.show_all();
442 } else if (cd_track_details_hbox.get_parent()){
444 item_table.remove (cd_track_details_hbox);
445 // item_table.resize(1, 7);
446 redraw_ranges(); /* EMIT_SIGNAL */
451 LocationEditRow::hide_toggled ()
453 if (i_am_the_modifier || !location) return;
455 location->set_hidden (hide_check_button.get_active(), this);
459 LocationEditRow::remove_button_pressed ()
461 if (!location) return;
463 remove_requested(location); /* EMIT_SIGNAL */
469 LocationEditRow::scms_toggled ()
471 if (i_am_the_modifier || !location) return;
473 if (scms_check_button.get_active()) {
474 location->cd_info["scms"] = "on";
476 location->cd_info.erase("scms");
482 LocationEditRow::preemph_toggled ()
484 if (i_am_the_modifier || !location) return;
486 if (preemph_check_button.get_active()) {
487 location->cd_info["preemph"] = "on";
489 location->cd_info.erase("preemph");
494 LocationEditRow::end_changed (ARDOUR::Location *loc)
496 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::end_changed), loc));
498 if (!location) return;
500 // update end and length
503 end_clock.set (location->end());
504 length_clock.set (location->length());
510 LocationEditRow::start_changed (ARDOUR::Location *loc)
512 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::start_changed), loc));
514 if (!location) return;
516 // update end and length
519 start_clock.set (location->start());
521 if (location->start() == session->current_start_frame()) {
522 cd_check_button.set_sensitive (false);
524 cd_check_button.set_sensitive (true);
531 LocationEditRow::name_changed (ARDOUR::Location *loc)
533 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::name_changed), loc));
535 if (!location) return;
537 // update end and length
540 name_entry.set_text(location->name());
541 name_label.set_text(location->name());
548 LocationEditRow::location_changed (ARDOUR::Location *loc)
550 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::location_changed), loc));
552 if (!location) return;
556 start_clock.set (location->start());
557 end_clock.set (location->end());
558 length_clock.set (location->length());
560 start_clock.set_sensitive (!location->locked());
561 end_clock.set_sensitive (!location->locked());
562 length_clock.set_sensitive (!location->locked());
569 LocationEditRow::flags_changed (ARDOUR::Location *loc, void *src)
571 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationEditRow::flags_changed), loc, src));
573 if (!location) return;
577 cd_check_button.set_active (location->is_cd_marker());
578 hide_check_button.set_active (location->is_hidden());
584 LocationEditRow::focus_name() {
585 name_entry.grab_focus();
589 LocationUI::LocationUI ()
591 , add_location_button (_("New Marker"))
592 , add_range_button (_("New Range"))
594 i_am_the_modifier = 0;
596 location_vpacker.set_spacing (5);
598 add_location_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON)));
599 add_range_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON)));
601 loop_punch_box.pack_start (loop_edit_row, false, false);
602 loop_punch_box.pack_start (punch_edit_row, false, false);
604 loop_punch_scroller.add (loop_punch_box);
605 loop_punch_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_NEVER);
606 loop_punch_scroller.set_shadow_type (Gtk::SHADOW_NONE);
608 location_vpacker.pack_start (loop_punch_scroller, false, false);
610 location_rows.set_name("LocationLocRows");
611 location_rows_scroller.add (location_rows);
612 location_rows_scroller.set_name ("LocationLocRowsScroller");
613 location_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
614 location_rows_scroller.set_size_request (-1, 130);
618 loc_frame_box.set_spacing (5);
619 loc_frame_box.set_border_width (5);
620 loc_frame_box.set_name("LocationFrameBox");
622 loc_frame_box.pack_start (location_rows_scroller, true, true);
624 add_location_button.set_name ("LocationAddLocationButton");
626 HBox* add_button_box = manage (new HBox);
628 // loc_frame_box.pack_start (add_location_button, false, false);
629 add_button_box->pack_start (add_location_button, true, true);
631 loc_frame.set_name ("LocationLocEditorFrame");
632 loc_frame.set_label (_("Markers (including CD index)"));
633 loc_frame.add (loc_frame_box);
634 loc_range_panes.pack1(loc_frame, true, false);
637 range_rows.set_name("LocationRangeRows");
638 range_rows_scroller.add (range_rows);
639 range_rows_scroller.set_name ("LocationRangeRowsScroller");
640 range_rows_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
641 range_rows_scroller.set_size_request (-1, 130);
643 range_frame_box.set_spacing (5);
644 range_frame_box.set_name("LocationFrameBox");
645 range_frame_box.set_border_width (5);
646 range_frame_box.pack_start (range_rows_scroller, true, true);
648 add_range_button.set_name ("LocationAddRangeButton");
649 //range_frame_box.pack_start (add_range_button, false, false);
651 add_button_box->pack_start (add_range_button, true, true);
653 range_frame.set_name ("LocationRangeEditorFrame");
654 range_frame.set_label (_("Ranges (including CD track ranges)"));
655 range_frame.add (range_frame_box);
656 loc_range_panes.pack2(range_frame, true, false);
657 location_vpacker.pack_start (loc_range_panes, true, true);
658 location_vpacker.pack_start (*add_button_box, false, false);
660 pack_start (location_vpacker, true, true);
662 add_location_button.signal_clicked().connect (mem_fun(*this, &LocationUI::add_new_location));
663 add_range_button.signal_clicked().connect (mem_fun(*this, &LocationUI::add_new_range));
668 LocationUI::~LocationUI()
673 LocationUI::do_location_remove (ARDOUR::Location *loc)
675 /* this is handled internally by Locations, but there's
676 no point saving state etc. when we know the marker
684 session->begin_reversible_command (_("remove marker"));
685 XMLNode &before = session->locations()->get_state();
686 session->locations()->remove (loc);
687 XMLNode &after = session->locations()->get_state();
688 session->add_command(new MementoCommand<Locations>(*(session->locations()), &before, &after));
689 session->commit_reversible_command ();
695 LocationUI::location_remove_requested (ARDOUR::Location *loc)
697 // must do this to prevent problems when destroying
698 // the effective sender of this event
700 Glib::signal_idle().connect (bind (mem_fun(*this, &LocationUI::do_location_remove), loc));
705 LocationUI::location_redraw_ranges ()
712 LocationUI::location_added (Location* location)
714 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::location_added), location));
716 if (location->is_auto_punch()) {
717 punch_edit_row.set_location(location);
719 else if (location->is_auto_loop()) {
720 loop_edit_row.set_location(location);
723 refresh_location_list ();
728 LocationUI::location_removed (Location* location)
730 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::location_removed), location));
732 if (location->is_auto_punch()) {
733 punch_edit_row.set_location(0);
735 else if (location->is_auto_loop()) {
736 loop_edit_row.set_location(0);
739 refresh_location_list ();
743 struct LocationSortByStart {
744 bool operator() (Location *a, Location *b) {
745 return a->start() < b->start();
750 LocationUI::map_locations (Locations::LocationList& locations)
752 Locations::LocationList::iterator i;
756 Locations::LocationList temp = locations;
757 LocationSortByStart cmp;
762 Box_Helpers::BoxList & loc_children = location_rows.children();
763 Box_Helpers::BoxList & range_children = range_rows.children();
764 LocationEditRow * erow;
766 for (n = 0, i = locations.begin(); i != locations.end(); ++n, ++i) {
770 if (location->is_mark()) {
772 erow = manage (new LocationEditRow(session, location, mark_n));
773 erow->remove_requested.connect (mem_fun(*this, &LocationUI::location_remove_requested));
774 erow->redraw_ranges.connect (mem_fun(*this, &LocationUI::location_redraw_ranges));
775 loc_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
776 if (location == newest_location) {
781 else if (location->is_auto_punch()) {
782 punch_edit_row.set_session (session);
783 punch_edit_row.set_location (location);
784 punch_edit_row.show_all();
786 else if (location->is_auto_loop()) {
787 loop_edit_row.set_session (session);
788 loop_edit_row.set_location (location);
789 loop_edit_row.show_all();
792 erow = manage (new LocationEditRow(session, location));
793 erow->remove_requested.connect (mem_fun(*this, &LocationUI::location_remove_requested));
794 range_children.push_back(Box_Helpers::Element(*erow, PACK_SHRINK, 1, PACK_START));
798 range_rows.show_all();
799 location_rows.show_all();
803 LocationUI::add_new_location()
808 nframes_t where = session->audible_frame();
809 session->locations()->next_available_name(markername,"mark");
810 Location *location = new Location (where, where, markername, Location::IsMark);
811 if (Config->get_name_new_markers()) {
812 newest_location = location;
814 session->begin_reversible_command (_("add marker"));
815 XMLNode &before = session->locations()->get_state();
816 session->locations()->add (location, true);
817 XMLNode &after = session->locations()->get_state();
818 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
819 session->commit_reversible_command ();
825 LocationUI::add_new_range()
830 nframes_t where = session->audible_frame();
831 session->locations()->next_available_name(rangename,"unnamed");
832 Location *location = new Location (where, where, rangename, Location::IsRangeMarker);
833 session->begin_reversible_command (_("add range marker"));
834 XMLNode &before = session->locations()->get_state();
835 session->locations()->add (location, true);
836 XMLNode &after = session->locations()->get_state();
837 session->add_command (new MementoCommand<Locations>(*(session->locations()), &before, &after));
838 session->commit_reversible_command ();
844 LocationUI::refresh_location_list_s (Change ignored)
846 ENSURE_GUI_THREAD(bind (mem_fun(*this, &LocationUI::refresh_location_list_s), ignored));
848 refresh_location_list ();
852 LocationUI::refresh_location_list ()
854 ENSURE_GUI_THREAD(mem_fun(*this, &LocationUI::refresh_location_list));
855 using namespace Box_Helpers;
857 // this is just too expensive to do when window is not shown
858 if (!is_visible()) return;
860 BoxList & loc_children = location_rows.children();
861 BoxList & range_children = range_rows.children();
863 loc_children.clear();
864 range_children.clear();
867 session->locations()->apply (*this, &LocationUI::map_locations);
873 LocationUI::set_session(ARDOUR::Session* s)
878 session->locations()->changed.connect (mem_fun(*this, &LocationUI::refresh_location_list));
879 session->locations()->StateChanged.connect (mem_fun(*this, &LocationUI::refresh_location_list_s));
880 session->locations()->added.connect (mem_fun(*this, &LocationUI::location_added));
881 session->locations()->removed.connect (mem_fun(*this, &LocationUI::location_removed));
882 session->GoingAway.connect (mem_fun(*this, &LocationUI::session_gone));
884 refresh_location_list ();
888 LocationUI::session_gone()
890 ENSURE_GUI_THREAD(mem_fun(*this, &LocationUI::session_gone));
892 using namespace Box_Helpers;
893 BoxList & loc_children = location_rows.children();
894 BoxList & range_children = range_rows.children();
896 loc_children.clear();
897 range_children.clear();
899 loop_edit_row.set_session (0);
900 loop_edit_row.set_location (0);
902 punch_edit_row.set_session (0);
903 punch_edit_row.set_location (0);
906 /*------------------------*/
908 LocationUIWindow::LocationUIWindow ()
909 : ArdourDialog ("locations dialog")
911 set_title (_("Locations"));
912 set_wmclass(X_("ardour_locations"), "Ardour");
913 set_name ("LocationWindow");
915 get_vbox()->pack_start (_ui);
918 LocationUIWindow::~LocationUIWindow()
923 LocationUIWindow::on_show()
925 _ui.refresh_location_list();
926 ArdourDialog::on_show();
930 LocationUIWindow::on_delete_event (GdkEventAny*)
937 LocationUIWindow::set_session (Session *s)
939 ArdourDialog::set_session (s);
942 s->GoingAway.connect (mem_fun (*this, &LocationUIWindow::session_gone));
946 LocationUIWindow::session_gone ()
949 ArdourDialog::session_gone ();