2 Copyright (C) 2000-2004 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.
24 #include <sigc++/bind.h>
26 #include <gtkmm2ext/gtk_ui.h>
27 #include <gtkmm2ext/utils.h>
28 #include <gtkmm2ext/choice.h>
29 #include <gtkmm2ext/utils.h>
30 #include <gtkmm2ext/stop_signal.h>
31 #include <gtkmm2ext/doi.h>
33 #include <ardour/ardour.h>
34 #include <ardour/session.h>
35 #include <ardour/audioengine.h>
36 #include <ardour/route.h>
37 #include <ardour/audio_track.h>
38 #include <ardour/diskstream.h>
39 #include <ardour/send.h>
40 #include <ardour/insert.h>
41 #include <ardour/ladspa_plugin.h>
42 #include <ardour/connection.h>
43 #include <ardour/session_connection.h>
45 #include "ardour_ui.h"
46 #include "ardour_dialog.h"
47 #include "ardour_message.h"
48 #include "public_editor.h"
49 #include "redirect_box.h"
51 #include "plugin_selector.h"
52 #include "route_redirect_selection.h"
55 #include "plugin_ui.h"
57 #include "io_selector.h"
59 #include "gui_thread.h"
64 using namespace ARDOUR;
66 using namespace Gtkmm2ext;
70 RedirectBox::RedirectBox (Placement pcmnt, Session& sess, Route& rt, PluginSelector &plugsel, RouteRedirectSelection & rsel, bool owner_is_mixer)
73 _owner_is_mixer (owner_is_mixer),
75 _plugin_selector(plugsel),
82 redirect_drag_in_progress = false;
84 redirect_display.set_name ("MixerRedirectSelector");
85 redirect_display.column_titles_active ();
86 redirect_display.set_reorderable (true);
87 redirect_display.set_button_actions (0, (GTK_BUTTON_SELECTS|GTK_BUTTON_DRAGS));
88 redirect_display.set_button_actions (1, 0);
89 redirect_display.set_button_actions (2, 0);
90 redirect_display.set_button_actions (3, 0);
91 redirect_display.drag_begin.connect (slot (*this, &RedirectBox::redirect_drag_begin));
92 redirect_display.drag_end.connect (slot (*this, &RedirectBox::redirect_drag_end));
93 redirect_display.set_size_request (-1, 48);
94 redirect_display.set_selection_mode (GTK_SELECTION_MULTIPLE);
95 redirect_display.set_shadow_type (Gtk::SHADOW_IN);
96 redirect_display.row_move.connect (slot (*this, &RedirectBox::redirects_reordered));
98 redirect_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
100 redirect_scroller.add (redirect_display);
101 redirect_eventbox.add (redirect_scroller);
102 pack_start (redirect_eventbox, true, true);
104 redirect_scroller.show ();
105 redirect_display.show ();
106 redirect_eventbox.show ();
109 _route.redirects_changed.connect (slot (*this, &RedirectBox::redirects_changed));
111 redirect_display.button_press_event.connect (slot (*this, &RedirectBox::redirect_button));
112 redirect_display.button_release_event.connect (slot (*this, &RedirectBox::redirect_button));
114 redirect_display.button_release_event.connect_after (slot (do_not_propagate));
115 _plugin_selector.hide.connect(slot(*this,&RedirectBox::disconnect_newplug));
117 redirect_display.click_column.connect (slot (*this, &RedirectBox::show_redirect_menu));
119 set_stuff_from_route ();
121 /* start off as a passthru strip. we'll correct this, if necessary,
122 in update_diskstream_display().
125 //set_name ("AudioTrackStripBase");
127 /* now force an update of all the various elements */
129 redirects_changed (0);
131 //add_events (Gdk::BUTTON_RELEASE_MASK);
134 RedirectBox::~RedirectBox ()
136 // GoingAway(); /* EMIT_SIGNAL */
141 RedirectBox::set_stuff_from_route ()
146 RedirectBox::set_title (const std::string & title)
148 redirect_display.column(0).set_title (title);
152 RedirectBox::set_title_shown (bool flag)
155 redirect_display.column_titles_show();
157 redirect_display.column_titles_hide();
163 RedirectBox::update()
165 redirects_changed(0);
170 RedirectBox::set_width (Width w)
177 redirects_changed(0);
182 RedirectBox::remove_redirect_gui (Redirect *redirect)
186 PortInsert *port_insert = 0;
188 if ((insert = dynamic_cast<Insert *> (redirect)) != 0) {
190 if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
191 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
192 port_insert->set_gui (0);
196 } else if ((send = dynamic_cast<Send *> (insert)) != 0) {
197 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
204 RedirectBox::build_send_action_menu ()
207 using namespace Menu_Helpers;
209 send_action_menu = new Menu;
210 send_action_menu->set_name ("ArdourContextMenu");
211 MenuList& items = send_action_menu->items();
213 items.push_back (MenuElem (_("New send"), slot (*this, &RedirectBox::new_send)));
214 items.push_back (MenuElem (_("Show send controls"), slot (*this, &RedirectBox::show_send_controls)));
218 RedirectBox::show_send_controls ()
224 RedirectBox::new_send ()
230 RedirectBox::show_redirect_menu (gint arg)
232 if (redirect_menu == 0) {
233 redirect_menu = build_redirect_menu (redirect_display);
236 redirect_menu->popup (1, 0);
240 RedirectBox::redirect_drag_begin (GdkDragContext *context)
242 redirect_drag_in_progress = true;
246 RedirectBox::redirect_drag_end (GdkDragContext *context)
248 redirect_drag_in_progress = false;
252 RedirectBox::redirect_button (GdkEventButton *ev)
256 CList *clist = &redirect_display;
258 if (clist->get_selection_info ((int)ev->x, (int)ev->y, &row, &col) != 1) {
261 redirect = reinterpret_cast<Redirect *> (clist->row (row).get_data ());
265 case GDK_BUTTON_PRESS:
268 case GDK_2BUTTON_PRESS:
269 if (ev->state != 0) {
272 /* might be edit event, see below */
275 case GDK_BUTTON_RELEASE:
276 if (redirect_drag_in_progress) {
277 // drag-n-drop reordering
278 return stop_signal (*clist, "button-release-event");
284 /* shouldn't be here, but gcc complains */
288 if (redirect && Keyboard::is_delete_event (ev)) {
290 Gtk::Main::idle.connect (bind (slot (*this, &RedirectBox::idle_delete_redirect), redirect));
293 } else if (redirect && (Keyboard::is_edit_event (ev) || ev->type == GDK_2BUTTON_PRESS)) {
295 if (_session.engine().connected()) {
296 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
297 edit_redirect (redirect);
301 } else if (Keyboard::is_context_menu_event (ev)) {
302 show_redirect_menu(0);
303 return stop_signal (*clist, "button-release-event");
306 switch (ev->button) {
309 using namespace CList_Helpers;
310 SelectionList& sel (redirect_display.selection());
311 bool selecting = true;
313 for (SelectionIterator i = sel.begin(); i != sel.end(); ++i) {
314 if ((*i).get_row_num() == row) {
315 // clicked row is not selected yet, so it is
316 // becoming selected now
323 RedirectSelected (redirect); // emit
326 RedirectUnselected (redirect); // emit
334 redirect->set_active (!redirect->active(), this);
350 RedirectBox::build_redirect_menu (CList& clist)
352 using namespace Menu_Helpers;
353 Menu * menu = new Menu;
354 menu->set_name ("ArdourContextMenu");
355 MenuList& items = menu->items();
356 menu->set_name ("ArdourContextMenu");
360 items.push_back (MenuElem (_("New Plugin ..."), slot (*this, &RedirectBox::choose_plugin)));
361 items.push_back (MenuElem (_("New Insert"), slot (*this, &RedirectBox::choose_insert)));
362 items.push_back (MenuElem (_("New Send ..."), slot (*this, &RedirectBox::choose_send)));
363 items.push_back (SeparatorElem());
364 items.push_back (MenuElem (_("Clear"), slot (*this, &RedirectBox::clear_redirects)));
365 items.push_back (SeparatorElem());
367 /* standard editing stuff */
369 items.push_back (MenuElem (_("Cut"), slot (*this, &RedirectBox::cut_redirects)));
370 selection_dependent_items.push_back (items.back());
371 items.push_back (MenuElem (_("Copy"), slot (*this, &RedirectBox::copy_redirects)));
372 selection_dependent_items.push_back (items.back());
373 items.push_back (MenuElem (_("Paste"), slot (*this, &RedirectBox::paste_redirects)));
374 redirect_paste_item = items.back();
376 items.push_back (SeparatorElem());
377 items.push_back (MenuElem (_("Rename"), slot (*this, &RedirectBox::rename_redirects)));
379 items.push_back (SeparatorElem());
380 items.push_back (MenuElem (_("Select all"), slot (*this, &RedirectBox::select_all_redirects)));
381 items.push_back (MenuElem (_("Deselect all"), slot (*this, &RedirectBox::deselect_all_redirects)));
384 Menu *select_sub_menu = manage (new Menu);
385 MenuList& sitems = select_sub_menu->items();
386 select_sub_menu->set_name ("ArdourContextMenu");
388 sitems.push_back (MenuElem (_("Plugins")));
389 sitems.push_back (MenuElem (_("Inserts")));
390 sitems.push_back (MenuElem (_("Sends")));
391 sitems.push_back (SeparatorElem());
393 items.push_back (MenuElem (_("Select all ..."), *select_sub_menu));
397 items.push_back (SeparatorElem());
398 items.push_back (MenuElem (_("Activate"), bind (slot (*this, &RedirectBox::for_selected_redirects),
399 &RedirectBox::activate_redirect)));
400 selection_dependent_items.push_back (items.back());
401 items.push_back (MenuElem (_("Deactivate"), bind (slot (*this, &RedirectBox::for_selected_redirects),
402 &RedirectBox::deactivate_redirect)));
403 selection_dependent_items.push_back (items.back());
404 items.push_back (SeparatorElem());
406 items.push_back (MenuElem (_("Activate All"), bind (slot (*this, &RedirectBox::all_redirects_active), true)));
407 items.push_back (MenuElem (_("Deactivate All"), bind (slot (*this, &RedirectBox::all_redirects_active), false)));
411 items.push_back (SeparatorElem());
412 items.push_back (MenuElem (_("Edit"), bind (slot (*this, &RedirectBox::for_selected_redirects),
413 &RedirectBox::edit_redirect)));
414 selection_dependent_items.push_back (items.back());
416 menu->map_event.connect (slot (*this, &RedirectBox::redirect_menu_map_handler));
422 RedirectBox::redirect_menu_map_handler (GdkEventAny *ev)
424 using namespace Menu_Helpers;
425 using namespace CList_Helpers;
427 Gtk::CList* clist = &redirect_display;
429 bool sensitive = !clist->selection().empty();
431 for (vector<MenuItem*>::iterator i = selection_dependent_items.begin(); i != selection_dependent_items.end(); ++i) {
432 (*i)->set_sensitive (sensitive);
435 redirect_paste_item->set_sensitive (!_rr_selection.redirects.empty());
440 RedirectBox::select_all_redirects ()
442 redirect_display.selection().all();
446 RedirectBox::deselect_all_redirects ()
448 redirect_display.selection().clear ();
452 RedirectBox::choose_plugin ()
454 show_plugin_selector();
458 RedirectBox::insert_plugin_chosen (Plugin *plugin)
462 Redirect *redirect = new PluginInsert (_session, *plugin, _placement);
464 redirect->active_changed.connect (slot (*this, &RedirectBox::show_redirect_active));
466 uint32_t err_streams;
468 if (_route.add_redirect (redirect, this, &err_streams)) {
469 wierd_plugin_dialog (*plugin, err_streams, _route);
476 RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, IO& io)
478 ArdourDialog dialog ("wierd plugin dialog");
480 Button button (_("OK"));
484 /* i hate this kind of code */
486 if (streams > p.get_info().n_inputs) {
487 label.set_text (compose (_(
488 "You attempted to add a plugin (%1).\n"
489 "The plugin has %2 inputs\n"
490 "but at the insertion point, there are\n"
491 "%3 active signal streams.\n"
493 "This makes no sense - you are throwing away\n"
494 "part of the signal."),
496 p.get_info().n_inputs,
498 } else if (streams < p.get_info().n_inputs) {
499 label.set_text (compose (_(
500 "You attempted to add a plugin (%1).\n"
501 "The plugin has %2 inputs\n"
502 "but at the insertion point there are\n"
503 "only %3 active signal streams.\n"
505 "This makes no sense - unless the plugin supports\n"
506 "side-chain inputs. A future version of Ardour will\n"
507 "support this type of configuration."),
509 p.get_info().n_inputs,
512 label.set_text (compose (_(
513 "You attempted to add a plugin (%1).\n"
515 "The I/O configuration doesn't make sense:\n"
517 "The plugin has %2 inputs and %3 outputs.\n"
518 "The track/bus has %4 inputs and %5 outputs.\n"
519 "The insertion point, has %6 active signals.\n"
521 "Ardour does not understand what to do in such situations.\n"),
523 p.get_info().n_inputs,
524 p.get_info().n_outputs,
530 button_box.pack_start (button, false, true);
532 vpacker.set_spacing (12);
533 vpacker.set_border_width (12);
534 vpacker.pack_start (label);
535 vpacker.pack_start (button_box);
537 button.signal_clicked().connect (bind (slot (dialog, &ArdourDialog::stop), 0));
539 dialog.add (vpacker);
540 dialog.set_name (X_("PluginIODialog"));
541 dialog.set_position (Gtk::WIN_POS_MOUSE);
542 dialog.set_modal (true);
546 dialog.get_window().set_decorations (GdkWMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
552 RedirectBox::choose_insert ()
554 Redirect *redirect = new PortInsert (_session, _placement);
555 redirect->active_changed.connect (slot (*this, &RedirectBox::show_redirect_active));
556 _route.add_redirect (redirect, this);
560 RedirectBox::choose_send ()
562 Send *send = new Send (_session, _placement);
564 /* XXX need redirect lock on route */
566 send->ensure_io (0, _route.max_redirect_outs(), false, this);
568 IOSelectorWindow *ios = new IOSelectorWindow (_session, *send, false, true);
571 ios->selector().Finished.connect (bind (slot (*this, &RedirectBox::send_io_finished), static_cast<Redirect*>(send), ios));
575 RedirectBox::send_io_finished (IOSelector::Result r, Redirect* redirect, IOSelectorWindow* ios)
578 case IOSelector::Cancelled:
582 case IOSelector::Accepted:
583 _route.add_redirect (redirect, this);
587 delete_when_idle (ios);
591 RedirectBox::disconnect_newplug ()
593 newplug_connection.disconnect();
596 RedirectBox::show_plugin_selector ()
598 newplug_connection = _plugin_selector.PluginCreated.connect (slot (*this,&RedirectBox::insert_plugin_chosen));
599 _plugin_selector.show_all ();
603 RedirectBox::redirects_changed (void *src)
605 ENSURE_GUI_THREAD(bind (slot (*this, &RedirectBox::redirects_changed), src));
607 redirect_display.freeze ();
608 redirect_display.clear ();
609 redirect_active_connections.clear ();
610 redirect_name_connections.clear ();
612 _route.foreach_redirect (this, &RedirectBox::add_redirect_to_display);
614 switch (_placement) {
616 build_redirect_tooltip(redirect_display, redirect_eventbox, _("Pre-fader inserts, sends & plugins:"));
619 build_redirect_tooltip(redirect_display, redirect_eventbox, _("Post-fader inserts, sends & plugins:"));
622 redirect_display.thaw ();
626 RedirectBox::add_redirect_to_display (Redirect *redirect)
628 const gchar *rowdata[1];
632 if (redirect->placement() != _placement) {
636 clist = &redirect_display;
638 string rname = redirect_name (*redirect);
639 rowdata[0] = rname.c_str();
640 clist->rows().push_back (rowdata);
641 row = clist->rows().size() - 1;
642 clist->row (row).set_data (redirect);
644 show_redirect_active (redirect, this);
646 redirect_active_connections.push_back
647 (redirect->active_changed.connect (slot (*this, &RedirectBox::show_redirect_active)));
648 redirect_name_connections.push_back
649 (redirect->name_changed.connect (bind (slot (*this, &RedirectBox::show_redirect_name), redirect)));
653 RedirectBox::redirect_name (Redirect& redirect)
658 if (!redirect.active()) {
662 if ((send = dynamic_cast<Send *> (&redirect)) != 0) {
666 /* grab the send name out of its overall name */
668 string::size_type lbracket, rbracket;
669 lbracket = send->name().find ('[');
670 rbracket = send->name().find (']');
674 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
677 name_display += short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
685 name_display += redirect.name();
688 name_display += short_version (redirect.name(), 5);
694 if (!redirect.active()) {
702 RedirectBox::build_redirect_tooltip (CList& clist, EventBox& box, string start)
704 CList_Helpers::RowIterator ri;
707 for (ri = clist.rows().begin(); ri != clist.rows().end(); ++ri) {
709 tip += clist.cell(ri->get_row_num(), 0).get_text();
711 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
715 RedirectBox::show_redirect_name (void* src, Redirect *redirect)
717 ENSURE_GUI_THREAD(bind (slot (*this, &RedirectBox::show_redirect_name), src, redirect));
719 show_redirect_active (redirect, src);
723 RedirectBox::show_redirect_active (Redirect *redirect, void *src)
725 ENSURE_GUI_THREAD(bind (slot (*this, &RedirectBox::show_redirect_active), redirect, src));
727 CList_Helpers::RowIterator ri;
730 if ((ri = redirect_display.rows().find_data (redirect)) == redirect_display.rows().end()) {
734 clist = &redirect_display;
736 clist->cell(ri->get_row_num(), 0).set_text (redirect_name (*redirect));
738 if (redirect->active()) {
746 RedirectBox::redirects_reordered (gint src, gint dst)
748 /* this is called before the reorder has been done, so just queue
749 something for idle time.
752 Gtk::Main::idle.connect (slot (*this, &RedirectBox::compute_redirect_sort_keys));
756 RedirectBox::compute_redirect_sort_keys ()
758 CList_Helpers::RowList::iterator i;
763 for (i = redirect_display.rows().begin(); i != redirect_display.rows().end(); ++i) {
764 Redirect *redirect = reinterpret_cast<Redirect*> (i->get_data());
765 redirect->set_sort_key (sort_key, this);
769 if (_route.sort_redirects ()) {
771 redirects_changed (0);
773 /* now tell them about the problem */
775 ArdourDialog dialog ("wierd plugin dialog");
777 Button button (_("OK"));
782 You cannot reorder this set of redirects\n\
783 in that way because the inputs and\n\
784 outputs do not work correctly."));
786 button_box.pack_start (button, false, true);
788 vpacker.set_spacing (12);
789 vpacker.set_border_width (12);
790 vpacker.pack_start (label);
791 vpacker.pack_start (button_box);
793 button.signal_clicked().connect (bind (slot (dialog, &ArdourDialog::stop), 0));
795 dialog.add (vpacker);
796 dialog.set_name (X_("PluginIODialog"));
797 dialog.set_position (Gtk::WIN_POS_MOUSE);
798 dialog.set_modal (true);
802 dialog.get_window().set_decorations (GdkWMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
811 RedirectBox::rename_redirects ()
813 vector<Redirect*> to_be_renamed;
815 get_selected_redirects (to_be_renamed);
817 if (to_be_renamed.empty()) {
821 for (vector<Redirect*>::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
822 rename_redirect (*i);
827 RedirectBox::cut_redirects ()
829 vector<Redirect*> to_be_removed;
831 get_selected_redirects (to_be_removed);
833 if (to_be_removed.empty()) {
837 /* this essentially transfers ownership of the redirect
838 of the redirect from the route to the mixer
842 _rr_selection.set (to_be_removed);
844 for (vector<Redirect*>::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
846 void* gui = (*i)->get_gui ();
849 static_cast<Gtk::Widget*>(gui)->hide ();
852 if (_route.remove_redirect (*i, this)) {
854 _rr_selection.remove (*i);
861 RedirectBox::copy_redirects ()
863 vector<Redirect*> to_be_copied;
864 vector<Redirect*> copies;
866 get_selected_redirects (to_be_copied);
868 if (to_be_copied.empty()) {
872 for (vector<Redirect*>::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
873 copies.push_back (Redirect::clone (**i));
876 _rr_selection.set (copies);
880 RedirectBox::idle_delete_redirect (Redirect *redirect)
882 /* NOT copied to _mixer.selection() */
884 if (_route.remove_redirect (redirect, this)) {
894 RedirectBox::rename_redirect (Redirect* redirect)
896 ArdourDialog dialog ("rename redirect dialog");
900 Button ok_button (_("OK"));
901 Button cancel_button (_("Cancel"));
903 dialog.set_title (_("ardour: rename redirect"));
904 dialog.set_name ("RedirectRenameWindow");
905 dialog.set_size_request (300, -1);
906 dialog.set_position (Gtk::WIN_POS_MOUSE);
907 dialog.set_modal (true);
909 vbox.set_border_width (12);
910 vbox.set_spacing (12);
911 vbox.pack_start (entry, false, false);
912 vbox.pack_start (hbox, false, false);
913 hbox.pack_start (ok_button);
914 hbox.pack_start (cancel_button);
918 entry.set_name ("RedirectNameDisplay");
919 entry.set_text (redirect->name());
920 entry.select_region (0, -1);
923 ok_button.set_name ("EditorGTKButton");
924 cancel_button.set_name ("EditorGTKButton");
926 entry.activate.connect (bind (slot (dialog, &ArdourDialog::stop), 1));
927 cancel_button.signal_clicked().connect (bind (slot (dialog, &ArdourDialog::stop), -1));
928 ok_button.signal_clicked().connect (bind (slot (dialog, &ArdourDialog::stop), 1));
932 dialog.set_keyboard_input (true);
935 if (dialog.run_status() == 1) {
936 redirect->set_name (entry.get_text(), this);
941 RedirectBox::cut_redirect (Redirect *redirect)
943 /* this essentially transfers ownership of the redirect
944 of the redirect from the route to the mixer
948 _rr_selection.add (redirect);
950 void* gui = redirect->get_gui ();
953 static_cast<Gtk::Widget*>(gui)->hide ();
956 if (_route.remove_redirect (redirect, this)) {
957 _rr_selection.remove (redirect);
962 RedirectBox::copy_redirect (Redirect *redirect)
964 Redirect* copy = Redirect::clone (*redirect);
965 _rr_selection.add (copy);
969 RedirectBox::paste_redirects ()
971 if (_rr_selection.redirects.empty()) {
975 RedirectSelection& sel (_rr_selection.redirects);
976 list<Redirect*> others;
978 for (list<Redirect*>::iterator i = sel.begin(); i != sel.end(); ++i) {
980 Redirect* copy = Redirect::clone (**i);
982 copy->set_placement (_placement, this);
983 others.push_back (copy);
986 if (_route.add_redirects (others, this)) {
987 for (list<Redirect*>::iterator i = others.begin(); i != others.end(); ++i) {
992 "Copying the set of redirects on the clipboard failed,\n\
993 probably because the I/O configuration of the plugins\n\
994 could not match the configuration of this track.");
995 ArdourMessage am (0, X_("bad redirect copy dialog"), msg);
1000 RedirectBox::activate_redirect (Redirect *r)
1002 r->set_active (true, 0);
1006 RedirectBox::deactivate_redirect (Redirect *r)
1008 r->set_active (false, 0);
1012 RedirectBox::get_selected_redirects (vector<Redirect*>& redirects)
1014 using namespace CList_Helpers;
1015 SelectionList& sel (redirect_display.selection());
1017 for (SelectionIterator i = sel.begin(); i != sel.end(); ++i) {
1018 Redirect* redirect = reinterpret_cast<Redirect *> ((*i).get_data ());
1019 redirects.push_back (redirect);
1024 RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(Redirect*))
1026 using namespace CList_Helpers;
1027 SelectionList& sel (redirect_display.selection());
1029 for (SelectionIterator i = sel.begin(); i != sel.end(); ++i) {
1030 Redirect* redirect = reinterpret_cast<Redirect *> ((*i).get_data ());
1031 (this->*pmf)(redirect);
1036 RedirectBox::clone_redirects ()
1038 RouteSelection& routes (_rr_selection.routes);
1040 if (!routes.empty()) {
1041 if (_route.copy_redirects (*routes.front(), _placement)) {
1043 "Copying the set of redirects on the clipboard failed,\n\
1044 probably because the I/O configuration of the plugins\n\
1045 could not match the configuration of this track.");
1046 ArdourMessage am (0, X_("bad redirect copy dialog"), msg);
1052 RedirectBox::all_redirects_active (bool state)
1054 _route.all_redirects_active (state);
1058 RedirectBox::clear_redirects()
1061 vector<string> choices;
1063 if (dynamic_cast<AudioTrack*>(&_route) != 0) {
1064 prompt = _("Do you really want to remove all redirects from this track?\n"
1065 "(this cannot be undone)");
1067 prompt = _("Do you really want to remove all redirects from this bus?\n"
1068 "(this cannot be undone)");
1071 choices.push_back (_("Yes, remove them all"));
1072 choices.push_back (_("Cancel"));
1074 Gtkmm2ext::Choice prompter (prompt, choices);
1076 prompter.chosen.connect (Gtk::Main::quit.slot());
1077 prompter.show_all ();
1081 if (prompter.get_choice() == 0) {
1082 _route.clear_redirects (this);
1088 RedirectBox::edit_redirect (Redirect* redirect)
1092 if (dynamic_cast<AudioTrack*>(&_route) != 0) {
1094 if (dynamic_cast<AudioTrack*> (&_route)->freeze_state() == AudioTrack::Frozen) {
1099 if ((insert = dynamic_cast<Insert *> (redirect)) == 0) {
1103 if (!_session.engine().connected()) {
1107 Send *send = dynamic_cast<Send*> (redirect);
1109 SendUIWindow *send_ui;
1111 if (send->get_gui() == 0) {
1114 title = compose(_("ardour: %1"), send->name());
1116 send_ui = new SendUIWindow (*send, _session);
1117 send_ui->set_title (title);
1118 send->set_gui (send_ui);
1121 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
1124 if (send_ui->is_visible()) {
1125 send_ui->get_window().raise ();
1127 send_ui->show_all ();
1134 PluginInsert *plugin_insert;
1135 PortInsert *port_insert;
1137 if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) {
1139 PluginUIWindow *plugin_ui;
1141 if (plugin_insert->get_gui() == 0) {
1144 string maker = plugin_insert->plugin().maker();
1145 string::size_type email_pos;
1147 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1148 maker = maker.substr (0, email_pos - 1);
1151 if (maker.length() > 32) {
1152 maker = maker.substr (0, 32);
1156 title = compose(_("ardour: %1: %2 (by %3)"), _route.name(), plugin_insert->name(), maker);
1158 plugin_ui = new PluginUIWindow (_session.engine(), *plugin_insert);
1159 if (_owner_is_mixer) {
1160 ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui);
1162 ARDOUR_UI::instance()->the_editor().ensure_float (*plugin_ui);
1164 plugin_ui->set_title (title);
1165 plugin_insert->set_gui (plugin_ui);
1168 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
1171 if (plugin_ui->is_visible()) {
1172 plugin_ui->get_window().raise ();
1174 plugin_ui->show_all ();
1177 } else if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
1179 if (!_session.engine().connected()) {
1180 ArdourMessage msg (NULL, "nojackdialog", _("Not connected to JACK - no I/O changes are possible"));
1184 PortInsertWindow *io_selector;
1186 if (port_insert->get_gui() == 0) {
1187 io_selector = new PortInsertWindow (_session, *port_insert);
1188 port_insert->set_gui (io_selector);
1191 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1194 if (io_selector->is_visible()) {
1195 io_selector->get_window().raise ();
1197 io_selector->show_all ();