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>
48 #include <ardour/connection.h>
49 #include <ardour/session_connection.h>
51 #include "ardour_ui.h"
52 #include "ardour_dialog.h"
53 #include "public_editor.h"
54 #include "redirect_box.h"
56 #include "plugin_selector.h"
57 #include "route_redirect_selection.h"
60 #include "plugin_ui.h"
62 #include "io_selector.h"
64 #include "gui_thread.h"
68 #ifdef HAVE_AUDIOUNITS
73 using namespace ARDOUR;
77 using namespace Gtkmm2ext;
79 RedirectBox* RedirectBox::_current_redirect_box = 0;
80 RefPtr<Action> RedirectBox::paste_action;
81 bool RedirectBox::get_colors = true;
82 Gdk::Color* RedirectBox::active_redirect_color;
83 Gdk::Color* RedirectBox::inactive_redirect_color;
85 RedirectBox::RedirectBox (Placement pcmnt, Session& sess, boost::shared_ptr<Route> rt, PluginSelector &plugsel,
86 RouteRedirectSelection & rsel, bool owner_is_mixer)
89 _owner_is_mixer (owner_is_mixer),
91 _plugin_selector(plugsel),
95 active_redirect_color = new Gdk::Color;
96 inactive_redirect_color = new Gdk::Color;
97 set_color (*active_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_ACTIVE, false ));
98 set_color (*inactive_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false ));
104 send_action_menu = 0;
105 redirect_drag_in_progress = false;
106 no_redirect_redisplay = false;
107 ignore_delete = false;
109 model = ListStore::create(columns);
111 RefPtr<TreeSelection> selection = redirect_display.get_selection();
112 selection->set_mode (Gtk::SELECTION_MULTIPLE);
113 selection->signal_changed().connect (mem_fun (*this, &RedirectBox::selection_changed));
115 redirect_display.set_model (model);
116 redirect_display.append_column (X_("notshown"), columns.text);
117 redirect_display.set_name ("RedirectSelector");
118 redirect_display.set_headers_visible (false);
119 redirect_display.set_reorderable (true);
120 redirect_display.set_size_request (-1, 40);
121 redirect_display.get_column(0)->set_sizing(TREE_VIEW_COLUMN_FIXED);
122 redirect_display.get_column(0)->set_fixed_width(48);
123 redirect_display.add_object_drag (columns.redirect.index(), "redirects");
124 redirect_display.signal_object_drop.connect (mem_fun (*this, &RedirectBox::object_drop));
126 TreeViewColumn* name_col = redirect_display.get_column(0);
127 CellRendererText* renderer = dynamic_cast<CellRendererText*>(redirect_display.get_column_cell_renderer (0));
128 name_col->add_attribute(renderer->property_foreground_gdk(), columns.color);
130 redirect_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
132 model->signal_row_deleted().connect (mem_fun (*this, &RedirectBox::row_deleted));
134 redirect_scroller.add (redirect_display);
135 redirect_eventbox.add (redirect_scroller);
137 redirect_scroller.set_size_request (-1, 40);
139 pack_start (redirect_eventbox, true, true);
141 _route->redirects_changed.connect (mem_fun(*this, &RedirectBox::redisplay_redirects));
142 _route->GoingAway.connect (mem_fun (*this, &RedirectBox::route_going_away));
144 redirect_eventbox.signal_enter_notify_event().connect (bind (sigc::ptr_fun (RedirectBox::enter_box), this));
146 redirect_display.signal_button_press_event().connect (mem_fun(*this, &RedirectBox::redirect_button_press_event), false);
147 redirect_display.signal_button_release_event().connect (mem_fun(*this, &RedirectBox::redirect_button_release_event));
149 /* start off as a passthru strip. we'll correct this, if necessary,
150 in update_diskstream_display().
153 /* now force an update of all the various elements */
155 redisplay_redirects (0);
158 RedirectBox::~RedirectBox ()
163 RedirectBox::route_going_away ()
165 /* don't keep updating display as redirects are deleted */
166 no_redirect_redisplay = true;
170 RedirectBox::object_drop (string type, uint32_t cnt, const boost::shared_ptr<Redirect>* ptr)
172 if (type != "redirects" || cnt == 0 || !ptr) {
176 /* do something with the dropped redirects */
178 list<boost::shared_ptr<Redirect> > redirects;
180 for (uint32_t n = 0; n < cnt; ++n) {
181 redirects.push_back (ptr[n]);
184 paste_redirect_list (redirects);
188 RedirectBox::update()
190 redisplay_redirects (0);
195 RedirectBox::set_width (Width w)
202 redisplay_redirects (0);
206 RedirectBox::remove_redirect_gui (boost::shared_ptr<Redirect> redirect)
208 boost::shared_ptr<Insert> insert;
209 boost::shared_ptr<Send> send;
210 boost::shared_ptr<PortInsert> port_insert;
212 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) != 0) {
214 if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
215 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
216 port_insert->set_gui (0);
220 } else if ((send = boost::dynamic_pointer_cast<Send> (insert)) != 0) {
221 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
228 RedirectBox::build_send_action_menu ()
231 using namespace Menu_Helpers;
233 send_action_menu = new Menu;
234 send_action_menu->set_name ("ArdourContextMenu");
235 MenuList& items = send_action_menu->items();
237 items.push_back (MenuElem (_("New send"), mem_fun(*this, &RedirectBox::new_send)));
238 items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &RedirectBox::show_send_controls)));
242 RedirectBox::show_send_controls ()
248 RedirectBox::new_send ()
254 RedirectBox::show_redirect_menu (gint arg)
256 if (redirect_menu == 0) {
257 redirect_menu = build_redirect_menu ();
260 paste_action->set_sensitive (!_rr_selection.redirects.empty());
262 redirect_menu->popup (1, arg);
266 RedirectBox::redirect_drag_begin (GdkDragContext *context)
268 redirect_drag_in_progress = true;
272 RedirectBox::redirect_drag_end (GdkDragContext *context)
274 redirect_drag_in_progress = false;
278 RedirectBox::redirect_button_press_event (GdkEventButton *ev)
281 TreeModel::Path path;
282 TreeViewColumn* column;
285 boost::shared_ptr<Redirect> redirect;
287 bool selected = false;
289 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
290 if ((iter = model->get_iter (path))) {
291 redirect = (*iter)[columns.redirect];
292 selected = redirect_display.get_selection()->is_selected (iter);
297 if (redirect && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
299 if (_session.engine().connected()) {
300 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
301 edit_redirect (redirect);
305 } else if (redirect && ev->button == 1 && selected) {
307 // this is purely informational but necessary
308 RedirectSelected (redirect); // emit
315 RedirectBox::redirect_button_release_event (GdkEventButton *ev)
318 TreeModel::Path path;
319 TreeViewColumn* column;
322 boost::shared_ptr<Redirect> redirect;
326 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
327 if ((iter = model->get_iter (path))) {
328 redirect = (*iter)[columns.redirect];
332 if (redirect && Keyboard::is_delete_event (ev)) {
334 Glib::signal_idle().connect (bind (mem_fun(*this, &RedirectBox::idle_delete_redirect), boost::weak_ptr<Redirect>(redirect)));
337 } else if (Keyboard::is_context_menu_event (ev)) {
339 show_redirect_menu(ev->time);
342 } else if (redirect && (ev->button == 2) && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))) {
344 /* button2-click with no modifiers */
346 redirect->set_active (!redirect->active(), this);
355 RedirectBox::build_redirect_menu ()
357 redirect_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/redirectmenu") );
358 redirect_menu->set_name ("ArdourContextMenu");
362 return redirect_menu;
366 RedirectBox::selection_changed ()
368 bool sensitive = (redirect_display.get_selection()->count_selected_rows()) ? true : false;
369 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
373 RedirectBox::select_all_redirects ()
375 redirect_display.get_selection()->select_all();
379 RedirectBox::deselect_all_redirects ()
381 redirect_display.get_selection()->unselect_all();
385 RedirectBox::choose_plugin ()
387 sigc::connection newplug_connection = _plugin_selector.PluginCreated.connect (mem_fun(*this,&RedirectBox::insert_plugin_chosen));
388 _plugin_selector.show_all();
389 _plugin_selector.run ();
390 newplug_connection.disconnect();
394 RedirectBox::insert_plugin_chosen (boost::shared_ptr<Plugin> plugin)
398 boost::shared_ptr<Redirect> redirect (new PluginInsert (_session, plugin, _placement));
400 uint32_t err_streams;
402 if (_route->add_redirect (redirect, this, &err_streams)) {
403 weird_plugin_dialog (*plugin, err_streams, _route);
405 redirect->active_changed.connect (bind (mem_fun (*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect)));
411 RedirectBox::weird_plugin_dialog (Plugin& p, uint32_t streams, boost::shared_ptr<IO> io)
413 ArdourDialog dialog (_("ardour: weird plugin dialog"));
416 /* i hate this kind of code */
418 if (streams > p.get_info()->n_inputs) {
419 label.set_text (string_compose (_(
420 "You attempted to add a plugin (%1).\n"
421 "The plugin has %2 inputs\n"
422 "but at the insertion point, there are\n"
423 "%3 active signal streams.\n"
425 "This makes no sense - you are throwing away\n"
426 "part of the signal."),
428 p.get_info()->n_inputs,
430 } else if (streams < p.get_info()->n_inputs) {
431 label.set_text (string_compose (_(
432 "You attempted to add a plugin (%1).\n"
433 "The plugin has %2 inputs\n"
434 "but at the insertion point there are\n"
435 "only %3 active signal streams.\n"
437 "This makes no sense - unless the plugin supports\n"
438 "side-chain inputs. A future version of Ardour will\n"
439 "support this type of configuration."),
441 p.get_info()->n_inputs,
444 label.set_text (string_compose (_(
445 "You attempted to add a plugin (%1).\n"
447 "The I/O configuration doesn't make sense:\n"
449 "The plugin has %2 inputs and %3 outputs.\n"
450 "The track/bus has %4 inputs and %5 outputs.\n"
451 "The insertion point, has %6 active signals.\n"
453 "Ardour does not understand what to do in such situations.\n"),
455 p.get_info()->n_inputs,
456 p.get_info()->n_outputs,
462 dialog.get_vbox()->pack_start (label);
463 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
465 dialog.set_name (X_("PluginIODialog"));
466 dialog.set_position (Gtk::WIN_POS_MOUSE);
467 dialog.set_modal (true);
474 RedirectBox::choose_insert ()
476 boost::shared_ptr<Redirect> redirect (new PortInsert (_session, _placement));
477 redirect->active_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect)));
478 _route->add_redirect (redirect, this);
482 RedirectBox::choose_send ()
484 boost::shared_ptr<Send> send (new Send (_session, _placement));
486 /* XXX need redirect lock on route */
488 send->ensure_io (0, _route->max_redirect_outs(), false, this);
490 IOSelectorWindow *ios = new IOSelectorWindow (_session, send, false, true);
494 boost::shared_ptr<Redirect> r = boost::static_pointer_cast<Redirect>(send);
496 ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), boost::weak_ptr<Redirect>(r), ios));
500 RedirectBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Redirect> weak_redirect, IOSelectorWindow* ios)
502 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
509 case IOSelector::Cancelled:
510 // redirect will go away when all shared_ptrs to it vanish
513 case IOSelector::Accepted:
514 _route->add_redirect (redirect, this);
518 delete_when_idle (ios);
522 RedirectBox::redisplay_redirects (void *src)
524 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::redisplay_redirects), src));
526 if (no_redirect_redisplay) {
530 ignore_delete = true;
532 ignore_delete = false;
534 redirect_active_connections.clear ();
535 redirect_name_connections.clear ();
537 void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>) = &RedirectBox::add_redirect_to_display;
538 _route->foreach_redirect (this, pmf);
540 switch (_placement) {
542 build_redirect_tooltip(redirect_eventbox, _("Pre-fader inserts, sends & plugins:"));
545 build_redirect_tooltip(redirect_eventbox, _("Post-fader inserts, sends & plugins:"));
551 RedirectBox::add_redirect_to_display (boost::shared_ptr<Redirect> redirect)
553 if (redirect->placement() != _placement) {
557 Gtk::TreeModel::Row row = *(model->append());
558 row[columns.text] = redirect_name (redirect);
559 row[columns.redirect] = redirect;
561 show_redirect_active (redirect);
563 redirect_active_connections.push_back (redirect->active_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect))));
564 redirect_name_connections.push_back (redirect->name_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_name), boost::weak_ptr<Redirect>(redirect))));
568 RedirectBox::redirect_name (boost::weak_ptr<Redirect> weak_redirect)
570 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
576 boost::shared_ptr<Send> send;
579 if (!redirect->active()) {
583 if ((send = boost::dynamic_pointer_cast<Send> (redirect)) != 0) {
587 /* grab the send name out of its overall name */
589 string::size_type lbracket, rbracket;
590 lbracket = send->name().find ('[');
591 rbracket = send->name().find (']');
595 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
598 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
606 name_display += redirect->name();
609 name_display += PBD::short_version (redirect->name(), 5);
615 if (!redirect->active()) {
623 RedirectBox::build_redirect_tooltip (EventBox& box, string start)
627 Gtk::TreeModel::Children children = model->children();
628 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
629 Gtk::TreeModel::Row row = *iter;
631 tip += row[columns.text];
633 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
637 RedirectBox::show_redirect_name (void* src, boost::weak_ptr<Redirect> redirect)
639 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_name), src, redirect));
640 show_redirect_active (redirect);
644 RedirectBox::show_redirect_active_r (Redirect* r, void *src, boost::weak_ptr<Redirect> weak_redirect)
646 show_redirect_active (weak_redirect);
650 RedirectBox::show_redirect_active (boost::weak_ptr<Redirect> weak_redirect)
652 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
658 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_active), weak_redirect));
660 Gtk::TreeModel::Children children = model->children();
661 Gtk::TreeModel::Children::iterator iter = children.begin();
663 while (iter != children.end()) {
665 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
668 (*iter)[columns.text] = redirect_name (r);
670 if (redirect->active()) {
671 (*iter)[columns.color] = *active_redirect_color;
673 (*iter)[columns.color] = *inactive_redirect_color;
683 RedirectBox::row_deleted (const Gtk::TreeModel::Path& path)
685 if (!ignore_delete) {
686 compute_redirect_sort_keys ();
691 RedirectBox::compute_redirect_sort_keys ()
693 uint32_t sort_key = 0;
694 Gtk::TreeModel::Children children = model->children();
696 for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
697 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
698 r->set_sort_key (sort_key);
702 if (_route->sort_redirects ()) {
704 redisplay_redirects (0);
706 /* now tell them about the problem */
708 ArdourDialog dialog (_("ardour: weird plugin dialog"));
712 You cannot reorder this set of redirects\n\
713 in that way because the inputs and\n\
714 outputs do not work correctly."));
716 dialog.get_vbox()->pack_start (label);
717 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
719 dialog.set_name (X_("PluginIODialog"));
720 dialog.set_position (Gtk::WIN_POS_MOUSE);
721 dialog.set_modal (true);
729 RedirectBox::rename_redirects ()
731 vector<boost::shared_ptr<Redirect> > to_be_renamed;
733 get_selected_redirects (to_be_renamed);
735 if (to_be_renamed.empty()) {
739 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
740 rename_redirect (*i);
745 RedirectBox::cut_redirects ()
747 vector<boost::shared_ptr<Redirect> > to_be_removed;
749 get_selected_redirects (to_be_removed);
751 if (to_be_removed.empty()) {
755 /* this essentially transfers ownership of the redirect
756 of the redirect from the route to the mixer
760 _rr_selection.set (to_be_removed);
762 no_redirect_redisplay = true;
763 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
764 // Do not cut inserts or sends
765 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0) {
766 void* gui = (*i)->get_gui ();
769 static_cast<Gtk::Widget*>(gui)->hide ();
772 if (_route->remove_redirect (*i, this)) {
774 _rr_selection.remove (*i);
777 _rr_selection.remove (*i);
781 no_redirect_redisplay = false;
782 redisplay_redirects (this);
786 RedirectBox::copy_redirects ()
788 vector<boost::shared_ptr<Redirect> > to_be_copied;
789 vector<boost::shared_ptr<Redirect> > copies;
791 get_selected_redirects (to_be_copied);
793 if (to_be_copied.empty()) {
797 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
798 // Do not copy inserts or sends
799 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0) {
800 copies.push_back (Redirect::clone (*i));
804 _rr_selection.set (copies);
809 RedirectBox::delete_redirects ()
811 vector<boost::shared_ptr<Redirect> > to_be_deleted;
813 get_selected_redirects (to_be_deleted);
815 if (to_be_deleted.empty()) {
819 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_deleted.begin(); i != to_be_deleted.end(); ++i) {
821 void* gui = (*i)->get_gui ();
824 static_cast<Gtk::Widget*>(gui)->hide ();
827 _route->remove_redirect( *i, this);
830 no_redirect_redisplay = false;
831 redisplay_redirects (this);
835 RedirectBox::idle_delete_redirect (boost::weak_ptr<Redirect> weak_redirect)
837 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
843 /* NOT copied to _mixer.selection() */
845 no_redirect_redisplay = true;
846 _route->remove_redirect (redirect, this);
847 no_redirect_redisplay = false;
848 redisplay_redirects (this);
854 RedirectBox::rename_redirect (boost::shared_ptr<Redirect> redirect)
856 ArdourPrompter name_prompter (true);
858 name_prompter.set_prompt (_("rename redirect"));
859 name_prompter.set_initial_text (redirect->name());
860 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
861 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
862 name_prompter.show_all ();
864 switch (name_prompter.run ()) {
866 case Gtk::RESPONSE_ACCEPT:
867 name_prompter.get_result (result);
868 if (result.length()) {
869 redirect->set_name (result, this);
878 RedirectBox::cut_redirect (boost::shared_ptr<Redirect> redirect)
880 /* this essentially transfers ownership of the redirect
881 of the redirect from the route to the mixer
885 _rr_selection.add (redirect);
887 void* gui = redirect->get_gui ();
890 static_cast<Gtk::Widget*>(gui)->hide ();
893 no_redirect_redisplay = true;
894 if (_route->remove_redirect (redirect, this)) {
895 _rr_selection.remove (redirect);
897 no_redirect_redisplay = false;
898 redisplay_redirects (this);
902 RedirectBox::copy_redirect (boost::shared_ptr<Redirect> redirect)
904 boost::shared_ptr<Redirect> copy = Redirect::clone (redirect);
905 _rr_selection.add (copy);
909 RedirectBox::paste_redirects ()
911 if (_rr_selection.redirects.empty()) {
915 paste_redirect_list (_rr_selection.redirects);
919 RedirectBox::paste_redirect_list (list<boost::shared_ptr<Redirect> >& redirects)
921 list<boost::shared_ptr<Redirect> > copies;
923 for (list<boost::shared_ptr<Redirect> >::iterator i = redirects.begin(); i != redirects.end(); ++i) {
925 boost::shared_ptr<Redirect> copy = Redirect::clone (*i);
927 copy->set_placement (_placement, this);
928 copies.push_back (copy);
931 if (_route->add_redirects (copies, this)) {
934 "Copying the set of redirects on the clipboard failed,\n\
935 probably because the I/O configuration of the plugins\n\
936 could not match the configuration of this track.");
937 MessageDialog am (msg);
943 RedirectBox::activate_redirect (boost::shared_ptr<Redirect> r)
945 r->set_active (true, 0);
949 RedirectBox::deactivate_redirect (boost::shared_ptr<Redirect> r)
951 r->set_active (false, 0);
955 RedirectBox::get_selected_redirects (vector<boost::shared_ptr<Redirect> >& redirects)
957 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
959 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
960 redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
965 RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>))
967 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
969 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
970 boost::shared_ptr<Redirect> redirect = (*(model->get_iter(*iter)))[columns.redirect];
971 (this->*pmf)(redirect);
976 RedirectBox::clone_redirects ()
978 RouteSelection& routes (_rr_selection.routes);
980 if (!routes.empty()) {
981 if (_route->copy_redirects (*routes.front(), _placement)) {
983 "Copying the set of redirects on the clipboard failed,\n\
984 probably because the I/O configuration of the plugins\n\
985 could not match the configuration of this track.");
986 MessageDialog am (msg);
993 RedirectBox::all_redirects_active (bool state)
995 _route->all_redirects_active (_placement, state);
999 RedirectBox::clear_redirects ()
1002 vector<string> choices;
1004 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1005 if (_placement == PreFader) {
1006 prompt = _("Do you really want to remove all pre-fader redirects from this track?\n"
1007 "(this cannot be undone)");
1009 prompt = _("Do you really want to remove all post-fader redirects from this track?\n"
1010 "(this cannot be undone)");
1013 if (_placement == PreFader) {
1014 prompt = _("Do you really want to remove all pre-fader redirects from this bus?\n"
1015 "(this cannot be undone)");
1017 prompt = _("Do you really want to remove all post-fader redirects from this bus?\n"
1018 "(this cannot be undone)");
1022 choices.push_back (_("Cancel"));
1023 choices.push_back (_("Yes, remove them all"));
1025 Gtkmm2ext::Choice prompter (prompt, choices);
1027 if (prompter.run () == 1) {
1028 _route->clear_redirects (_placement, this);
1033 RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
1035 boost::shared_ptr<Insert> insert;
1037 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1039 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1044 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) == 0) {
1048 if (!_session.engine().connected()) {
1052 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (redirect);
1054 SendUIWindow *send_ui;
1056 if (send->get_gui() == 0) {
1058 send_ui = new SendUIWindow (send, _session);
1060 WindowTitle title(Glib::get_application_name());
1061 title += send->name();
1062 send_ui->set_title (title.get_string());
1064 send->set_gui (send_ui);
1067 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
1070 if (send_ui->is_visible()) {
1071 send_ui->get_window()->raise ();
1073 send_ui->show_all ();
1074 send_ui->present ();
1079 /* it's an insert */
1081 boost::shared_ptr<PluginInsert> plugin_insert;
1082 boost::shared_ptr<PortInsert> port_insert;
1084 if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (insert)) != 0) {
1086 PluginUIWindow *plugin_ui;
1088 if (plugin_insert->get_gui() == 0) {
1090 plugin_ui = new PluginUIWindow (plugin_insert);
1092 if (_owner_is_mixer) {
1093 ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui);
1095 ARDOUR_UI::instance()->the_editor().ensure_float (*plugin_ui);
1098 WindowTitle title(Glib::get_application_name());
1099 title += generate_redirect_title (plugin_insert);
1100 plugin_ui->set_title (title.get_string());
1102 plugin_insert->set_gui (plugin_ui);
1104 // change window title when route name is changed
1105 _route->name_changed.connect (bind (mem_fun(*this, &RedirectBox::route_name_changed), plugin_ui, boost::weak_ptr<PluginInsert> (plugin_insert)));
1109 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
1112 if (plugin_ui->is_visible()) {
1113 plugin_ui->get_window()->raise ();
1115 plugin_ui->show_all ();
1116 plugin_ui->present ();
1119 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
1121 if (!_session.engine().connected()) {
1122 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1127 PortInsertWindow *io_selector;
1129 if (port_insert->get_gui() == 0) {
1130 io_selector = new PortInsertWindow (_session, port_insert);
1131 port_insert->set_gui (io_selector);
1134 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1137 if (io_selector->is_visible()) {
1138 io_selector->get_window()->raise ();
1140 io_selector->show_all ();
1141 io_selector->present ();
1148 RedirectBox::enter_box (GdkEventCrossing *ev, RedirectBox* rb)
1150 switch (ev->detail) {
1151 case GDK_NOTIFY_INFERIOR:
1154 case GDK_NOTIFY_VIRTUAL:
1158 _current_redirect_box = rb;
1165 RedirectBox::register_actions ()
1167 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("redirectmenu"));
1168 Glib::RefPtr<Action> act;
1171 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin ..."), sigc::ptr_fun (RedirectBox::rb_choose_plugin));
1173 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"), sigc::ptr_fun (RedirectBox::rb_choose_insert));
1174 ActionManager::jack_sensitive_actions.push_back (act);
1175 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."), sigc::ptr_fun (RedirectBox::rb_choose_send));
1176 ActionManager::jack_sensitive_actions.push_back (act);
1178 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear"), sigc::ptr_fun (RedirectBox::rb_clear));
1180 /* standard editing stuff */
1181 act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"), sigc::ptr_fun (RedirectBox::rb_cut));
1182 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1183 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"), sigc::ptr_fun (RedirectBox::rb_copy));
1184 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1186 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"), sigc::ptr_fun (RedirectBox::rb_delete));
1187 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
1189 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"), sigc::ptr_fun (RedirectBox::rb_paste));
1190 act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"), sigc::ptr_fun (RedirectBox::rb_rename));
1191 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1192 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"), sigc::ptr_fun (RedirectBox::rb_select_all));
1193 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"), sigc::ptr_fun (RedirectBox::rb_deselect_all));
1196 act = ActionManager::register_action (popup_act_grp, X_("activate"), _("Activate"), sigc::ptr_fun (RedirectBox::rb_activate));
1197 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1198 act = ActionManager::register_action (popup_act_grp, X_("deactivate"), _("Deactivate"), sigc::ptr_fun (RedirectBox::rb_deactivate));
1199 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1200 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"), sigc::ptr_fun (RedirectBox::rb_activate_all));
1201 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"), sigc::ptr_fun (RedirectBox::rb_deactivate_all));
1204 act = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit"), sigc::ptr_fun (RedirectBox::rb_edit));
1205 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1207 ActionManager::add_action_group (popup_act_grp);
1213 RedirectBox::rb_choose_plugin ()
1215 if (_current_redirect_box == 0) {
1218 _current_redirect_box->choose_plugin ();
1222 RedirectBox::rb_choose_insert ()
1224 if (_current_redirect_box == 0) {
1227 _current_redirect_box->choose_insert ();
1231 RedirectBox::rb_choose_send ()
1233 if (_current_redirect_box == 0) {
1236 _current_redirect_box->choose_send ();
1240 RedirectBox::rb_clear ()
1242 if (_current_redirect_box == 0) {
1246 _current_redirect_box->clear_redirects ();
1250 RedirectBox::rb_cut ()
1252 if (_current_redirect_box == 0) {
1256 _current_redirect_box->cut_redirects ();
1260 RedirectBox::rb_delete ()
1262 if (_current_redirect_box == 0) {
1266 _current_redirect_box->delete_redirects ();
1270 RedirectBox::rb_copy ()
1272 if (_current_redirect_box == 0) {
1275 _current_redirect_box->copy_redirects ();
1279 RedirectBox::rb_paste ()
1281 if (_current_redirect_box == 0) {
1285 _current_redirect_box->paste_redirects ();
1289 RedirectBox::rb_rename ()
1291 if (_current_redirect_box == 0) {
1294 _current_redirect_box->rename_redirects ();
1298 RedirectBox::rb_select_all ()
1300 if (_current_redirect_box == 0) {
1304 _current_redirect_box->select_all_redirects ();
1308 RedirectBox::rb_deselect_all ()
1310 if (_current_redirect_box == 0) {
1314 _current_redirect_box->deselect_all_redirects ();
1318 RedirectBox::rb_activate ()
1320 if (_current_redirect_box == 0) {
1324 _current_redirect_box->for_selected_redirects (&RedirectBox::activate_redirect);
1328 RedirectBox::rb_deactivate ()
1330 if (_current_redirect_box == 0) {
1333 _current_redirect_box->for_selected_redirects (&RedirectBox::deactivate_redirect);
1337 RedirectBox::rb_activate_all ()
1339 if (_current_redirect_box == 0) {
1343 _current_redirect_box->all_redirects_active (true);
1347 RedirectBox::rb_deactivate_all ()
1349 if (_current_redirect_box == 0) {
1352 _current_redirect_box->all_redirects_active (false);
1356 RedirectBox::rb_edit ()
1358 if (_current_redirect_box == 0) {
1362 _current_redirect_box->for_selected_redirects (&RedirectBox::edit_redirect);
1366 RedirectBox::route_name_changed (void* src, PluginUIWindow* plugin_ui, boost::weak_ptr<PluginInsert> wpi)
1368 ENSURE_GUI_THREAD(bind (mem_fun (*this, &RedirectBox::route_name_changed), src, plugin_ui, wpi));
1369 boost::shared_ptr<PluginInsert> pi (wpi.lock());
1373 WindowTitle title(Glib::get_application_name());
1374 title += generate_redirect_title (pi);
1375 plugin_ui->set_title (title.get_string());
1380 RedirectBox::generate_redirect_title (boost::shared_ptr<PluginInsert> pi)
1382 string maker = pi->plugin()->maker();
1383 string::size_type email_pos;
1385 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1386 maker = maker.substr (0, email_pos - 1);
1389 if (maker.length() > 32) {
1390 maker = maker.substr (0, 32);
1394 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);