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 <gtkmm/messagedialog.h>
29 #include <gtkmm2ext/gtk_ui.h>
30 #include <gtkmm2ext/utils.h>
31 #include <gtkmm2ext/choice.h>
32 #include <gtkmm2ext/utils.h>
33 #include <gtkmm2ext/stop_signal.h>
34 #include <gtkmm2ext/doi.h>
36 #include <ardour/ardour.h>
37 #include <ardour/session.h>
38 #include <ardour/audioengine.h>
39 #include <ardour/route.h>
40 #include <ardour/audio_track.h>
41 #include <ardour/audio_diskstream.h>
42 #include <ardour/send.h>
43 #include <ardour/insert.h>
44 #include <ardour/ladspa_plugin.h>
45 #include <ardour/connection.h>
46 #include <ardour/session_connection.h>
48 #include "ardour_ui.h"
49 #include "ardour_dialog.h"
50 #include "public_editor.h"
51 #include "redirect_box.h"
53 #include "plugin_selector.h"
54 #include "route_redirect_selection.h"
57 #include "plugin_ui.h"
59 #include "io_selector.h"
61 #include "gui_thread.h"
66 #include "au_pluginui.h"
70 using namespace ARDOUR;
74 using namespace Gtkmm2ext;
76 RedirectBox* RedirectBox::_current_redirect_box = 0;
77 RefPtr<Action> RedirectBox::paste_action;
78 bool RedirectBox::get_colors = true;
79 Gdk::Color* RedirectBox::active_redirect_color;
80 Gdk::Color* RedirectBox::inactive_redirect_color;
82 RedirectBox::RedirectBox (Placement pcmnt, Session& sess, boost::shared_ptr<Route> rt, PluginSelector &plugsel,
83 RouteRedirectSelection & rsel, bool owner_is_mixer)
86 _owner_is_mixer (owner_is_mixer),
88 _plugin_selector(plugsel),
92 active_redirect_color = new Gdk::Color;
93 inactive_redirect_color = new Gdk::Color;
94 set_color (*active_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_ACTIVE, false ));
95 set_color (*inactive_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false ));
101 send_action_menu = 0;
102 redirect_drag_in_progress = false;
103 no_redirect_redisplay = false;
104 ignore_delete = false;
106 model = ListStore::create(columns);
108 RefPtr<TreeSelection> selection = redirect_display.get_selection();
109 selection->set_mode (Gtk::SELECTION_MULTIPLE);
110 selection->signal_changed().connect (mem_fun (*this, &RedirectBox::selection_changed));
112 redirect_display.set_model (model);
113 redirect_display.append_column (X_("notshown"), columns.text);
114 redirect_display.set_name ("RedirectSelector");
115 redirect_display.set_headers_visible (false);
116 redirect_display.set_reorderable (true);
117 redirect_display.set_size_request (-1, 40);
118 redirect_display.get_column(0)->set_sizing(TREE_VIEW_COLUMN_FIXED);
119 redirect_display.get_column(0)->set_fixed_width(48);
120 redirect_display.add_object_drag (columns.redirect.index(), "redirects");
121 redirect_display.signal_object_drop.connect (mem_fun (*this, &RedirectBox::object_drop));
123 TreeViewColumn* name_col = redirect_display.get_column(0);
124 CellRendererText* renderer = dynamic_cast<CellRendererText*>(redirect_display.get_column_cell_renderer (0));
125 name_col->add_attribute(renderer->property_foreground_gdk(), columns.color);
127 redirect_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
129 model->signal_row_deleted().connect (mem_fun (*this, &RedirectBox::row_deleted));
131 redirect_scroller.add (redirect_display);
132 redirect_eventbox.add (redirect_scroller);
134 redirect_scroller.set_size_request (-1, 40);
136 pack_start (redirect_eventbox, true, true);
138 _route->redirects_changed.connect (mem_fun(*this, &RedirectBox::redisplay_redirects));
139 _route->GoingAway.connect (mem_fun (*this, &RedirectBox::route_going_away));
141 redirect_eventbox.signal_enter_notify_event().connect (bind (sigc::ptr_fun (RedirectBox::enter_box), this));
143 redirect_display.signal_button_press_event().connect (mem_fun(*this, &RedirectBox::redirect_button_press_event), false);
144 redirect_display.signal_button_release_event().connect (mem_fun(*this, &RedirectBox::redirect_button_release_event));
146 /* start off as a passthru strip. we'll correct this, if necessary,
147 in update_diskstream_display().
150 /* now force an update of all the various elements */
152 redisplay_redirects (0);
155 RedirectBox::~RedirectBox ()
160 RedirectBox::route_going_away ()
162 /* don't keep updating display as redirects are deleted */
163 no_redirect_redisplay = true;
167 RedirectBox::object_drop (string type, uint32_t cnt, const boost::shared_ptr<Redirect>* ptr)
169 if (type != "redirects" || cnt == 0 || !ptr) {
173 /* do something with the dropped redirects */
175 list<boost::shared_ptr<Redirect> > redirects;
177 for (uint32_t n = 0; n < cnt; ++n) {
178 redirects.push_back (ptr[n]);
181 paste_redirect_list (redirects);
185 RedirectBox::update()
187 redisplay_redirects (0);
192 RedirectBox::set_width (Width w)
199 redisplay_redirects (0);
203 RedirectBox::remove_redirect_gui (boost::shared_ptr<Redirect> redirect)
205 boost::shared_ptr<Insert> insert;
206 boost::shared_ptr<Send> send;
207 boost::shared_ptr<PortInsert> port_insert;
209 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) != 0) {
211 if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
212 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
213 port_insert->set_gui (0);
217 } else if ((send = boost::dynamic_pointer_cast<Send> (insert)) != 0) {
218 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
225 RedirectBox::build_send_action_menu ()
228 using namespace Menu_Helpers;
230 send_action_menu = new Menu;
231 send_action_menu->set_name ("ArdourContextMenu");
232 MenuList& items = send_action_menu->items();
234 items.push_back (MenuElem (_("New send"), mem_fun(*this, &RedirectBox::new_send)));
235 items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &RedirectBox::show_send_controls)));
239 RedirectBox::show_send_controls ()
245 RedirectBox::new_send ()
251 RedirectBox::show_redirect_menu (gint arg)
253 if (redirect_menu == 0) {
254 redirect_menu = build_redirect_menu ();
257 paste_action->set_sensitive (!_rr_selection.redirects.empty());
259 redirect_menu->popup (1, arg);
263 RedirectBox::redirect_drag_begin (GdkDragContext *context)
265 redirect_drag_in_progress = true;
269 RedirectBox::redirect_drag_end (GdkDragContext *context)
271 redirect_drag_in_progress = false;
275 RedirectBox::redirect_button_press_event (GdkEventButton *ev)
278 TreeModel::Path path;
279 TreeViewColumn* column;
282 boost::shared_ptr<Redirect> redirect;
284 bool selected = false;
286 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
287 if ((iter = model->get_iter (path))) {
288 redirect = (*iter)[columns.redirect];
289 selected = redirect_display.get_selection()->is_selected (iter);
294 if (redirect && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS && ev->state == 0))) {
296 if (_session.engine().connected()) {
297 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
298 edit_redirect (redirect);
302 } else if (redirect && ev->button == 1 && selected) {
304 // this is purely informational but necessary
305 RedirectSelected (redirect); // emit
312 RedirectBox::redirect_button_release_event (GdkEventButton *ev)
315 TreeModel::Path path;
316 TreeViewColumn* column;
319 boost::shared_ptr<Redirect> redirect;
323 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
324 if ((iter = model->get_iter (path))) {
325 redirect = (*iter)[columns.redirect];
329 if (redirect && Keyboard::is_delete_event (ev)) {
331 Glib::signal_idle().connect (bind (mem_fun(*this, &RedirectBox::idle_delete_redirect), boost::weak_ptr<Redirect>(redirect)));
334 } else if (Keyboard::is_context_menu_event (ev)) {
336 show_redirect_menu(ev->time);
339 } else if (redirect && ev->button == 2 && ev->state == GDK_BUTTON2_MASK) {
341 redirect->set_active (!redirect->active(), this);
350 RedirectBox::build_redirect_menu ()
352 redirect_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/redirectmenu") );
353 redirect_menu->set_name ("ArdourContextMenu");
357 return redirect_menu;
361 RedirectBox::selection_changed ()
363 bool sensitive = (redirect_display.get_selection()->count_selected_rows()) ? true : false;
364 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
368 RedirectBox::select_all_redirects ()
370 redirect_display.get_selection()->select_all();
374 RedirectBox::deselect_all_redirects ()
376 redirect_display.get_selection()->unselect_all();
380 RedirectBox::choose_plugin ()
382 sigc::connection newplug_connection = _plugin_selector.PluginCreated.connect (mem_fun(*this,&RedirectBox::insert_plugin_chosen));
383 _plugin_selector.show_all();
384 _plugin_selector.run ();
385 newplug_connection.disconnect();
389 RedirectBox::insert_plugin_chosen (boost::shared_ptr<Plugin> plugin)
393 boost::shared_ptr<Redirect> redirect (new PluginInsert (_session, plugin, _placement));
395 redirect->active_changed.connect (bind (mem_fun (*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect)));
397 uint32_t err_streams;
399 if (_route->add_redirect (redirect, this, &err_streams)) {
400 weird_plugin_dialog (*plugin, err_streams, _route);
401 // XXX SHAREDPTR delete plugin here .. do we even need to care?
407 RedirectBox::weird_plugin_dialog (Plugin& p, uint32_t streams, boost::shared_ptr<IO> io)
409 ArdourDialog dialog (_("ardour: weird plugin dialog"));
412 /* i hate this kind of code */
414 if (streams > p.get_info()->n_inputs) {
415 label.set_text (string_compose (_(
416 "You attempted to add a plugin (%1).\n"
417 "The plugin has %2 inputs\n"
418 "but at the insertion point, there are\n"
419 "%3 active signal streams.\n"
421 "This makes no sense - you are throwing away\n"
422 "part of the signal."),
424 p.get_info()->n_inputs,
426 } else if (streams < p.get_info()->n_inputs) {
427 label.set_text (string_compose (_(
428 "You attempted to add a plugin (%1).\n"
429 "The plugin has %2 inputs\n"
430 "but at the insertion point there are\n"
431 "only %3 active signal streams.\n"
433 "This makes no sense - unless the plugin supports\n"
434 "side-chain inputs. A future version of Ardour will\n"
435 "support this type of configuration."),
437 p.get_info()->n_inputs,
440 label.set_text (string_compose (_(
441 "You attempted to add a plugin (%1).\n"
443 "The I/O configuration doesn't make sense:\n"
445 "The plugin has %2 inputs and %3 outputs.\n"
446 "The track/bus has %4 inputs and %5 outputs.\n"
447 "The insertion point, has %6 active signals.\n"
449 "Ardour does not understand what to do in such situations.\n"),
451 p.get_info()->n_inputs,
452 p.get_info()->n_outputs,
453 io->n_inputs().get_total(),
454 io->n_outputs().get_total(),
458 dialog.get_vbox()->pack_start (label);
459 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
461 dialog.set_name (X_("PluginIODialog"));
462 dialog.set_position (Gtk::WIN_POS_MOUSE);
463 dialog.set_modal (true);
470 RedirectBox::choose_insert ()
472 boost::shared_ptr<Redirect> redirect (new PortInsert (_session, _placement));
473 redirect->active_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect)));
474 _route->add_redirect (redirect, this);
478 RedirectBox::choose_send ()
480 boost::shared_ptr<Send> send (new Send (_session, _placement));
481 send->set_default_type(_route->default_type());
483 /* XXX need redirect lock on route */
485 send->ensure_io (ChanCount::ZERO, _route->max_redirect_outs(), false, this);
487 IOSelectorWindow *ios = new IOSelectorWindow (_session, send, false, true);
491 boost::shared_ptr<Redirect> r = boost::static_pointer_cast<Redirect>(send);
493 ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), boost::weak_ptr<Redirect>(r), ios));
497 RedirectBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Redirect> weak_redirect, IOSelectorWindow* ios)
499 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
506 case IOSelector::Cancelled:
507 // redirect will go away when all shared_ptrs to it vanish
510 case IOSelector::Accepted:
511 _route->add_redirect (redirect, this);
515 delete_when_idle (ios);
519 RedirectBox::redisplay_redirects (void *src)
521 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::redisplay_redirects), src));
523 if (no_redirect_redisplay) {
527 ignore_delete = true;
529 ignore_delete = false;
531 redirect_active_connections.clear ();
532 redirect_name_connections.clear ();
534 void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>) = &RedirectBox::add_redirect_to_display;
535 _route->foreach_redirect (this, pmf);
537 switch (_placement) {
539 build_redirect_tooltip(redirect_eventbox, _("Pre-fader inserts, sends & plugins:"));
542 build_redirect_tooltip(redirect_eventbox, _("Post-fader inserts, sends & plugins:"));
548 RedirectBox::add_redirect_to_display (boost::shared_ptr<Redirect> redirect)
550 if (redirect->placement() != _placement) {
554 Gtk::TreeModel::Row row = *(model->append());
555 row[columns.text] = redirect_name (redirect);
556 row[columns.redirect] = redirect;
558 show_redirect_active (redirect);
560 redirect_active_connections.push_back (redirect->active_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect))));
561 redirect_name_connections.push_back (redirect->name_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_name), boost::weak_ptr<Redirect>(redirect))));
565 RedirectBox::redirect_name (boost::weak_ptr<Redirect> weak_redirect)
567 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
573 boost::shared_ptr<Send> send;
576 if (!redirect->active()) {
580 if ((send = boost::dynamic_pointer_cast<Send> (redirect)) != 0) {
584 /* grab the send name out of its overall name */
586 string::size_type lbracket, rbracket;
587 lbracket = send->name().find ('[');
588 rbracket = send->name().find (']');
592 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
595 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
603 name_display += redirect->name();
606 name_display += PBD::short_version (redirect->name(), 5);
612 if (!redirect->active()) {
620 RedirectBox::build_redirect_tooltip (EventBox& box, string start)
624 Gtk::TreeModel::Children children = model->children();
625 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
626 Gtk::TreeModel::Row row = *iter;
628 tip += row[columns.text];
630 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
634 RedirectBox::show_redirect_name (void* src, boost::weak_ptr<Redirect> redirect)
636 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_name), src, redirect));
637 show_redirect_active (redirect);
641 RedirectBox::show_redirect_active_r (Redirect* r, void *src, boost::weak_ptr<Redirect> weak_redirect)
643 show_redirect_active (weak_redirect);
647 RedirectBox::show_redirect_active (boost::weak_ptr<Redirect> weak_redirect)
649 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_active), weak_redirect));
651 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
657 Gtk::TreeModel::Children children = model->children();
658 Gtk::TreeModel::Children::iterator iter = children.begin();
660 while (iter != children.end()) {
662 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
665 (*iter)[columns.text] = redirect_name (r);
667 if (redirect->active()) {
668 (*iter)[columns.color] = *active_redirect_color;
670 (*iter)[columns.color] = *inactive_redirect_color;
680 RedirectBox::row_deleted (const Gtk::TreeModel::Path& path)
682 if (!ignore_delete) {
683 compute_redirect_sort_keys ();
688 RedirectBox::compute_redirect_sort_keys ()
690 uint32_t sort_key = 0;
691 Gtk::TreeModel::Children children = model->children();
693 for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
694 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
695 r->set_sort_key (sort_key);
699 if (_route->sort_redirects ()) {
701 redisplay_redirects (0);
703 /* now tell them about the problem */
705 ArdourDialog dialog (_("ardour: weird plugin dialog"));
709 You cannot reorder this set of redirects\n\
710 in that way because the inputs and\n\
711 outputs do not work correctly."));
713 dialog.get_vbox()->pack_start (label);
714 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
716 dialog.set_name (X_("PluginIODialog"));
717 dialog.set_position (Gtk::WIN_POS_MOUSE);
718 dialog.set_modal (true);
726 RedirectBox::rename_redirects ()
728 vector<boost::shared_ptr<Redirect> > to_be_renamed;
730 get_selected_redirects (to_be_renamed);
732 if (to_be_renamed.empty()) {
736 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
737 rename_redirect (*i);
742 RedirectBox::cut_redirects ()
744 vector<boost::shared_ptr<Redirect> > to_be_removed;
746 get_selected_redirects (to_be_removed);
748 if (to_be_removed.empty()) {
752 /* this essentially transfers ownership of the redirect
753 of the redirect from the route to the mixer
757 _rr_selection.set (to_be_removed);
759 no_redirect_redisplay = true;
760 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
762 void* gui = (*i)->get_gui ();
765 static_cast<Gtk::Widget*>(gui)->hide ();
768 if (_route->remove_redirect (*i, this)) {
770 _rr_selection.remove (*i);
774 no_redirect_redisplay = false;
775 redisplay_redirects (this);
779 RedirectBox::copy_redirects ()
781 vector<boost::shared_ptr<Redirect> > to_be_copied;
782 vector<boost::shared_ptr<Redirect> > copies;
784 get_selected_redirects (to_be_copied);
786 if (to_be_copied.empty()) {
790 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
791 copies.push_back (Redirect::clone (*i));
794 _rr_selection.set (copies);
798 RedirectBox::idle_delete_redirect (boost::weak_ptr<Redirect> weak_redirect)
800 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
806 /* NOT copied to _mixer.selection() */
808 no_redirect_redisplay = true;
809 _route->remove_redirect (redirect, this);
810 no_redirect_redisplay = false;
811 redisplay_redirects (this);
817 RedirectBox::rename_redirect (boost::shared_ptr<Redirect> redirect)
819 ArdourPrompter name_prompter (true);
821 name_prompter.set_prompt (_("rename redirect"));
822 name_prompter.set_initial_text (redirect->name());
823 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
824 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
825 name_prompter.show_all ();
827 switch (name_prompter.run ()) {
829 case Gtk::RESPONSE_ACCEPT:
830 name_prompter.get_result (result);
831 if (result.length()) {
832 redirect->set_name (result, this);
841 RedirectBox::cut_redirect (boost::shared_ptr<Redirect> redirect)
843 /* this essentially transfers ownership of the redirect
844 of the redirect from the route to the mixer
848 _rr_selection.add (redirect);
850 void* gui = redirect->get_gui ();
853 static_cast<Gtk::Widget*>(gui)->hide ();
856 no_redirect_redisplay = true;
857 if (_route->remove_redirect (redirect, this)) {
858 _rr_selection.remove (redirect);
860 no_redirect_redisplay = false;
861 redisplay_redirects (this);
865 RedirectBox::copy_redirect (boost::shared_ptr<Redirect> redirect)
867 boost::shared_ptr<Redirect> copy = Redirect::clone (redirect);
868 _rr_selection.add (copy);
872 RedirectBox::paste_redirects ()
874 if (_rr_selection.redirects.empty()) {
878 paste_redirect_list (_rr_selection.redirects);
882 RedirectBox::paste_redirect_list (list<boost::shared_ptr<Redirect> >& redirects)
884 list<boost::shared_ptr<Redirect> > copies;
886 for (list<boost::shared_ptr<Redirect> >::iterator i = redirects.begin(); i != redirects.end(); ++i) {
888 boost::shared_ptr<Redirect> copy = Redirect::clone (*i);
890 copy->set_placement (_placement, this);
891 copies.push_back (copy);
894 if (_route->add_redirects (copies, this)) {
897 "Copying the set of redirects on the clipboard failed,\n\
898 probably because the I/O configuration of the plugins\n\
899 could not match the configuration of this track.");
900 MessageDialog am (msg);
906 RedirectBox::activate_redirect (boost::shared_ptr<Redirect> r)
908 r->set_active (true, 0);
912 RedirectBox::deactivate_redirect (boost::shared_ptr<Redirect> r)
914 r->set_active (false, 0);
918 RedirectBox::get_selected_redirects (vector<boost::shared_ptr<Redirect> >& redirects)
920 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
922 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
923 redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
928 RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>))
930 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
932 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
933 boost::shared_ptr<Redirect> redirect = (*(model->get_iter(*iter)))[columns.redirect];
934 (this->*pmf)(redirect);
939 RedirectBox::clone_redirects ()
941 RouteSelection& routes (_rr_selection.routes);
943 if (!routes.empty()) {
944 if (_route->copy_redirects (*routes.front(), _placement)) {
946 "Copying the set of redirects on the clipboard failed,\n\
947 probably because the I/O configuration of the plugins\n\
948 could not match the configuration of this track.");
949 MessageDialog am (msg);
956 RedirectBox::all_redirects_active (bool state)
958 _route->all_redirects_active (state);
962 RedirectBox::clear_redirects()
965 vector<string> choices;
967 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
968 prompt = _("Do you really want to remove all redirects from this track?\n"
969 "(this cannot be undone)");
971 prompt = _("Do you really want to remove all redirects from this bus?\n"
972 "(this cannot be undone)");
975 choices.push_back (_("Cancel"));
976 choices.push_back (_("Yes, remove them all"));
978 Gtkmm2ext::Choice prompter (prompt, choices);
980 if (prompter.run () == 1) {
981 _route->clear_redirects (this);
986 RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
988 boost::shared_ptr<Insert> insert;
990 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
992 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
997 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) == 0) {
1001 if (!_session.engine().connected()) {
1005 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (redirect);
1007 SendUIWindow *send_ui;
1009 if (send->get_gui() == 0) {
1012 title = string_compose(_("ardour: %1"), send->name());
1014 send_ui = new SendUIWindow (send, _session);
1015 send_ui->set_title (title);
1016 send->set_gui (send_ui);
1019 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
1022 if (send_ui->is_visible()) {
1023 send_ui->get_window()->raise ();
1025 send_ui->show_all ();
1030 /* it's an insert */
1032 boost::shared_ptr<PluginInsert> plugin_insert;
1033 boost::shared_ptr<PortInsert> port_insert;
1035 if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (insert)) != 0) {
1037 ARDOUR::PluginType type = plugin_insert->type();
1039 if (type == ARDOUR::LADSPA || type == ARDOUR::VST) {
1040 PluginUIWindow *plugin_ui;
1042 if (plugin_insert->get_gui() == 0) {
1044 plugin_ui = new PluginUIWindow (plugin_insert);
1046 if (_owner_is_mixer) {
1047 ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui);
1049 ARDOUR_UI::instance()->the_editor().ensure_float (*plugin_ui);
1052 plugin_ui->set_title (generate_redirect_title (plugin_insert));
1053 plugin_insert->set_gui (plugin_ui);
1055 // change window title when route name is changed
1056 _route->name_changed.connect (bind (mem_fun(*this, &RedirectBox::route_name_changed), plugin_ui, boost::weak_ptr<PluginInsert> (plugin_insert)));
1060 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
1063 if (plugin_ui->is_visible()) {
1064 plugin_ui->get_window()->raise ();
1066 plugin_ui->show_all ();
1068 #ifdef HAVE_AUDIOUNIT
1069 } else if (type == ARDOUR::AudioUnit) {
1070 AUPluginUI* plugin_ui;
1071 if (plugin_insert->get_gui() == 0) {
1072 plugin_ui = new AUPluginUI (plugin_insert);
1074 plugin_ui = reinterpret_cast<AUPluginUI*> (plugin_insert->get_gui());
1077 // raise window, somehow
1080 warning << "Unsupported plugin sent to RedirectBox::edit_redirect()" << endmsg;
1084 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
1086 if (!_session.engine().connected()) {
1087 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1092 PortInsertWindow *io_selector;
1094 if (port_insert->get_gui() == 0) {
1095 io_selector = new PortInsertWindow (_session, port_insert);
1096 port_insert->set_gui (io_selector);
1099 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1102 if (io_selector->is_visible()) {
1103 io_selector->get_window()->raise ();
1105 io_selector->show_all ();
1112 RedirectBox::enter_box (GdkEventCrossing *ev, RedirectBox* rb)
1114 switch (ev->detail) {
1115 case GDK_NOTIFY_INFERIOR:
1118 case GDK_NOTIFY_VIRTUAL:
1122 _current_redirect_box = rb;
1129 RedirectBox::register_actions ()
1131 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("redirectmenu"));
1132 Glib::RefPtr<Action> act;
1135 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin ..."), sigc::ptr_fun (RedirectBox::rb_choose_plugin));
1137 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"), sigc::ptr_fun (RedirectBox::rb_choose_insert));
1138 ActionManager::jack_sensitive_actions.push_back (act);
1139 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."), sigc::ptr_fun (RedirectBox::rb_choose_send));
1140 ActionManager::jack_sensitive_actions.push_back (act);
1142 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear"), sigc::ptr_fun (RedirectBox::rb_clear));
1144 /* standard editing stuff */
1145 act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"), sigc::ptr_fun (RedirectBox::rb_cut));
1146 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1147 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"), sigc::ptr_fun (RedirectBox::rb_copy));
1148 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1149 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"), sigc::ptr_fun (RedirectBox::rb_paste));
1150 act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"), sigc::ptr_fun (RedirectBox::rb_rename));
1151 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1152 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"), sigc::ptr_fun (RedirectBox::rb_select_all));
1153 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"), sigc::ptr_fun (RedirectBox::rb_deselect_all));
1156 act = ActionManager::register_action (popup_act_grp, X_("activate"), _("Activate"), sigc::ptr_fun (RedirectBox::rb_activate));
1157 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1158 act = ActionManager::register_action (popup_act_grp, X_("deactivate"), _("Deactivate"), sigc::ptr_fun (RedirectBox::rb_deactivate));
1159 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1160 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"), sigc::ptr_fun (RedirectBox::rb_activate_all));
1161 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"), sigc::ptr_fun (RedirectBox::rb_deactivate_all));
1164 act = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit"), sigc::ptr_fun (RedirectBox::rb_edit));
1165 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1167 ActionManager::add_action_group (popup_act_grp);
1173 RedirectBox::rb_choose_plugin ()
1175 if (_current_redirect_box == 0) {
1178 _current_redirect_box->choose_plugin ();
1182 RedirectBox::rb_choose_insert ()
1184 if (_current_redirect_box == 0) {
1187 _current_redirect_box->choose_insert ();
1191 RedirectBox::rb_choose_send ()
1193 if (_current_redirect_box == 0) {
1196 _current_redirect_box->choose_send ();
1200 RedirectBox::rb_clear ()
1202 if (_current_redirect_box == 0) {
1206 _current_redirect_box->clear_redirects ();
1210 RedirectBox::rb_cut ()
1212 if (_current_redirect_box == 0) {
1216 _current_redirect_box->cut_redirects ();
1220 RedirectBox::rb_copy ()
1222 if (_current_redirect_box == 0) {
1225 _current_redirect_box->copy_redirects ();
1229 RedirectBox::rb_paste ()
1231 if (_current_redirect_box == 0) {
1235 _current_redirect_box->paste_redirects ();
1239 RedirectBox::rb_rename ()
1241 if (_current_redirect_box == 0) {
1244 _current_redirect_box->rename_redirects ();
1248 RedirectBox::rb_select_all ()
1250 if (_current_redirect_box == 0) {
1254 _current_redirect_box->select_all_redirects ();
1258 RedirectBox::rb_deselect_all ()
1260 if (_current_redirect_box == 0) {
1264 _current_redirect_box->deselect_all_redirects ();
1268 RedirectBox::rb_activate ()
1270 if (_current_redirect_box == 0) {
1274 _current_redirect_box->for_selected_redirects (&RedirectBox::activate_redirect);
1278 RedirectBox::rb_deactivate ()
1280 if (_current_redirect_box == 0) {
1283 _current_redirect_box->for_selected_redirects (&RedirectBox::deactivate_redirect);
1287 RedirectBox::rb_activate_all ()
1289 if (_current_redirect_box == 0) {
1293 _current_redirect_box->all_redirects_active (true);
1297 RedirectBox::rb_deactivate_all ()
1299 if (_current_redirect_box == 0) {
1302 _current_redirect_box->all_redirects_active (false);
1306 RedirectBox::rb_edit ()
1308 if (_current_redirect_box == 0) {
1312 _current_redirect_box->for_selected_redirects (&RedirectBox::edit_redirect);
1316 RedirectBox::route_name_changed (void* src, PluginUIWindow* plugin_ui, boost::weak_ptr<PluginInsert> wpi)
1318 ENSURE_GUI_THREAD(bind (mem_fun (*this, &RedirectBox::route_name_changed), src, plugin_ui, wpi));
1319 boost::shared_ptr<PluginInsert> pi (wpi.lock());
1321 plugin_ui->set_title (generate_redirect_title (pi));
1326 RedirectBox::generate_redirect_title (boost::shared_ptr<PluginInsert> pi)
1328 string maker = pi->plugin()->maker();
1329 string::size_type email_pos;
1331 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1332 maker = maker.substr (0, email_pos - 1);
1335 if (maker.length() > 32) {
1336 maker = maker.substr (0, 32);
1340 return string_compose(_("ardour: %1: %2 (by %3)"), _route->name(), pi->name(), maker);