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.
23 #include <sigc++/bind.h>
25 #include <pbd/convert.h>
27 #include <glibmm/miscutils.h>
29 #include <gtkmm/messagedialog.h>
31 #include <gtkmm2ext/gtk_ui.h>
32 #include <gtkmm2ext/utils.h>
33 #include <gtkmm2ext/choice.h>
34 #include <gtkmm2ext/utils.h>
35 #include <gtkmm2ext/stop_signal.h>
36 #include <gtkmm2ext/doi.h>
37 #include <gtkmm2ext/window_title.h>
39 #include <ardour/ardour.h>
40 #include <ardour/session.h>
41 #include <ardour/audioengine.h>
42 #include <ardour/route.h>
43 #include <ardour/audio_track.h>
44 #include <ardour/audio_diskstream.h>
45 #include <ardour/send.h>
46 #include <ardour/insert.h>
47 #include <ardour/ladspa_plugin.h>
49 #include "ardour_ui.h"
50 #include "ardour_dialog.h"
51 #include "public_editor.h"
52 #include "redirect_box.h"
54 #include "plugin_selector.h"
55 #include "route_redirect_selection.h"
58 #include "plugin_ui.h"
60 #include "io_selector.h"
62 #include "gui_thread.h"
67 #include "au_pluginui.h"
71 using namespace ARDOUR;
75 using namespace Gtkmm2ext;
77 RedirectBox* RedirectBox::_current_redirect_box = 0;
78 RefPtr<Action> RedirectBox::paste_action;
79 bool RedirectBox::get_colors = true;
80 Gdk::Color* RedirectBox::active_redirect_color;
81 Gdk::Color* RedirectBox::inactive_redirect_color;
83 RedirectBox::RedirectBox (Placement pcmnt, Session& sess, boost::shared_ptr<Route> rt, PluginSelector &plugsel,
84 RouteRedirectSelection & rsel, bool owner_is_mixer)
87 _owner_is_mixer (owner_is_mixer),
89 _plugin_selector(plugsel),
93 active_redirect_color = new Gdk::Color;
94 inactive_redirect_color = new Gdk::Color;
95 set_color (*active_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_ACTIVE, false ));
96 set_color (*inactive_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false ));
102 send_action_menu = 0;
103 redirect_drag_in_progress = false;
104 no_redirect_redisplay = false;
105 ignore_delete = false;
108 model = ListStore::create(columns);
110 RefPtr<TreeSelection> selection = redirect_display.get_selection();
111 selection->set_mode (Gtk::SELECTION_MULTIPLE);
112 selection->signal_changed().connect (mem_fun (*this, &RedirectBox::selection_changed));
114 redirect_display.set_model (model);
115 redirect_display.append_column (X_("notshown"), columns.text);
116 redirect_display.set_name ("RedirectSelector");
117 redirect_display.set_headers_visible (false);
118 redirect_display.set_reorderable (true);
119 redirect_display.set_size_request (-1, 40);
120 redirect_display.get_column(0)->set_sizing(TREE_VIEW_COLUMN_FIXED);
121 redirect_display.get_column(0)->set_fixed_width(48);
122 redirect_display.add_object_drag (columns.redirect.index(), "redirects");
123 redirect_display.signal_object_drop.connect (mem_fun (*this, &RedirectBox::object_drop));
125 TreeViewColumn* name_col = redirect_display.get_column(0);
126 CellRendererText* renderer = dynamic_cast<CellRendererText*>(redirect_display.get_column_cell_renderer (0));
127 name_col->add_attribute(renderer->property_foreground_gdk(), columns.color);
129 redirect_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
131 model->signal_row_deleted().connect (mem_fun (*this, &RedirectBox::row_deleted));
133 redirect_scroller.add (redirect_display);
134 redirect_eventbox.add (redirect_scroller);
136 redirect_scroller.set_size_request (-1, 40);
138 pack_start (redirect_eventbox, true, true);
140 _route->redirects_changed.connect (mem_fun(*this, &RedirectBox::redisplay_redirects));
141 _route->GoingAway.connect (mem_fun (*this, &RedirectBox::route_going_away));
143 redirect_eventbox.signal_enter_notify_event().connect (bind (sigc::ptr_fun (RedirectBox::enter_box), this));
145 redirect_display.signal_button_press_event().connect (mem_fun(*this, &RedirectBox::redirect_button_press_event), false);
146 redirect_display.signal_button_release_event().connect (mem_fun(*this, &RedirectBox::redirect_button_release_event));
148 /* start off as a passthru strip. we'll correct this, if necessary,
149 in update_diskstream_display().
152 /* now force an update of all the various elements */
154 redisplay_redirects (0);
157 RedirectBox::~RedirectBox ()
162 RedirectBox::route_going_away ()
164 /* don't keep updating display as redirects are deleted */
165 no_redirect_redisplay = true;
169 RedirectBox::object_drop (string type, uint32_t cnt, const boost::shared_ptr<Redirect>* ptr)
171 if (type != "redirects" || cnt == 0 || !ptr) {
175 /* do something with the dropped redirects */
177 list<boost::shared_ptr<Redirect> > redirects;
179 for (uint32_t n = 0; n < cnt; ++n) {
180 redirects.push_back (ptr[n]);
183 paste_redirect_list (redirects);
187 RedirectBox::update()
189 redisplay_redirects (0);
194 RedirectBox::set_width (Width w)
201 redisplay_redirects (0);
205 RedirectBox::remove_redirect_gui (boost::shared_ptr<Redirect> redirect)
207 boost::shared_ptr<Insert> insert;
208 boost::shared_ptr<Send> send;
209 boost::shared_ptr<PortInsert> port_insert;
211 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) != 0) {
213 if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
214 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
215 port_insert->set_gui (0);
219 } else if ((send = boost::dynamic_pointer_cast<Send> (insert)) != 0) {
220 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
227 RedirectBox::build_send_action_menu ()
230 using namespace Menu_Helpers;
232 send_action_menu = new Menu;
233 send_action_menu->set_name ("ArdourContextMenu");
234 MenuList& items = send_action_menu->items();
236 items.push_back (MenuElem (_("New send"), mem_fun(*this, &RedirectBox::new_send)));
237 items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &RedirectBox::show_send_controls)));
241 RedirectBox::show_send_controls ()
247 RedirectBox::new_send ()
253 RedirectBox::show_redirect_menu (gint arg)
255 if (redirect_menu == 0) {
256 redirect_menu = build_redirect_menu ();
259 paste_action->set_sensitive (!_rr_selection.redirects.empty());
261 redirect_menu->popup (1, arg);
265 RedirectBox::redirect_drag_begin (GdkDragContext *context)
267 redirect_drag_in_progress = true;
271 RedirectBox::redirect_drag_end (GdkDragContext *context)
273 redirect_drag_in_progress = false;
277 RedirectBox::redirect_button_press_event (GdkEventButton *ev)
280 TreeModel::Path path;
281 TreeViewColumn* column;
284 boost::shared_ptr<Redirect> redirect;
286 bool selected = false;
288 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
289 if ((iter = model->get_iter (path))) {
290 redirect = (*iter)[columns.redirect];
291 selected = redirect_display.get_selection()->is_selected (iter);
296 if (redirect && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
298 if (_session.engine().connected()) {
299 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
300 edit_redirect (redirect);
304 } else if (redirect && ev->button == 1 && selected) {
306 // this is purely informational but necessary
307 RedirectSelected (redirect); // emit
314 RedirectBox::redirect_button_release_event (GdkEventButton *ev)
317 TreeModel::Path path;
318 TreeViewColumn* column;
321 boost::shared_ptr<Redirect> redirect;
325 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
326 if ((iter = model->get_iter (path))) {
327 redirect = (*iter)[columns.redirect];
331 if (redirect && Keyboard::is_delete_event (ev)) {
333 Glib::signal_idle().connect (bind (mem_fun(*this, &RedirectBox::idle_delete_redirect), boost::weak_ptr<Redirect>(redirect)));
336 } else if (Keyboard::is_context_menu_event (ev)) {
338 show_redirect_menu(ev->time);
341 } else if (redirect && (ev->button == 2) && (ev->state == Gdk::BUTTON2_MASK)) {
343 redirect->set_active (!redirect->active(), this);
352 RedirectBox::build_redirect_menu ()
354 redirect_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/redirectmenu") );
355 redirect_menu->set_name ("ArdourContextMenu");
359 return redirect_menu;
363 RedirectBox::selection_changed ()
365 bool sensitive = (redirect_display.get_selection()->count_selected_rows()) ? true : false;
366 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
370 RedirectBox::select_all_redirects ()
372 redirect_display.get_selection()->select_all();
376 RedirectBox::deselect_all_redirects ()
378 redirect_display.get_selection()->unselect_all();
382 RedirectBox::choose_plugin ()
384 sigc::connection newplug_connection = _plugin_selector.PluginCreated.connect (mem_fun(*this,&RedirectBox::insert_plugin_chosen));
385 _plugin_selector.show_all();
386 _plugin_selector.run ();
387 newplug_connection.disconnect();
391 RedirectBox::insert_plugin_chosen (boost::shared_ptr<Plugin> plugin)
395 boost::shared_ptr<Redirect> redirect (new PluginInsert (_session, plugin, _placement));
397 redirect->active_changed.connect (bind (mem_fun (*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect)));
399 uint32_t err_streams;
401 if (_route->add_redirect (redirect, this, &err_streams)) {
402 weird_plugin_dialog (*plugin, err_streams, _route);
403 // XXX SHAREDPTR delete plugin here .. do we even need to care?
409 RedirectBox::weird_plugin_dialog (Plugin& p, uint32_t streams, boost::shared_ptr<IO> io)
411 ArdourDialog dialog (_("ardour: weird plugin dialog"));
414 /* i hate this kind of code */
416 if (streams > p.get_info()->n_inputs) {
417 label.set_text (string_compose (_(
418 "You attempted to add a plugin (%1).\n"
419 "The plugin has %2 inputs\n"
420 "but at the insertion point, there are\n"
421 "%3 active signal streams.\n"
423 "This makes no sense - you are throwing away\n"
424 "part of the signal."),
426 p.get_info()->n_inputs,
428 } else if (streams < p.get_info()->n_inputs) {
429 label.set_text (string_compose (_(
430 "You attempted to add a plugin (%1).\n"
431 "The plugin has %2 inputs\n"
432 "but at the insertion point there are\n"
433 "only %3 active signal streams.\n"
435 "This makes no sense - unless the plugin supports\n"
436 "side-chain inputs. A future version of Ardour will\n"
437 "support this type of configuration."),
439 p.get_info()->n_inputs,
442 label.set_text (string_compose (_(
443 "You attempted to add a plugin (%1).\n"
445 "The I/O configuration doesn't make sense:\n"
447 "The plugin has %2 inputs and %3 outputs.\n"
448 "The track/bus has %4 inputs and %5 outputs.\n"
449 "The insertion point, has %6 active signals.\n"
451 "Ardour does not understand what to do in such situations.\n"),
453 p.get_info()->n_inputs,
454 p.get_info()->n_outputs,
455 io->n_inputs().get_total(),
456 io->n_outputs().get_total(),
460 dialog.get_vbox()->pack_start (label);
461 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
463 dialog.set_name (X_("PluginIODialog"));
464 dialog.set_position (Gtk::WIN_POS_MOUSE);
465 dialog.set_modal (true);
472 RedirectBox::choose_insert ()
474 boost::shared_ptr<Redirect> redirect (new PortInsert (_session, _placement));
475 redirect->active_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect)));
476 _route->add_redirect (redirect, this);
480 RedirectBox::choose_send ()
482 boost::shared_ptr<Send> send (new Send (_session, _placement));
483 send->set_default_type(_route->default_type());
485 /* XXX need redirect lock on route */
487 send->ensure_io (ChanCount::ZERO, _route->max_redirect_outs(), false, this);
489 IOSelectorWindow *ios = new IOSelectorWindow (_session, send, false, true);
493 boost::shared_ptr<Redirect> r = boost::static_pointer_cast<Redirect>(send);
495 ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), boost::weak_ptr<Redirect>(r), ios));
499 RedirectBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Redirect> weak_redirect, IOSelectorWindow* ios)
501 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
508 case IOSelector::Cancelled:
509 // redirect will go away when all shared_ptrs to it vanish
512 case IOSelector::Accepted:
513 _route->add_redirect (redirect, this);
517 delete_when_idle (ios);
521 RedirectBox::redisplay_redirects (void *src)
523 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::redisplay_redirects), src));
525 if (no_redirect_redisplay) {
529 ignore_delete = true;
531 ignore_delete = false;
533 redirect_active_connections.clear ();
534 redirect_name_connections.clear ();
536 void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>) = &RedirectBox::add_redirect_to_display;
537 _route->foreach_redirect (this, pmf);
539 switch (_placement) {
541 build_redirect_tooltip(redirect_eventbox, _("Pre-fader inserts, sends & plugins:"));
544 build_redirect_tooltip(redirect_eventbox, _("Post-fader inserts, sends & plugins:"));
550 RedirectBox::add_redirect_to_display (boost::shared_ptr<Redirect> redirect)
552 if (redirect->placement() != _placement) {
556 Gtk::TreeModel::Row row = *(model->append());
557 row[columns.text] = redirect_name (redirect);
558 row[columns.redirect] = redirect;
560 show_redirect_active (redirect);
562 redirect_active_connections.push_back (redirect->active_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect))));
563 redirect_name_connections.push_back (redirect->name_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_name), boost::weak_ptr<Redirect>(redirect))));
567 RedirectBox::redirect_name (boost::weak_ptr<Redirect> weak_redirect)
569 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
575 boost::shared_ptr<Send> send;
578 if (!redirect->active()) {
582 if ((send = boost::dynamic_pointer_cast<Send> (redirect)) != 0) {
586 /* grab the send name out of its overall name */
588 string::size_type lbracket, rbracket;
589 lbracket = send->name().find ('[');
590 rbracket = send->name().find (']');
594 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
597 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
605 name_display += redirect->name();
608 name_display += PBD::short_version (redirect->name(), 5);
614 if (!redirect->active()) {
622 RedirectBox::build_redirect_tooltip (EventBox& box, string start)
626 Gtk::TreeModel::Children children = model->children();
627 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
628 Gtk::TreeModel::Row row = *iter;
631 /* don't use the column text, since it may be narrowed */
633 boost::shared_ptr<Redirect> r = row[columns.redirect];
636 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
640 RedirectBox::show_redirect_name (void* src, boost::weak_ptr<Redirect> redirect)
642 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_name), src, redirect));
643 show_redirect_active (redirect);
647 RedirectBox::show_redirect_active_r (Redirect* r, void *src, boost::weak_ptr<Redirect> weak_redirect)
649 show_redirect_active (weak_redirect);
653 RedirectBox::show_redirect_active (boost::weak_ptr<Redirect> weak_redirect)
655 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_active), weak_redirect));
657 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
663 Gtk::TreeModel::Children children = model->children();
664 Gtk::TreeModel::Children::iterator iter = children.begin();
666 while (iter != children.end()) {
668 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
671 (*iter)[columns.text] = redirect_name (r);
673 if (redirect->active()) {
674 (*iter)[columns.color] = *active_redirect_color;
676 (*iter)[columns.color] = *inactive_redirect_color;
686 RedirectBox::row_deleted (const Gtk::TreeModel::Path& path)
688 if (!ignore_delete) {
689 compute_redirect_sort_keys ();
694 RedirectBox::compute_redirect_sort_keys ()
696 uint32_t sort_key = 0;
697 Gtk::TreeModel::Children children = model->children();
699 for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
700 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
701 r->set_sort_key (sort_key);
705 if (_route->sort_redirects ()) {
707 redisplay_redirects (0);
709 /* now tell them about the problem */
711 ArdourDialog dialog (_("ardour: weird plugin dialog"));
715 You cannot reorder this set of redirects\n\
716 in that way because the inputs and\n\
717 outputs do not work correctly."));
719 dialog.get_vbox()->pack_start (label);
720 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
722 dialog.set_name (X_("PluginIODialog"));
723 dialog.set_position (Gtk::WIN_POS_MOUSE);
724 dialog.set_modal (true);
732 RedirectBox::rename_redirects ()
734 vector<boost::shared_ptr<Redirect> > to_be_renamed;
736 get_selected_redirects (to_be_renamed);
738 if (to_be_renamed.empty()) {
742 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
743 rename_redirect (*i);
748 RedirectBox::cut_redirects ()
750 vector<boost::shared_ptr<Redirect> > to_be_removed;
752 get_selected_redirects (to_be_removed);
754 if (to_be_removed.empty()) {
758 /* this essentially transfers ownership of the redirect
759 of the redirect from the route to the mixer
763 _rr_selection.set (to_be_removed);
765 no_redirect_redisplay = true;
766 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
767 // Do not cut inserts or sends
768 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0) {
769 void* gui = (*i)->get_gui ();
772 static_cast<Gtk::Widget*>(gui)->hide ();
775 if (_route->remove_redirect (*i, this)) {
777 _rr_selection.remove (*i);
780 _rr_selection.remove (*i);
784 no_redirect_redisplay = false;
785 redisplay_redirects (this);
789 RedirectBox::copy_redirects ()
791 vector<boost::shared_ptr<Redirect> > to_be_copied;
792 vector<boost::shared_ptr<Redirect> > copies;
794 get_selected_redirects (to_be_copied);
796 if (to_be_copied.empty()) {
800 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
801 // Do not copy inserts or sends
802 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0) {
803 copies.push_back (Redirect::clone (*i));
807 _rr_selection.set (copies);
812 RedirectBox::delete_redirects ()
814 vector<boost::shared_ptr<Redirect> > to_be_deleted;
816 get_selected_redirects (to_be_deleted);
818 if (to_be_deleted.empty()) {
822 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_deleted.begin(); i != to_be_deleted.end(); ++i) {
824 void* gui = (*i)->get_gui ();
827 static_cast<Gtk::Widget*>(gui)->hide ();
830 _route->remove_redirect( *i, this);
833 no_redirect_redisplay = false;
834 redisplay_redirects (this);
838 RedirectBox::idle_delete_redirect (boost::weak_ptr<Redirect> weak_redirect)
840 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
846 /* NOT copied to _mixer.selection() */
848 no_redirect_redisplay = true;
849 _route->remove_redirect (redirect, this);
850 no_redirect_redisplay = false;
851 redisplay_redirects (this);
857 RedirectBox::rename_redirect (boost::shared_ptr<Redirect> redirect)
859 ArdourPrompter name_prompter (true);
861 name_prompter.set_prompt (_("rename redirect"));
862 name_prompter.set_initial_text (redirect->name());
863 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
864 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
865 name_prompter.show_all ();
867 switch (name_prompter.run ()) {
869 case Gtk::RESPONSE_ACCEPT:
870 name_prompter.get_result (result);
871 if (result.length()) {
872 redirect->set_name (result, this);
881 RedirectBox::cut_redirect (boost::shared_ptr<Redirect> redirect)
883 /* this essentially transfers ownership of the redirect
884 of the redirect from the route to the mixer
888 _rr_selection.add (redirect);
890 void* gui = redirect->get_gui ();
893 static_cast<Gtk::Widget*>(gui)->hide ();
896 no_redirect_redisplay = true;
897 if (_route->remove_redirect (redirect, this)) {
898 _rr_selection.remove (redirect);
900 no_redirect_redisplay = false;
901 redisplay_redirects (this);
905 RedirectBox::copy_redirect (boost::shared_ptr<Redirect> redirect)
907 boost::shared_ptr<Redirect> copy = Redirect::clone (redirect);
908 _rr_selection.add (copy);
912 RedirectBox::paste_redirects ()
914 if (_rr_selection.redirects.empty()) {
918 paste_redirect_list (_rr_selection.redirects);
922 RedirectBox::paste_redirect_list (list<boost::shared_ptr<Redirect> >& redirects)
924 list<boost::shared_ptr<Redirect> > copies;
926 for (list<boost::shared_ptr<Redirect> >::iterator i = redirects.begin(); i != redirects.end(); ++i) {
928 boost::shared_ptr<Redirect> copy = Redirect::clone (*i);
930 copy->set_placement (_placement, this);
931 copies.push_back (copy);
934 if (_route->add_redirects (copies, this)) {
937 "Copying the set of redirects on the clipboard failed,\n\
938 probably because the I/O configuration of the plugins\n\
939 could not match the configuration of this track.");
940 MessageDialog am (msg);
946 RedirectBox::activate_redirect (boost::shared_ptr<Redirect> r)
948 r->set_active (true, 0);
952 RedirectBox::deactivate_redirect (boost::shared_ptr<Redirect> r)
954 r->set_active (false, 0);
958 RedirectBox::get_selected_redirects (vector<boost::shared_ptr<Redirect> >& redirects)
960 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
962 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
963 redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
968 RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>))
970 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
972 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
973 boost::shared_ptr<Redirect> redirect = (*(model->get_iter(*iter)))[columns.redirect];
974 (this->*pmf)(redirect);
979 RedirectBox::clone_redirects ()
981 RouteSelection& routes (_rr_selection.routes);
983 if (!routes.empty()) {
984 if (_route->copy_redirects (*routes.front(), _placement)) {
986 "Copying the set of redirects on the clipboard failed,\n\
987 probably because the I/O configuration of the plugins\n\
988 could not match the configuration of this track.");
989 MessageDialog am (msg);
996 RedirectBox::all_redirects_active (bool state)
998 _route->all_redirects_active (_placement, state);
1002 RedirectBox::all_plugins_active (bool state)
1005 // XXX not implemented
1007 _route->disable_plugins (_placement);
1012 RedirectBox::ab_plugins ()
1014 _route->ab_plugins (ab_direction);
1015 ab_direction = !ab_direction;
1019 RedirectBox::clear_redirects ()
1022 vector<string> choices;
1024 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1025 if (_placement == PreFader) {
1026 prompt = _("Do you really want to remove all pre-fader redirects from this track?\n"
1027 "(this cannot be undone)");
1029 prompt = _("Do you really want to remove all post-fader redirects from this track?\n"
1030 "(this cannot be undone)");
1033 if (_placement == PreFader) {
1034 prompt = _("Do you really want to remove all pre-fader redirects from this bus?\n"
1035 "(this cannot be undone)");
1037 prompt = _("Do you really want to remove all post-fader redirects from this bus?\n"
1038 "(this cannot be undone)");
1042 choices.push_back (_("Cancel"));
1043 choices.push_back (_("Yes, remove them all"));
1045 Gtkmm2ext::Choice prompter (prompt, choices);
1047 if (prompter.run () == 1) {
1048 _route->clear_redirects (_placement, this);
1053 RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
1055 boost::shared_ptr<Insert> insert;
1057 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1059 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1064 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) == 0) {
1068 if (!_session.engine().connected()) {
1072 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (redirect);
1074 SendUIWindow *send_ui;
1076 if (send->get_gui() == 0) {
1078 send_ui = new SendUIWindow (send, _session);
1080 WindowTitle title(Glib::get_application_name());
1081 title += send->name();
1082 send_ui->set_title (title.get_string());
1084 send->set_gui (send_ui);
1087 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
1090 if (send_ui->is_visible()) {
1091 send_ui->get_window()->raise ();
1093 send_ui->show_all ();
1094 send_ui->present ();
1099 /* it's an insert */
1101 boost::shared_ptr<PluginInsert> plugin_insert;
1102 boost::shared_ptr<PortInsert> port_insert;
1104 if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (insert)) != 0) {
1106 ARDOUR::PluginType type = plugin_insert->type();
1108 if (type == ARDOUR::LADSPA || type == ARDOUR::VST) {
1109 PluginUIWindow *plugin_ui;
1111 if (plugin_insert->get_gui() == 0) {
1113 plugin_ui = new PluginUIWindow (plugin_insert);
1115 if (_owner_is_mixer) {
1116 ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui);
1118 ARDOUR_UI::instance()->the_editor().ensure_float (*plugin_ui);
1121 WindowTitle title(Glib::get_application_name());
1122 title += generate_redirect_title (plugin_insert);
1123 plugin_ui->set_title (title.get_string());
1125 plugin_insert->set_gui (plugin_ui);
1127 // change window title when route name is changed
1128 _route->name_changed.connect (bind (mem_fun(*this, &RedirectBox::route_name_changed), plugin_ui, boost::weak_ptr<PluginInsert> (plugin_insert)));
1132 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
1135 if (plugin_ui->is_visible()) {
1136 plugin_ui->get_window()->raise ();
1138 plugin_ui->show_all ();
1139 plugin_ui->present ();
1141 #ifdef HAVE_AUDIOUNIT
1142 } else if (type == ARDOUR::AudioUnit) {
1143 AUPluginUI* plugin_ui;
1144 if (plugin_insert->get_gui() == 0) {
1145 plugin_ui = new AUPluginUI (plugin_insert);
1147 plugin_ui = reinterpret_cast<AUPluginUI*> (plugin_insert->get_gui());
1150 if (plugin_ui->is_visible()) {
1151 plugin_ui->get_window()->raise ();
1153 plugin_ui->show_all ();
1154 plugin_ui->present ();
1158 warning << "Unsupported plugin sent to RedirectBox::edit_redirect()" << endmsg;
1162 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
1164 if (!_session.engine().connected()) {
1165 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1170 PortInsertWindow *io_selector;
1172 if (port_insert->get_gui() == 0) {
1173 io_selector = new PortInsertWindow (_session, port_insert);
1174 port_insert->set_gui (io_selector);
1177 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1180 if (io_selector->is_visible()) {
1181 io_selector->get_window()->raise ();
1183 io_selector->show_all ();
1184 io_selector->present ();
1191 RedirectBox::enter_box (GdkEventCrossing *ev, RedirectBox* rb)
1193 switch (ev->detail) {
1194 case GDK_NOTIFY_INFERIOR:
1197 case GDK_NOTIFY_VIRTUAL:
1201 _current_redirect_box = rb;
1208 RedirectBox::register_actions ()
1210 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("redirectmenu"));
1211 Glib::RefPtr<Action> act;
1214 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin ..."), sigc::ptr_fun (RedirectBox::rb_choose_plugin));
1216 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"), sigc::ptr_fun (RedirectBox::rb_choose_insert));
1217 ActionManager::jack_sensitive_actions.push_back (act);
1218 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."), sigc::ptr_fun (RedirectBox::rb_choose_send));
1219 ActionManager::jack_sensitive_actions.push_back (act);
1221 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear"), sigc::ptr_fun (RedirectBox::rb_clear));
1223 /* standard editing stuff */
1224 act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"), sigc::ptr_fun (RedirectBox::rb_cut));
1225 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1226 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"), sigc::ptr_fun (RedirectBox::rb_copy));
1227 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1229 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"), sigc::ptr_fun (RedirectBox::rb_delete));
1230 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
1232 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"), sigc::ptr_fun (RedirectBox::rb_paste));
1233 act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"), sigc::ptr_fun (RedirectBox::rb_rename));
1234 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1235 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"), sigc::ptr_fun (RedirectBox::rb_select_all));
1236 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"), sigc::ptr_fun (RedirectBox::rb_deselect_all));
1239 act = ActionManager::register_action (popup_act_grp, X_("activate"), _("Activate"), sigc::ptr_fun (RedirectBox::rb_activate));
1240 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1241 act = ActionManager::register_action (popup_act_grp, X_("deactivate"), _("Deactivate"), sigc::ptr_fun (RedirectBox::rb_deactivate));
1242 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1243 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"), sigc::ptr_fun (RedirectBox::rb_activate_all));
1244 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"), sigc::ptr_fun (RedirectBox::rb_deactivate_all));
1246 ActionManager::register_action (popup_act_grp, X_("a_b_plugins"), _("A/B plugins"), sigc::ptr_fun (RedirectBox::rb_ab_plugins));
1247 ActionManager::register_action (popup_act_grp, X_("deactivate_plugins"), _("Deactivate plugins"), sigc::ptr_fun (RedirectBox::rb_deactivate_plugins));
1250 act = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit"), sigc::ptr_fun (RedirectBox::rb_edit));
1251 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1253 ActionManager::add_action_group (popup_act_grp);
1259 RedirectBox::rb_choose_plugin ()
1261 if (_current_redirect_box == 0) {
1264 _current_redirect_box->choose_plugin ();
1268 RedirectBox::rb_choose_insert ()
1270 if (_current_redirect_box == 0) {
1273 _current_redirect_box->choose_insert ();
1277 RedirectBox::rb_choose_send ()
1279 if (_current_redirect_box == 0) {
1282 _current_redirect_box->choose_send ();
1286 RedirectBox::rb_clear ()
1288 if (_current_redirect_box == 0) {
1292 _current_redirect_box->clear_redirects ();
1296 RedirectBox::rb_cut ()
1298 if (_current_redirect_box == 0) {
1302 _current_redirect_box->cut_redirects ();
1306 RedirectBox::rb_delete ()
1308 if (_current_redirect_box == 0) {
1312 _current_redirect_box->delete_redirects ();
1316 RedirectBox::rb_copy ()
1318 if (_current_redirect_box == 0) {
1321 _current_redirect_box->copy_redirects ();
1325 RedirectBox::rb_paste ()
1327 if (_current_redirect_box == 0) {
1331 _current_redirect_box->paste_redirects ();
1335 RedirectBox::rb_rename ()
1337 if (_current_redirect_box == 0) {
1340 _current_redirect_box->rename_redirects ();
1344 RedirectBox::rb_select_all ()
1346 if (_current_redirect_box == 0) {
1350 _current_redirect_box->select_all_redirects ();
1354 RedirectBox::rb_deselect_all ()
1356 if (_current_redirect_box == 0) {
1360 _current_redirect_box->deselect_all_redirects ();
1364 RedirectBox::rb_activate ()
1366 if (_current_redirect_box == 0) {
1370 _current_redirect_box->for_selected_redirects (&RedirectBox::activate_redirect);
1374 RedirectBox::rb_deactivate ()
1376 if (_current_redirect_box == 0) {
1379 _current_redirect_box->for_selected_redirects (&RedirectBox::deactivate_redirect);
1383 RedirectBox::rb_activate_all ()
1385 if (_current_redirect_box == 0) {
1389 _current_redirect_box->all_redirects_active (true);
1393 RedirectBox::rb_deactivate_all ()
1395 if (_current_redirect_box == 0) {
1398 _current_redirect_box->all_redirects_active (false);
1402 RedirectBox::rb_deactivate_plugins ()
1404 if (_current_redirect_box == 0) {
1407 _current_redirect_box->all_plugins_active (false);
1412 RedirectBox::rb_ab_plugins ()
1414 if (_current_redirect_box == 0) {
1418 _current_redirect_box->ab_plugins ();
1423 RedirectBox::rb_edit ()
1425 if (_current_redirect_box == 0) {
1429 _current_redirect_box->for_selected_redirects (&RedirectBox::edit_redirect);
1433 RedirectBox::route_name_changed (void* src, PluginUIWindow* plugin_ui, boost::weak_ptr<PluginInsert> wpi)
1435 ENSURE_GUI_THREAD(bind (mem_fun (*this, &RedirectBox::route_name_changed), src, plugin_ui, wpi));
1436 boost::shared_ptr<PluginInsert> pi (wpi.lock());
1440 WindowTitle title(Glib::get_application_name());
1441 title += generate_redirect_title (pi);
1442 plugin_ui->set_title (title.get_string());
1447 RedirectBox::generate_redirect_title (boost::shared_ptr<PluginInsert> pi)
1449 string maker = pi->plugin()->maker();
1450 string::size_type email_pos;
1452 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1453 maker = maker.substr (0, email_pos - 1);
1456 if (maker.length() > 32) {
1457 maker = maker.substr (0, 32);
1461 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);