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"
56 #include "plugin_ui.h"
58 #include "io_selector.h"
60 #include "gui_thread.h"
65 using namespace ARDOUR;
67 using namespace Gtkmm2ext;
71 RedirectBox::RedirectBox (Placement pcmnt, Session& sess, Route& rt, PluginSelector &plugsel, RouteRedirectSelection & rsel, bool owner_is_mixer)
74 _owner_is_mixer (owner_is_mixer),
76 _plugin_selector(plugsel),
78 //redirect_display (1)
83 redirect_drag_in_progress = false;
85 model = ListStore::create(columns);
86 selection = redirect_display.get_selection();
87 selection->set_mode (Gtk::SELECTION_MULTIPLE);
88 redirect_display.set_model (model);
89 redirect_display.append_column (NULL, columns.text);
90 redirect_display.set_name ("MixerRedirectSelector");
91 redirect_display.set_headers_visible (false);
92 redirect_display.set_reorderable (true);
93 redirect_display.set_size_request (-1, 48);
94 redirect_display.add_object_drag (columns.redirect.index(), "redirects");
95 redirect_display.signal_object_drop.connect (mem_fun (*this, &RedirectBox::object_drop));
97 // Does this adequately replace the drag start/stop signal handlers?
98 model->signal_rows_reordered().connect (mem_fun (*this, &RedirectBox::redirects_reordered));
99 redirect_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
101 redirect_scroller.add (redirect_display);
102 redirect_eventbox.add (redirect_scroller);
103 pack_start (redirect_eventbox, true, true);
105 redirect_scroller.show ();
106 redirect_display.show ();
107 redirect_eventbox.show ();
110 _route.redirects_changed.connect (mem_fun(*this, &RedirectBox::redirects_changed));
112 redirect_display.signal_button_press_event().connect (mem_fun(*this, &RedirectBox::redirect_button));
113 redirect_display.signal_button_release_event().connect (mem_fun(*this, &RedirectBox::redirect_button));
115 //redirect_display.signal_button_release_event().connect_after (ptr_fun (do_not_propagate));
116 //_plugin_selector.hide.connect(mem_fun(*this,&RedirectBox::disconnect_newplug));
117 set_stuff_from_route ();
119 /* start off as a passthru strip. we'll correct this, if necessary,
120 in update_diskstream_display().
123 //set_name ("AudioTrackStripBase");
125 /* now force an update of all the various elements */
127 redirects_changed (0);
129 //add_events (Gdk::BUTTON_RELEASE_MASK);
132 RedirectBox::~RedirectBox ()
134 // GoingAway(); /* EMIT_SIGNAL */
139 RedirectBox::object_drop (string type, uint32_t cnt, void** ptr)
141 if (type != "redirects") {
147 RedirectBox::set_stuff_from_route ()
152 RedirectBox::set_title (const std::string & title)
154 redirect_display.get_column(0)->set_title (title);
158 RedirectBox::set_title_shown (bool flag)
164 RedirectBox::update()
166 redirects_changed(0);
171 RedirectBox::set_width (Width w)
178 redirects_changed(0);
183 RedirectBox::remove_redirect_gui (Redirect *redirect)
187 PortInsert *port_insert = 0;
189 if ((insert = dynamic_cast<Insert *> (redirect)) != 0) {
191 if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
192 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
193 port_insert->set_gui (0);
197 } else if ((send = dynamic_cast<Send *> (insert)) != 0) {
198 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
205 RedirectBox::build_send_action_menu ()
208 using namespace Menu_Helpers;
210 send_action_menu = new Menu;
211 send_action_menu->set_name ("ArdourContextMenu");
212 MenuList& items = send_action_menu->items();
214 items.push_back (MenuElem (_("New send"), mem_fun(*this, &RedirectBox::new_send)));
215 items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &RedirectBox::show_send_controls)));
219 RedirectBox::show_send_controls ()
225 RedirectBox::new_send ()
231 RedirectBox::show_redirect_menu (gint arg)
233 if (redirect_menu == 0) {
234 redirect_menu = build_redirect_menu ();
237 redirect_menu->popup (1, 0);
241 RedirectBox::redirect_drag_begin (GdkDragContext *context)
243 redirect_drag_in_progress = true;
247 RedirectBox::redirect_drag_end (GdkDragContext *context)
249 redirect_drag_in_progress = false;
253 RedirectBox::redirect_button (GdkEventButton *ev)
256 TreeModel::Row row = *(redirect_display.get_selection()->get_selected());
257 redirect = row[columns.redirect];
260 case GDK_BUTTON_PRESS:
261 if (ev->button == 3) {
262 show_redirect_menu (0); // Handle the context-click menu here as well
268 case GDK_2BUTTON_PRESS:
269 if (ev->state != 0) {
272 /* might be edit event, see below */
275 case GDK_BUTTON_RELEASE:
279 /* shouldn't be here, but gcc complains */
283 if (redirect && Keyboard::is_delete_event (ev)) {
285 Glib::signal_idle().connect (bind (mem_fun(*this, &RedirectBox::idle_delete_redirect), redirect));
288 } else if (redirect && (Keyboard::is_edit_event (ev) || ev->type == GDK_2BUTTON_PRESS)) {
290 if (_session.engine().connected()) {
291 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
292 edit_redirect (redirect);
296 } else if (Keyboard::is_context_menu_event (ev)) {
297 show_redirect_menu(0);
298 return TRUE; //stop_signal (*clist, "button-release-event");
301 switch (ev->button) {
308 redirect->set_active (!redirect->active(), this);
324 RedirectBox::build_redirect_menu ()
326 popup_act_grp = Gtk::ActionGroup::create();
330 popup_act_grp->add (Gtk::Action::create("newplugin", _("New Plugin ...")), mem_fun(*this, &RedirectBox::choose_plugin));
331 popup_act_grp->add (Gtk::Action::create("newinsert", _("New Insert")), mem_fun(*this, &RedirectBox::choose_insert));
332 popup_act_grp->add (Gtk::Action::create("newsend", _("New Send ...")), mem_fun(*this, &RedirectBox::choose_send));
333 popup_act_grp->add (Gtk::Action::create("clear", _("Clear")), mem_fun(*this, &RedirectBox::clear_redirects));
335 /* standard editing stuff */
337 popup_act_grp->add (Gtk::Action::create("cut", _("Cut")), mem_fun(*this, &RedirectBox::cut_redirects));
338 popup_act_grp->add (Gtk::Action::create("copy", _("Copy")), mem_fun(*this, &RedirectBox::copy_redirects));
339 popup_act_grp->add (Gtk::Action::create("paste", _("Paste")), mem_fun(*this, &RedirectBox::paste_redirects));
340 popup_act_grp->add (Gtk::Action::create("rename", _("Rename")), mem_fun(*this, &RedirectBox::rename_redirects));
341 popup_act_grp->add (Gtk::Action::create("selectall", _("Select All")), mem_fun(*this, &RedirectBox::select_all_redirects));
342 popup_act_grp->add (Gtk::Action::create("deselectall", _("Deselect All")), mem_fun(*this, &RedirectBox::deselect_all_redirects));
346 popup_act_grp->add (Gtk::Action::create("activate", _("Activate")), bind (mem_fun(*this, &RedirectBox::for_selected_redirects), &RedirectBox::activate_redirect));
347 popup_act_grp->add (Gtk::Action::create("deactivate", _("Deactivate")), bind (mem_fun(*this, &RedirectBox::for_selected_redirects), &RedirectBox::deactivate_redirect));
348 popup_act_grp->add (Gtk::Action::create("activateall", _("Activate All")), bind (mem_fun(*this, &RedirectBox::all_redirects_active), true));
349 popup_act_grp->add (Gtk::Action::create("deactivateall", _("Deactivate All")), bind (mem_fun(*this, &RedirectBox::all_redirects_active), false));
353 popup_act_grp->add (Gtk::Action::create("edit", _("Edit")), bind (mem_fun(*this, &RedirectBox::for_selected_redirects), &RedirectBox::edit_redirect));
355 selection_dependent_items.push_back (popup_act_grp->get_action("cut"));
356 selection_dependent_items.push_back (popup_act_grp->get_action("copy"));
357 selection_dependent_items.push_back (popup_act_grp->get_action("rename"));
358 selection_dependent_items.push_back (popup_act_grp->get_action("activate"));
359 selection_dependent_items.push_back (popup_act_grp->get_action("deactivate"));
360 selection_dependent_items.push_back (popup_act_grp->get_action("edit"));
362 //popup_ui_mgr = Gtk::UIManager::create();
363 //popup_ui_mgr->insert_action_group(popup_act_grp);
365 redirect_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/redirectmenu") );
366 redirect_menu->signal_map_event().connect (mem_fun(*this, &RedirectBox::redirect_menu_map_handler));
367 redirect_menu->set_name ("ArdourContextMenu");
369 return redirect_menu;
373 RedirectBox::redirect_menu_map_handler (GdkEventAny *ev)
375 bool sensitive = (redirect_display.get_selection()->count_selected_rows()) ? true : false;
377 for (vector<Glib::RefPtr<Gtk::Action> >::iterator i = selection_dependent_items.begin(); i != selection_dependent_items.end(); ++i) {
378 (*i)->set_sensitive (sensitive);
381 popup_act_grp->get_action("paste")->set_sensitive (!_rr_selection.redirects.empty());
386 RedirectBox::select_all_redirects ()
388 redirect_display.get_selection()->select_all();
392 RedirectBox::deselect_all_redirects ()
394 redirect_display.get_selection()->unselect_all();
398 RedirectBox::choose_plugin ()
400 show_plugin_selector();
404 RedirectBox::insert_plugin_chosen (Plugin *plugin)
408 Redirect *redirect = new PluginInsert (_session, *plugin, _placement);
410 redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active));
412 uint32_t err_streams;
414 if (_route.add_redirect (redirect, this, &err_streams)) {
415 wierd_plugin_dialog (*plugin, err_streams, _route);
422 RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, IO& io)
424 ArdourDialog dialog ("wierd plugin dialog");
426 Button button (_("OK"));
430 /* i hate this kind of code */
432 if (streams > p.get_info().n_inputs) {
433 label.set_text (string_compose (_(
434 "You attempted to add a plugin (%1).\n"
435 "The plugin has %2 inputs\n"
436 "but at the insertion point, there are\n"
437 "%3 active signal streams.\n"
439 "This makes no sense - you are throwing away\n"
440 "part of the signal."),
442 p.get_info().n_inputs,
444 } else if (streams < p.get_info().n_inputs) {
445 label.set_text (string_compose (_(
446 "You attempted to add a plugin (%1).\n"
447 "The plugin has %2 inputs\n"
448 "but at the insertion point there are\n"
449 "only %3 active signal streams.\n"
451 "This makes no sense - unless the plugin supports\n"
452 "side-chain inputs. A future version of Ardour will\n"
453 "support this type of configuration."),
455 p.get_info().n_inputs,
458 label.set_text (string_compose (_(
459 "You attempted to add a plugin (%1).\n"
461 "The I/O configuration doesn't make sense:\n"
463 "The plugin has %2 inputs and %3 outputs.\n"
464 "The track/bus has %4 inputs and %5 outputs.\n"
465 "The insertion point, has %6 active signals.\n"
467 "Ardour does not understand what to do in such situations.\n"),
469 p.get_info().n_inputs,
470 p.get_info().n_outputs,
476 button_box.pack_start (button, false, true);
478 vpacker.set_spacing (12);
479 vpacker.set_border_width (12);
480 vpacker.pack_start (label);
481 vpacker.pack_start (button_box);
483 button.signal_clicked().connect (bind (mem_fun (dialog, &ArdourDialog::stop), 0));
485 dialog.add (vpacker);
486 dialog.set_name (X_("PluginIODialog"));
487 dialog.set_position (Gtk::WIN_POS_MOUSE);
488 dialog.set_modal (true);
493 //dialog.get_window()->set_decorations (Gdk::WMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
499 RedirectBox::choose_insert ()
501 Redirect *redirect = new PortInsert (_session, _placement);
502 redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active));
503 _route.add_redirect (redirect, this);
507 RedirectBox::choose_send ()
509 Send *send = new Send (_session, _placement);
511 /* XXX need redirect lock on route */
513 send->ensure_io (0, _route.max_redirect_outs(), false, this);
515 IOSelectorWindow *ios = new IOSelectorWindow (_session, *send, false, true);
518 ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), static_cast<Redirect*>(send), ios));
522 RedirectBox::send_io_finished (IOSelector::Result r, Redirect* redirect, IOSelectorWindow* ios)
525 case IOSelector::Cancelled:
529 case IOSelector::Accepted:
530 _route.add_redirect (redirect, this);
534 delete_when_idle (ios);
538 RedirectBox::disconnect_newplug ()
540 newplug_connection.disconnect();
543 RedirectBox::show_plugin_selector ()
545 newplug_connection = _plugin_selector.PluginCreated.connect (mem_fun(*this,&RedirectBox::insert_plugin_chosen));
546 _plugin_selector.show_all ();
550 RedirectBox::redirects_changed (void *src)
552 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::redirects_changed), src));
554 //redirect_display.freeze ();
556 redirect_active_connections.clear ();
557 redirect_name_connections.clear ();
559 _route.foreach_redirect (this, &RedirectBox::add_redirect_to_display);
561 switch (_placement) {
563 build_redirect_tooltip(redirect_eventbox, _("Pre-fader inserts, sends & plugins:"));
566 build_redirect_tooltip(redirect_eventbox, _("Post-fader inserts, sends & plugins:"));
569 //redirect_display.thaw ();
573 RedirectBox::add_redirect_to_display (Redirect *redirect)
575 if (redirect->placement() != _placement) {
579 Gtk::TreeModel::Row row = *(model->append());
580 row[columns.text] = redirect_name (*redirect);
581 row[columns.redirect] = redirect;
583 show_redirect_active (redirect, this);
585 redirect_active_connections.push_back (redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active)));
586 redirect_name_connections.push_back (redirect->name_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_name), redirect)));
590 RedirectBox::redirect_name (Redirect& redirect)
595 if (!redirect.active()) {
599 if ((send = dynamic_cast<Send *> (&redirect)) != 0) {
603 /* grab the send name out of its overall name */
605 string::size_type lbracket, rbracket;
606 lbracket = send->name().find ('[');
607 rbracket = send->name().find (']');
611 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
614 name_display += short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
622 name_display += redirect.name();
625 name_display += short_version (redirect.name(), 5);
631 if (!redirect.active()) {
639 RedirectBox::build_redirect_tooltip (EventBox& box, string start)
643 Gtk::TreeModel::Children children = model->children();
644 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
645 Gtk::TreeModel::Row row = *iter;
647 tip += row[columns.text];
649 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
653 RedirectBox::show_redirect_name (void* src, Redirect *redirect)
655 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_name), src, redirect));
657 show_redirect_active (redirect, src);
661 RedirectBox::show_redirect_active (Redirect *redirect, void *src)
663 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_active), redirect, src));
665 Gtk::TreeModel::Children children = model->children();
666 Gtk::TreeModel::Children::iterator iter = children.begin();
668 while( iter != children.end())
670 if ((*iter)[columns.redirect] == redirect)
675 (*iter)[columns.text] = redirect_name (*redirect);
677 if (redirect->active()) {
678 redirect_display.get_selection()->select (iter);
680 redirect_display.get_selection()->unselect (iter);
685 RedirectBox::redirects_reordered (const TreeModel::Path& path,const TreeModel::iterator& iter ,int* hmm)
687 /* this is called before the reorder has been done, so just queue
688 something for idle time.
691 Glib::signal_idle().connect (mem_fun(*this, &RedirectBox::compute_redirect_sort_keys));
695 RedirectBox::compute_redirect_sort_keys ()
697 uint32_t sort_key = 0;
698 Gtk::TreeModel::Children children = model->children();
700 for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
701 Redirect *redirect = (*iter)[columns.redirect];
702 redirect->set_sort_key (sort_key, this);
706 if (_route.sort_redirects ()) {
708 redirects_changed (0);
710 /* now tell them about the problem */
712 ArdourDialog dialog ("wierd plugin dialog");
714 Button button (_("OK"));
719 You cannot reorder this set of redirects\n\
720 in that way because the inputs and\n\
721 outputs do not work correctly."));
723 button_box.pack_start (button, false, true);
725 vpacker.set_spacing (12);
726 vpacker.set_border_width (12);
727 vpacker.pack_start (label);
728 vpacker.pack_start (button_box);
730 button.signal_clicked().connect (bind (mem_fun (dialog, &ArdourDialog::stop), 0));
732 dialog.add (vpacker);
733 dialog.set_name (X_("PluginIODialog"));
734 dialog.set_position (Gtk::WIN_POS_MOUSE);
735 dialog.set_modal (true);
740 //dialog.get_window()->set_decorations (Gdk::WMDecoration (GDK_DECOR_BORDER|GDK_DECOR_RESIZEH));
749 RedirectBox::rename_redirects ()
751 vector<Redirect*> to_be_renamed;
753 get_selected_redirects (to_be_renamed);
755 if (to_be_renamed.empty()) {
759 for (vector<Redirect*>::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
760 rename_redirect (*i);
765 RedirectBox::cut_redirects ()
767 vector<Redirect*> to_be_removed;
769 get_selected_redirects (to_be_removed);
771 if (to_be_removed.empty()) {
775 /* this essentially transfers ownership of the redirect
776 of the redirect from the route to the mixer
780 _rr_selection.set (to_be_removed);
782 for (vector<Redirect*>::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
784 void* gui = (*i)->get_gui ();
787 static_cast<Gtk::Widget*>(gui)->hide ();
790 if (_route.remove_redirect (*i, this)) {
792 _rr_selection.remove (*i);
799 RedirectBox::copy_redirects ()
801 vector<Redirect*> to_be_copied;
802 vector<Redirect*> copies;
804 get_selected_redirects (to_be_copied);
806 if (to_be_copied.empty()) {
810 for (vector<Redirect*>::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
811 copies.push_back (Redirect::clone (**i));
814 _rr_selection.set (copies);
818 RedirectBox::idle_delete_redirect (Redirect *redirect)
820 /* NOT copied to _mixer.selection() */
822 if (_route.remove_redirect (redirect, this)) {
832 RedirectBox::rename_redirect (Redirect* redirect)
834 ArdourDialog dialog ("rename redirect dialog");
838 Button ok_button (_("OK"));
839 Button cancel_button (_("Cancel"));
841 dialog.set_title (_("ardour: rename redirect"));
842 dialog.set_name ("RedirectRenameWindow");
843 dialog.set_size_request (300, -1);
844 dialog.set_position (Gtk::WIN_POS_MOUSE);
845 dialog.set_modal (true);
847 vbox.set_border_width (12);
848 vbox.set_spacing (12);
849 vbox.pack_start (entry, false, false);
850 vbox.pack_start (hbox, false, false);
851 hbox.pack_start (ok_button);
852 hbox.pack_start (cancel_button);
856 entry.set_name ("RedirectNameDisplay");
857 entry.set_text (redirect->name());
858 entry.select_region (0, -1);
861 ok_button.set_name ("EditorGTKButton");
862 cancel_button.set_name ("EditorGTKButton");
864 entry.signal_activate().connect (bind (mem_fun (dialog, &ArdourDialog::stop), 1));
865 cancel_button.signal_clicked().connect (bind (mem_fun (dialog, &ArdourDialog::stop), -1));
866 ok_button.signal_clicked().connect (bind (mem_fun (dialog, &ArdourDialog::stop), 1));
870 dialog.set_keyboard_input (true);
873 if (dialog.run_status() == 1) {
874 redirect->set_name (entry.get_text(), this);
879 RedirectBox::cut_redirect (Redirect *redirect)
881 /* this essentially transfers ownership of the redirect
882 of the redirect from the route to the mixer
886 _rr_selection.add (redirect);
888 void* gui = redirect->get_gui ();
891 static_cast<Gtk::Widget*>(gui)->hide ();
894 if (_route.remove_redirect (redirect, this)) {
895 _rr_selection.remove (redirect);
900 RedirectBox::copy_redirect (Redirect *redirect)
902 Redirect* copy = Redirect::clone (*redirect);
903 _rr_selection.add (copy);
907 RedirectBox::paste_redirects ()
909 if (_rr_selection.redirects.empty()) {
913 RedirectSelection& sel (_rr_selection.redirects);
914 list<Redirect*> others;
916 for (list<Redirect*>::iterator i = sel.begin(); i != sel.end(); ++i) {
918 Redirect* copy = Redirect::clone (**i);
920 copy->set_placement (_placement, this);
921 others.push_back (copy);
924 if (_route.add_redirects (others, this)) {
925 for (list<Redirect*>::iterator i = others.begin(); i != others.end(); ++i) {
930 "Copying the set of redirects on the clipboard failed,\n\
931 probably because the I/O configuration of the plugins\n\
932 could not match the configuration of this track.");
933 ArdourMessage am (0, X_("bad redirect copy dialog"), msg);
938 RedirectBox::activate_redirect (Redirect *r)
940 r->set_active (true, 0);
944 RedirectBox::deactivate_redirect (Redirect *r)
946 r->set_active (false, 0);
950 RedirectBox::get_selected_redirects (vector<Redirect*>& redirects)
952 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
954 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter)
955 redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
959 RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(Redirect*))
961 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
963 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
964 Redirect* redirect = (*(model->get_iter(*iter)))[columns.redirect];
965 (this->*pmf)(redirect);
970 RedirectBox::clone_redirects ()
972 RouteSelection& routes (_rr_selection.routes);
974 if (!routes.empty()) {
975 if (_route.copy_redirects (*routes.front(), _placement)) {
977 "Copying the set of redirects on the clipboard failed,\n\
978 probably because the I/O configuration of the plugins\n\
979 could not match the configuration of this track.");
980 ArdourMessage am (0, X_("bad redirect copy dialog"), msg);
986 RedirectBox::all_redirects_active (bool state)
988 _route.all_redirects_active (state);
992 RedirectBox::clear_redirects()
995 vector<string> choices;
997 if (dynamic_cast<AudioTrack*>(&_route) != 0) {
998 prompt = _("Do you really want to remove all redirects from this track?\n"
999 "(this cannot be undone)");
1001 prompt = _("Do you really want to remove all redirects from this bus?\n"
1002 "(this cannot be undone)");
1005 choices.push_back (_("Yes, remove them all"));
1006 choices.push_back (_("Cancel"));
1008 Gtkmm2ext::Choice prompter (prompt, choices);
1010 prompter.chosen.connect(sigc::ptr_fun(Gtk::Main::quit));
1011 prompter.show_all ();
1015 if (prompter.get_choice() == 0) {
1016 _route.clear_redirects (this);
1022 RedirectBox::edit_redirect (Redirect* redirect)
1026 if (dynamic_cast<AudioTrack*>(&_route) != 0) {
1028 if (dynamic_cast<AudioTrack*> (&_route)->freeze_state() == AudioTrack::Frozen) {
1033 if ((insert = dynamic_cast<Insert *> (redirect)) == 0) {
1037 if (!_session.engine().connected()) {
1041 Send *send = dynamic_cast<Send*> (redirect);
1043 SendUIWindow *send_ui;
1045 if (send->get_gui() == 0) {
1048 title = string_compose(_("ardour: %1"), send->name());
1050 send_ui = new SendUIWindow (*send, _session);
1051 send_ui->set_title (title);
1052 send->set_gui (send_ui);
1055 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
1058 if (send_ui->is_visible()) {
1059 send_ui->get_window()->raise ();
1061 send_ui->show_all ();
1068 PluginInsert *plugin_insert;
1069 PortInsert *port_insert;
1071 if ((plugin_insert = dynamic_cast<PluginInsert *> (insert)) != 0) {
1073 PluginUIWindow *plugin_ui;
1075 if (plugin_insert->get_gui() == 0) {
1078 string maker = plugin_insert->plugin().maker();
1079 string::size_type email_pos;
1081 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1082 maker = maker.substr (0, email_pos - 1);
1085 if (maker.length() > 32) {
1086 maker = maker.substr (0, 32);
1090 title = string_compose(_("ardour: %1: %2 (by %3)"), _route.name(), plugin_insert->name(), maker);
1092 plugin_ui = new PluginUIWindow (_session.engine(), *plugin_insert);
1093 if (_owner_is_mixer) {
1094 ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui);
1096 ARDOUR_UI::instance()->the_editor().ensure_float (*plugin_ui);
1098 plugin_ui->set_title (title);
1099 plugin_insert->set_gui (plugin_ui);
1102 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
1105 if (plugin_ui->is_visible()) {
1106 plugin_ui->get_window()->raise ();
1108 plugin_ui->show_all ();
1111 } else if ((port_insert = dynamic_cast<PortInsert *> (insert)) != 0) {
1113 if (!_session.engine().connected()) {
1114 ArdourMessage msg (NULL, "nojackdialog", _("Not connected to JACK - no I/O changes are possible"));
1118 PortInsertWindow *io_selector;
1120 if (port_insert->get_gui() == 0) {
1121 io_selector = new PortInsertWindow (_session, *port_insert);
1122 port_insert->set_gui (io_selector);
1125 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1128 if (io_selector->is_visible()) {
1129 io_selector->get_window()->raise ();
1131 io_selector->show_all ();