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),
77 //redirect_display (1)
82 redirect_drag_in_progress = false;
84 model = ListStore::create(columns);
85 selection = redirect_display.get_selection();
86 selection->set_mode (Gtk::SELECTION_MULTIPLE);
87 redirect_display.set_model (model);
88 redirect_display.append_column (NULL, columns.text);
89 redirect_display.set_name ("MixerRedirectSelector");
90 redirect_display.set_headers_visible (false);
91 redirect_display.set_reorderable (true);
92 redirect_display.set_size_request (-1, 48);
93 redirect_display.add_object_drag (columns.redirect.index(), "redirects");
94 redirect_display.signal_object_drop.connect (mem_fun (*this, &RedirectBox::object_drop));
96 // Does this adequately replace the drag start/stop signal handlers?
97 model->signal_rows_reordered().connect (mem_fun (*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 (mem_fun(*this, &RedirectBox::redirects_changed));
111 redirect_display.signal_button_press_event().connect (mem_fun(*this, &RedirectBox::redirect_button));
112 redirect_display.signal_button_release_event().connect (mem_fun(*this, &RedirectBox::redirect_button));
114 //redirect_display.signal_button_release_event().connect_after (ptr_fun (do_not_propagate));
115 //_plugin_selector.hide.connect(mem_fun(*this,&RedirectBox::disconnect_newplug));
116 set_stuff_from_route ();
118 /* start off as a passthru strip. we'll correct this, if necessary,
119 in update_diskstream_display().
122 //set_name ("AudioTrackStripBase");
124 /* now force an update of all the various elements */
126 redirects_changed (0);
128 //add_events (Gdk::BUTTON_RELEASE_MASK);
131 RedirectBox::~RedirectBox ()
133 // GoingAway(); /* EMIT_SIGNAL */
138 RedirectBox::object_drop (string type, uint32_t cnt, void** ptr)
140 if (type != "redirects") {
146 RedirectBox::set_stuff_from_route ()
151 RedirectBox::set_title (const std::string & title)
153 redirect_display.get_column(0)->set_title (title);
157 RedirectBox::set_title_shown (bool flag)
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"), mem_fun(*this, &RedirectBox::new_send)));
214 items.push_back (MenuElem (_("Show send controls"), mem_fun(*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 ();
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)
255 TreeModel::Row row = *(redirect_display.get_selection()->get_selected());
256 redirect = row[columns.redirect];
259 case GDK_BUTTON_PRESS:
260 if (ev->button == 3) {
261 show_redirect_menu (0); // Handle the context-click menu here as well
267 case GDK_2BUTTON_PRESS:
268 if (ev->state != 0) {
271 /* might be edit event, see below */
274 case GDK_BUTTON_RELEASE:
278 /* shouldn't be here, but gcc complains */
282 if (redirect && Keyboard::is_delete_event (ev)) {
284 Glib::signal_idle().connect (bind (mem_fun(*this, &RedirectBox::idle_delete_redirect), redirect));
287 } else if (redirect && (Keyboard::is_edit_event (ev) || ev->type == GDK_2BUTTON_PRESS)) {
289 if (_session.engine().connected()) {
290 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
291 edit_redirect (redirect);
295 } else if (Keyboard::is_context_menu_event (ev)) {
296 show_redirect_menu(0);
297 return TRUE; //stop_signal (*clist, "button-release-event");
300 switch (ev->button) {
307 redirect->set_active (!redirect->active(), this);
323 RedirectBox::build_redirect_menu ()
325 popup_act_grp = Gtk::ActionGroup::create();
329 popup_act_grp->add (Gtk::Action::create("newplugin", _("New Plugin ...")), mem_fun(*this, &RedirectBox::choose_plugin));
330 popup_act_grp->add (Gtk::Action::create("newinsert", _("New Insert")), mem_fun(*this, &RedirectBox::choose_insert));
331 popup_act_grp->add (Gtk::Action::create("newsend", _("New Send ...")), mem_fun(*this, &RedirectBox::choose_send));
332 popup_act_grp->add (Gtk::Action::create("clear", _("Clear")), mem_fun(*this, &RedirectBox::clear_redirects));
334 /* standard editing stuff */
336 popup_act_grp->add (Gtk::Action::create("cut", _("Cut")), mem_fun(*this, &RedirectBox::cut_redirects));
337 popup_act_grp->add (Gtk::Action::create("copy", _("Copy")), mem_fun(*this, &RedirectBox::copy_redirects));
338 popup_act_grp->add (Gtk::Action::create("paste", _("Paste")), mem_fun(*this, &RedirectBox::paste_redirects));
339 popup_act_grp->add (Gtk::Action::create("rename", _("Rename")), mem_fun(*this, &RedirectBox::rename_redirects));
340 popup_act_grp->add (Gtk::Action::create("selectall", _("Select All")), mem_fun(*this, &RedirectBox::select_all_redirects));
341 popup_act_grp->add (Gtk::Action::create("deselectall", _("Deselect All")), mem_fun(*this, &RedirectBox::deselect_all_redirects));
345 popup_act_grp->add (Gtk::Action::create("activate", _("Activate")), bind (mem_fun(*this, &RedirectBox::for_selected_redirects), &RedirectBox::activate_redirect));
346 popup_act_grp->add (Gtk::Action::create("deactivate", _("Deactivate")), bind (mem_fun(*this, &RedirectBox::for_selected_redirects), &RedirectBox::deactivate_redirect));
347 popup_act_grp->add (Gtk::Action::create("activateall", _("Activate All")), bind (mem_fun(*this, &RedirectBox::all_redirects_active), true));
348 popup_act_grp->add (Gtk::Action::create("deactivateall", _("Deactivate All")), bind (mem_fun(*this, &RedirectBox::all_redirects_active), false));
352 popup_act_grp->add (Gtk::Action::create("edit", _("Edit")), bind (mem_fun(*this, &RedirectBox::for_selected_redirects), &RedirectBox::edit_redirect));
354 selection_dependent_items.push_back (popup_act_grp->get_action("cut"));
355 selection_dependent_items.push_back (popup_act_grp->get_action("copy"));
356 selection_dependent_items.push_back (popup_act_grp->get_action("rename"));
357 selection_dependent_items.push_back (popup_act_grp->get_action("activate"));
358 selection_dependent_items.push_back (popup_act_grp->get_action("deactivate"));
359 selection_dependent_items.push_back (popup_act_grp->get_action("edit"));
361 popup_ui_mgr = Gtk::UIManager::create();
362 popup_ui_mgr->insert_action_group(popup_act_grp);
366 Glib::ustring ui_info =
368 " <popup name='redirectmenu'>"
369 " <menuitem action='newplugin'/>"
370 " <menuitem action='newinsert'/>"
371 " <menuitem action='newsend'/>"
373 " <menuitem action='clear'/>"
375 " <menuitem action='cut'/>"
376 " <menuitem action='copy'/>"
377 " <menuitem action='paste'/>"
379 " <menuitem action='rename'/>"
381 " <menuitem action='selectall'/>"
382 " <menuitem action='deselectall'/>"
384 " <menuitem action='activate'/>"
385 " <menuitem action='deactivate'/>"
387 " <menuitem action='activateall'/>"
388 " <menuitem action='deactivateall'/>"
390 " <menuitem action='edit'/>"
393 popup_ui_mgr->add_ui_from_string(ui_info);
395 } catch(const Glib::Error& ex) {
396 std::cerr << "building menus failed: " << ex.what();
399 redirect_menu = dynamic_cast<Gtk::Menu*>( popup_ui_mgr->get_widget("/redirectmenu") );
400 redirect_menu->signal_map_event().connect (mem_fun(*this, &RedirectBox::redirect_menu_map_handler));
401 redirect_menu->set_name ("ArdourContextMenu");
403 return redirect_menu;
407 RedirectBox::redirect_menu_map_handler (GdkEventAny *ev)
409 bool sensitive = (redirect_display.get_selection()->count_selected_rows()) ? true : false;
411 for (vector<Glib::RefPtr<Gtk::Action> >::iterator i = selection_dependent_items.begin(); i != selection_dependent_items.end(); ++i) {
412 (*i)->set_sensitive (sensitive);
415 popup_act_grp->get_action("paste")->set_sensitive (!_rr_selection.redirects.empty());
420 RedirectBox::select_all_redirects ()
422 redirect_display.get_selection()->select_all();
426 RedirectBox::deselect_all_redirects ()
428 redirect_display.get_selection()->unselect_all();
432 RedirectBox::choose_plugin ()
434 show_plugin_selector();
438 RedirectBox::insert_plugin_chosen (Plugin *plugin)
442 Redirect *redirect = new PluginInsert (_session, *plugin, _placement);
444 redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active));
446 uint32_t err_streams;
448 if (_route.add_redirect (redirect, this, &err_streams)) {
449 wierd_plugin_dialog (*plugin, err_streams, _route);
456 RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, IO& io)
458 ArdourDialog dialog ("wierd plugin dialog");
460 Button button (_("OK"));
464 /* i hate this kind of code */
466 if (streams > p.get_info().n_inputs) {
467 label.set_text (string_compose (_(
468 "You attempted to add a plugin (%1).\n"
469 "The plugin has %2 inputs\n"
470 "but at the insertion point, there are\n"
471 "%3 active signal streams.\n"
473 "This makes no sense - you are throwing away\n"
474 "part of the signal."),
476 p.get_info().n_inputs,
478 } else if (streams < p.get_info().n_inputs) {
479 label.set_text (string_compose (_(
480 "You attempted to add a plugin (%1).\n"
481 "The plugin has %2 inputs\n"
482 "but at the insertion point there are\n"
483 "only %3 active signal streams.\n"
485 "This makes no sense - unless the plugin supports\n"
486 "side-chain inputs. A future version of Ardour will\n"
487 "support this type of configuration."),
489 p.get_info().n_inputs,
492 label.set_text (string_compose (_(
493 "You attempted to add a plugin (%1).\n"
495 "The I/O configuration doesn't make sense:\n"
497 "The plugin has %2 inputs and %3 outputs.\n"
498 "The track/bus has %4 inputs and %5 outputs.\n"
499 "The insertion point, has %6 active signals.\n"
501 "Ardour does not understand what to do in such situations.\n"),
503 p.get_info().n_inputs,
504 p.get_info().n_outputs,
510 button_box.pack_start (button, false, true);
512 vpacker.set_spacing (12);
513 vpacker.set_border_width (12);
514 vpacker.pack_start (label);
515 vpacker.pack_start (button_box);
517 button.signal_clicked().connect (bind (mem_fun (dialog, &ArdourDialog::stop), 0));
519 dialog.add (vpacker);
520 dialog.set_name (X_("PluginIODialog"));
521 dialog.set_position (Gtk::WIN_POS_MOUSE);
522 dialog.set_modal (true);
527 //dialog.get_window()->set_decorations (Gdk::WMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
533 RedirectBox::choose_insert ()
535 Redirect *redirect = new PortInsert (_session, _placement);
536 redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active));
537 _route.add_redirect (redirect, this);
541 RedirectBox::choose_send ()
543 Send *send = new Send (_session, _placement);
545 /* XXX need redirect lock on route */
547 send->ensure_io (0, _route.max_redirect_outs(), false, this);
549 IOSelectorWindow *ios = new IOSelectorWindow (_session, *send, false, true);
552 ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), static_cast<Redirect*>(send), ios));
556 RedirectBox::send_io_finished (IOSelector::Result r, Redirect* redirect, IOSelectorWindow* ios)
559 case IOSelector::Cancelled:
563 case IOSelector::Accepted:
564 _route.add_redirect (redirect, this);
568 delete_when_idle (ios);
572 RedirectBox::disconnect_newplug ()
574 newplug_connection.disconnect();
577 RedirectBox::show_plugin_selector ()
579 newplug_connection = _plugin_selector.PluginCreated.connect (mem_fun(*this,&RedirectBox::insert_plugin_chosen));
580 _plugin_selector.show_all ();
584 RedirectBox::redirects_changed (void *src)
586 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::redirects_changed), src));
588 //redirect_display.freeze ();
590 redirect_active_connections.clear ();
591 redirect_name_connections.clear ();
593 _route.foreach_redirect (this, &RedirectBox::add_redirect_to_display);
595 switch (_placement) {
597 build_redirect_tooltip(redirect_eventbox, _("Pre-fader inserts, sends & plugins:"));
600 build_redirect_tooltip(redirect_eventbox, _("Post-fader inserts, sends & plugins:"));
603 //redirect_display.thaw ();
607 RedirectBox::add_redirect_to_display (Redirect *redirect)
609 if (redirect->placement() != _placement) {
613 Gtk::TreeModel::Row row = *(model->append());
614 row[columns.text] = redirect_name (*redirect);
615 row[columns.redirect] = redirect;
617 show_redirect_active (redirect, this);
619 redirect_active_connections.push_back (redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active)));
620 redirect_name_connections.push_back (redirect->name_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_name), redirect)));
624 RedirectBox::redirect_name (Redirect& redirect)
629 if (!redirect.active()) {
633 if ((send = dynamic_cast<Send *> (&redirect)) != 0) {
637 /* grab the send name out of its overall name */
639 string::size_type lbracket, rbracket;
640 lbracket = send->name().find ('[');
641 rbracket = send->name().find (']');
645 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
648 name_display += short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
656 name_display += redirect.name();
659 name_display += short_version (redirect.name(), 5);
665 if (!redirect.active()) {
673 RedirectBox::build_redirect_tooltip (EventBox& box, string start)
677 Gtk::TreeModel::Children children = model->children();
678 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
679 Gtk::TreeModel::Row row = *iter;
681 tip += row[columns.text];
683 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
687 RedirectBox::show_redirect_name (void* src, Redirect *redirect)
689 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_name), src, redirect));
691 show_redirect_active (redirect, src);
695 RedirectBox::show_redirect_active (Redirect *redirect, void *src)
697 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_active), redirect, src));
699 Gtk::TreeModel::Children children = model->children();
700 Gtk::TreeModel::Children::iterator iter = children.begin();
702 while( iter != children.end())
704 if ((*iter)[columns.redirect] == redirect)
709 (*iter)[columns.text] = redirect_name (*redirect);
711 if (redirect->active()) {
712 redirect_display.get_selection()->select (iter);
714 redirect_display.get_selection()->unselect (iter);
719 RedirectBox::redirects_reordered (const TreeModel::Path& path,const TreeModel::iterator& iter ,int* hmm)
721 /* this is called before the reorder has been done, so just queue
722 something for idle time.
725 Glib::signal_idle().connect (mem_fun(*this, &RedirectBox::compute_redirect_sort_keys));
729 RedirectBox::compute_redirect_sort_keys ()
731 uint32_t sort_key = 0;
732 Gtk::TreeModel::Children children = model->children();
734 for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
735 Redirect *redirect = (*iter)[columns.redirect];
736 redirect->set_sort_key (sort_key, this);
740 if (_route.sort_redirects ()) {
742 redirects_changed (0);
744 /* now tell them about the problem */
746 ArdourDialog dialog ("wierd plugin dialog");
748 Button button (_("OK"));
753 You cannot reorder this set of redirects\n\
754 in that way because the inputs and\n\
755 outputs do not work correctly."));
757 button_box.pack_start (button, false, true);
759 vpacker.set_spacing (12);
760 vpacker.set_border_width (12);
761 vpacker.pack_start (label);
762 vpacker.pack_start (button_box);
764 button.signal_clicked().connect (bind (mem_fun (dialog, &ArdourDialog::stop), 0));
766 dialog.add (vpacker);
767 dialog.set_name (X_("PluginIODialog"));
768 dialog.set_position (Gtk::WIN_POS_MOUSE);
769 dialog.set_modal (true);
774 //dialog.get_window()->set_decorations (Gdk::WMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
783 RedirectBox::rename_redirects ()
785 vector<Redirect*> to_be_renamed;
787 get_selected_redirects (to_be_renamed);
789 if (to_be_renamed.empty()) {
793 for (vector<Redirect*>::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
794 rename_redirect (*i);
799 RedirectBox::cut_redirects ()
801 vector<Redirect*> to_be_removed;
803 get_selected_redirects (to_be_removed);
805 if (to_be_removed.empty()) {
809 /* this essentially transfers ownership of the redirect
810 of the redirect from the route to the mixer
814 _rr_selection.set (to_be_removed);
816 for (vector<Redirect*>::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
818 void* gui = (*i)->get_gui ();
821 static_cast<Gtk::Widget*>(gui)->hide ();
824 if (_route.remove_redirect (*i, this)) {
826 _rr_selection.remove (*i);
833 RedirectBox::copy_redirects ()
835 vector<Redirect*> to_be_copied;
836 vector<Redirect*> copies;
838 get_selected_redirects (to_be_copied);
840 if (to_be_copied.empty()) {
844 for (vector<Redirect*>::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
845 copies.push_back (Redirect::clone (**i));
848 _rr_selection.set (copies);
852 RedirectBox::idle_delete_redirect (Redirect *redirect)
854 /* NOT copied to _mixer.selection() */
856 if (_route.remove_redirect (redirect, this)) {
866 RedirectBox::rename_redirect (Redirect* redirect)
868 ArdourDialog dialog ("rename redirect dialog");
872 Button ok_button (_("OK"));
873 Button cancel_button (_("Cancel"));
875 dialog.set_title (_("ardour: rename redirect"));
876 dialog.set_name ("RedirectRenameWindow");
877 dialog.set_size_request (300, -1);
878 dialog.set_position (Gtk::WIN_POS_MOUSE);
879 dialog.set_modal (true);
881 vbox.set_border_width (12);
882 vbox.set_spacing (12);
883 vbox.pack_start (entry, false, false);
884 vbox.pack_start (hbox, false, false);
885 hbox.pack_start (ok_button);
886 hbox.pack_start (cancel_button);
890 entry.set_name ("RedirectNameDisplay");
891 entry.set_text (redirect->name());
892 entry.select_region (0, -1);
895 ok_button.set_name ("EditorGTKButton");
896 cancel_button.set_name ("EditorGTKButton");
898 entry.signal_activate().connect (bind (mem_fun (dialog, &ArdourDialog::stop), 1));
899 cancel_button.signal_clicked().connect (bind (mem_fun (dialog, &ArdourDialog::stop), -1));
900 ok_button.signal_clicked().connect (bind (mem_fun (dialog, &ArdourDialog::stop), 1));
904 dialog.set_keyboard_input (true);
907 if (dialog.run_status() == 1) {
908 redirect->set_name (entry.get_text(), this);
913 RedirectBox::cut_redirect (Redirect *redirect)
915 /* this essentially transfers ownership of the redirect
916 of the redirect from the route to the mixer
920 _rr_selection.add (redirect);
922 void* gui = redirect->get_gui ();
925 static_cast<Gtk::Widget*>(gui)->hide ();
928 if (_route.remove_redirect (redirect, this)) {
929 _rr_selection.remove (redirect);
934 RedirectBox::copy_redirect (Redirect *redirect)
936 Redirect* copy = Redirect::clone (*redirect);
937 _rr_selection.add (copy);
941 RedirectBox::paste_redirects ()
943 if (_rr_selection.redirects.empty()) {
947 RedirectSelection& sel (_rr_selection.redirects);
948 list<Redirect*> others;
950 for (list<Redirect*>::iterator i = sel.begin(); i != sel.end(); ++i) {
952 Redirect* copy = Redirect::clone (**i);
954 copy->set_placement (_placement, this);
955 others.push_back (copy);
958 if (_route.add_redirects (others, this)) {
959 for (list<Redirect*>::iterator i = others.begin(); i != others.end(); ++i) {
964 "Copying the set of redirects on the clipboard failed,\n\
965 probably because the I/O configuration of the plugins\n\
966 could not match the configuration of this track.");
967 ArdourMessage am (0, X_("bad redirect copy dialog"), msg);
972 RedirectBox::activate_redirect (Redirect *r)
974 r->set_active (true, 0);
978 RedirectBox::deactivate_redirect (Redirect *r)
980 r->set_active (false, 0);
984 RedirectBox::get_selected_redirects (vector<Redirect*>& redirects)
986 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
988 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter)
989 redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
993 RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(Redirect*))
995 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
997 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
998 Redirect* redirect = (*(model->get_iter(*iter)))[columns.redirect];
999 (this->*pmf)(redirect);
1004 RedirectBox::clone_redirects ()
1006 RouteSelection& routes (_rr_selection.routes);
1008 if (!routes.empty()) {
1009 if (_route.copy_redirects (*routes.front(), _placement)) {
1011 "Copying the set of redirects on the clipboard failed,\n\
1012 probably because the I/O configuration of the plugins\n\
1013 could not match the configuration of this track.");
1014 ArdourMessage am (0, X_("bad redirect copy dialog"), msg);
1020 RedirectBox::all_redirects_active (bool state)
1022 _route.all_redirects_active (state);
1026 RedirectBox::clear_redirects()
1029 vector<string> choices;
1031 if (dynamic_cast<AudioTrack*>(&_route) != 0) {
1032 prompt = _("Do you really want to remove all redirects from this track?\n"
1033 "(this cannot be undone)");
1035 prompt = _("Do you really want to remove all redirects from this bus?\n"
1036 "(this cannot be undone)");
1039 choices.push_back (_("Yes, remove them all"));
1040 choices.push_back (_("Cancel"));
1042 Gtkmm2ext::Choice prompter (prompt, choices);
1044 prompter.chosen.connect(sigc::ptr_fun(Gtk::Main::quit));
1045 prompter.show_all ();
1049 if (prompter.get_choice() == 0) {
1050 _route.clear_redirects (this);
1056 RedirectBox::edit_redirect (Redirect* redirect)
1060 if (dynamic_cast<AudioTrack*>(&_route) != 0) {
1062 if (dynamic_cast<AudioTrack*> (&_route)->freeze_state() == AudioTrack::Frozen) {
1067 if ((insert = dynamic_cast<Insert *> (redirect)) == 0) {
1071 if (!_session.engine().connected()) {
1075 Send *send = dynamic_cast<Send*> (redirect);
1077 SendUIWindow *send_ui;
1079 if (send->get_gui() == 0) {
1082 title = string_compose(_("ardour: %1"), send->name());
1084 send_ui = new SendUIWindow (*send, _session);
1085 send_ui->set_title (title);
1086 send->set_gui (send_ui);
1089 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
1092 if (send_ui->is_visible()) {
1093 send_ui->get_window()->raise ();
1095 send_ui->show_all ();
1102 PluginInsert *plugin_insert;
1103 PortInsert *port_insert;
1105 if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) {
1107 PluginUIWindow *plugin_ui;
1109 if (plugin_insert->get_gui() == 0) {
1112 string maker = plugin_insert->plugin().maker();
1113 string::size_type email_pos;
1115 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1116 maker = maker.substr (0, email_pos - 1);
1119 if (maker.length() > 32) {
1120 maker = maker.substr (0, 32);
1124 title = string_compose(_("ardour: %1: %2 (by %3)"), _route.name(), plugin_insert->name(), maker);
1126 plugin_ui = new PluginUIWindow (_session.engine(), *plugin_insert);
1127 if (_owner_is_mixer) {
1128 ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui);
1130 ARDOUR_UI::instance()->the_editor().ensure_float (*plugin_ui);
1132 plugin_ui->set_title (title);
1133 plugin_insert->set_gui (plugin_ui);
1136 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
1139 if (plugin_ui->is_visible()) {
1140 plugin_ui->get_window()->raise ();
1142 plugin_ui->show_all ();
1145 } else if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
1147 if (!_session.engine().connected()) {
1148 ArdourMessage msg (NULL, "nojackdialog", _("Not connected to JACK - no I/O changes are possible"));
1152 PortInsertWindow *io_selector;
1154 if (port_insert->get_gui() == 0) {
1155 io_selector = new PortInsertWindow (_session, *port_insert);
1156 port_insert->set_gui (io_selector);
1159 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1162 if (io_selector->is_visible()) {
1163 io_selector->get_window()->raise ();
1165 io_selector->show_all ();