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));
140 redirect_eventbox.signal_enter_notify_event().connect (bind (sigc::ptr_fun (RedirectBox::enter_box), this));
142 redirect_display.signal_button_press_event().connect (mem_fun(*this, &RedirectBox::redirect_button_press_event), false);
143 redirect_display.signal_button_release_event().connect (mem_fun(*this, &RedirectBox::redirect_button_press_event));
145 /* start off as a passthru strip. we'll correct this, if necessary,
146 in update_diskstream_display().
149 /* now force an update of all the various elements */
151 redisplay_redirects (0);
154 RedirectBox::~RedirectBox ()
159 RedirectBox::object_drop (string type, uint32_t cnt, const boost::shared_ptr<Redirect>* ptr)
161 if (type != "redirects" || cnt == 0 || !ptr) {
165 /* do something with the dropped redirects */
167 list<boost::shared_ptr<Redirect> > redirects;
169 for (uint32_t n = 0; n < cnt; ++n) {
170 redirects.push_back (ptr[n]);
173 paste_redirect_list (redirects);
177 RedirectBox::update()
179 redisplay_redirects (0);
184 RedirectBox::set_width (Width w)
191 redisplay_redirects (0);
195 RedirectBox::remove_redirect_gui (boost::shared_ptr<Redirect> redirect)
197 boost::shared_ptr<Insert> insert;
198 boost::shared_ptr<Send> send;
199 boost::shared_ptr<PortInsert> port_insert;
201 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) != 0) {
203 if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
204 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
205 port_insert->set_gui (0);
209 } else if ((send = boost::dynamic_pointer_cast<Send> (insert)) != 0) {
210 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
217 RedirectBox::build_send_action_menu ()
220 using namespace Menu_Helpers;
222 send_action_menu = new Menu;
223 send_action_menu->set_name ("ArdourContextMenu");
224 MenuList& items = send_action_menu->items();
226 items.push_back (MenuElem (_("New send"), mem_fun(*this, &RedirectBox::new_send)));
227 items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &RedirectBox::show_send_controls)));
231 RedirectBox::show_send_controls ()
237 RedirectBox::new_send ()
243 RedirectBox::show_redirect_menu (gint arg)
245 if (redirect_menu == 0) {
246 redirect_menu = build_redirect_menu ();
249 paste_action->set_sensitive (!_rr_selection.redirects.empty());
251 redirect_menu->popup (1, arg);
255 RedirectBox::redirect_drag_begin (GdkDragContext *context)
257 redirect_drag_in_progress = true;
261 RedirectBox::redirect_drag_end (GdkDragContext *context)
263 redirect_drag_in_progress = false;
267 RedirectBox::redirect_button_press_event (GdkEventButton *ev)
270 TreeModel::Path path;
271 TreeViewColumn* column;
274 boost::shared_ptr<Redirect> redirect;
276 bool selected = false;
278 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
279 if ((iter = model->get_iter (path))) {
280 redirect = (*iter)[columns.redirect];
281 selected = redirect_display.get_selection()->is_selected (iter);
286 if (redirect && Keyboard::is_delete_event (ev)) {
288 Glib::signal_idle().connect (bind (mem_fun(*this, &RedirectBox::idle_delete_redirect), redirect));
291 } else if (redirect && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS && ev->state == 0))) {
293 if (_session.engine().connected()) {
294 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
295 edit_redirect (redirect);
299 } else if (Keyboard::is_context_menu_event (ev)) {
301 show_redirect_menu(ev->time);
304 } else if (redirect && ev->button == 2 && ev->state == 0) {
306 redirect->set_active (!redirect->active(), this);
310 else if (redirect && ev->button == 1 && selected) {
312 // this is purely informational but necessary
313 RedirectSelected (redirect); // emit
320 RedirectBox::build_redirect_menu ()
322 redirect_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/redirectmenu") );
323 redirect_menu->set_name ("ArdourContextMenu");
327 return redirect_menu;
331 RedirectBox::selection_changed ()
333 bool sensitive = (redirect_display.get_selection()->count_selected_rows()) ? true : false;
334 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
338 RedirectBox::select_all_redirects ()
340 redirect_display.get_selection()->select_all();
344 RedirectBox::deselect_all_redirects ()
346 redirect_display.get_selection()->unselect_all();
350 RedirectBox::choose_plugin ()
352 sigc::connection newplug_connection = _plugin_selector.PluginCreated.connect (mem_fun(*this,&RedirectBox::insert_plugin_chosen));
353 _plugin_selector.show_all();
354 _plugin_selector.run ();
355 newplug_connection.disconnect();
359 RedirectBox::insert_plugin_chosen (boost::shared_ptr<Plugin> plugin)
363 boost::shared_ptr<Redirect> redirect (new PluginInsert (_session, plugin, _placement));
365 redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active));
367 uint32_t err_streams;
369 if (_route->add_redirect (redirect, this, &err_streams)) {
370 wierd_plugin_dialog (*plugin, err_streams, _route);
371 // XXX SHAREDPTR delete plugin here .. do we even need to care?
377 RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, boost::shared_ptr<IO> io)
379 ArdourDialog dialog ("wierd plugin dialog");
382 /* i hate this kind of code */
384 if (streams > p.get_info()->n_inputs) {
385 label.set_text (string_compose (_(
386 "You attempted to add a plugin (%1).\n"
387 "The plugin has %2 inputs\n"
388 "but at the insertion point, there are\n"
389 "%3 active signal streams.\n"
391 "This makes no sense - you are throwing away\n"
392 "part of the signal."),
394 p.get_info()->n_inputs,
396 } else if (streams < p.get_info()->n_inputs) {
397 label.set_text (string_compose (_(
398 "You attempted to add a plugin (%1).\n"
399 "The plugin has %2 inputs\n"
400 "but at the insertion point there are\n"
401 "only %3 active signal streams.\n"
403 "This makes no sense - unless the plugin supports\n"
404 "side-chain inputs. A future version of Ardour will\n"
405 "support this type of configuration."),
407 p.get_info()->n_inputs,
410 label.set_text (string_compose (_(
411 "You attempted to add a plugin (%1).\n"
413 "The I/O configuration doesn't make sense:\n"
415 "The plugin has %2 inputs and %3 outputs.\n"
416 "The track/bus has %4 inputs and %5 outputs.\n"
417 "The insertion point, has %6 active signals.\n"
419 "Ardour does not understand what to do in such situations.\n"),
421 p.get_info()->n_inputs,
422 p.get_info()->n_outputs,
428 dialog.get_vbox()->pack_start (label);
429 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
431 dialog.set_name (X_("PluginIODialog"));
432 dialog.set_position (Gtk::WIN_POS_MOUSE);
433 dialog.set_modal (true);
440 RedirectBox::choose_insert ()
442 boost::shared_ptr<Redirect> redirect (new PortInsert (_session, _placement));
443 redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active));
444 _route->add_redirect (redirect, this);
448 RedirectBox::choose_send ()
450 boost::shared_ptr<Send> send (new Send (_session, _placement));
452 /* XXX need redirect lock on route */
454 send->ensure_io (0, _route->max_redirect_outs(), false, this);
456 IOSelectorWindow *ios = new IOSelectorWindow (_session, send, false, true);
459 ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), boost::static_pointer_cast<Redirect>(send), ios));
463 RedirectBox::send_io_finished (IOSelector::Result r, boost::shared_ptr<Redirect> redirect, IOSelectorWindow* ios)
466 case IOSelector::Cancelled:
467 // delete redirect; XXX SHAREDPTR HOW TO DESTROY THE REDIRECT ? do we even need to think about it?
470 case IOSelector::Accepted:
471 _route->add_redirect (redirect, this);
475 delete_when_idle (ios);
479 RedirectBox::redisplay_redirects (void *src)
481 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::redisplay_redirects), src));
483 if (no_redirect_redisplay) {
487 ignore_delete = true;
489 ignore_delete = false;
491 redirect_active_connections.clear ();
492 redirect_name_connections.clear ();
494 void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>) = &RedirectBox::add_redirect_to_display;
495 _route->foreach_redirect (this, pmf);
497 switch (_placement) {
499 build_redirect_tooltip(redirect_eventbox, _("Pre-fader inserts, sends & plugins:"));
502 build_redirect_tooltip(redirect_eventbox, _("Post-fader inserts, sends & plugins:"));
508 RedirectBox::add_redirect_to_display (boost::shared_ptr<Redirect> redirect)
510 if (redirect->placement() != _placement) {
514 Gtk::TreeModel::Row row = *(model->append());
515 row[columns.text] = redirect_name (redirect);
516 row[columns.redirect] = redirect;
518 show_redirect_active (redirect.get(), this);
520 redirect_active_connections.push_back (redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active)));
521 redirect_name_connections.push_back (redirect->name_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_name), redirect)));
525 RedirectBox::redirect_name (boost::shared_ptr<Redirect> redirect)
527 boost::shared_ptr<Send> send;
530 if (!redirect->active()) {
534 if ((send = boost::dynamic_pointer_cast<Send> (redirect)) != 0) {
538 /* grab the send name out of its overall name */
540 string::size_type lbracket, rbracket;
541 lbracket = send->name().find ('[');
542 rbracket = send->name().find (']');
546 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
549 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
557 name_display += redirect->name();
560 name_display += PBD::short_version (redirect->name(), 5);
566 if (!redirect->active()) {
574 RedirectBox::build_redirect_tooltip (EventBox& box, string start)
578 Gtk::TreeModel::Children children = model->children();
579 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
580 Gtk::TreeModel::Row row = *iter;
582 tip += row[columns.text];
584 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
588 RedirectBox::show_redirect_name (void* src, boost::shared_ptr<Redirect> redirect)
590 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_name), src, redirect));
591 show_redirect_active (redirect.get(), src);
595 RedirectBox::show_redirect_active (Redirect* redirect, void *src)
597 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_active), redirect, src));
599 Gtk::TreeModel::Children children = model->children();
600 Gtk::TreeModel::Children::iterator iter = children.begin();
602 while (iter != children.end()) {
604 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
606 if (r.get() == redirect) {
607 (*iter)[columns.text] = redirect_name (r);
609 if (redirect->active()) {
610 (*iter)[columns.color] = *active_redirect_color;
612 (*iter)[columns.color] = *inactive_redirect_color;
622 RedirectBox::row_deleted (const Gtk::TreeModel::Path& path)
624 if (!ignore_delete) {
625 compute_redirect_sort_keys ();
630 RedirectBox::compute_redirect_sort_keys ()
632 uint32_t sort_key = 0;
633 Gtk::TreeModel::Children children = model->children();
635 for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
636 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
637 r->set_sort_key (sort_key);
641 if (_route->sort_redirects ()) {
643 redisplay_redirects (0);
645 /* now tell them about the problem */
647 ArdourDialog dialog ("wierd plugin dialog");
651 You cannot reorder this set of redirects\n\
652 in that way because the inputs and\n\
653 outputs do not work correctly."));
655 dialog.get_vbox()->pack_start (label);
656 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
658 dialog.set_name (X_("PluginIODialog"));
659 dialog.set_position (Gtk::WIN_POS_MOUSE);
660 dialog.set_modal (true);
668 RedirectBox::rename_redirects ()
670 vector<boost::shared_ptr<Redirect> > to_be_renamed;
672 get_selected_redirects (to_be_renamed);
674 if (to_be_renamed.empty()) {
678 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
679 rename_redirect (*i);
684 RedirectBox::cut_redirects ()
686 vector<boost::shared_ptr<Redirect> > to_be_removed;
688 get_selected_redirects (to_be_removed);
690 if (to_be_removed.empty()) {
694 /* this essentially transfers ownership of the redirect
695 of the redirect from the route to the mixer
699 _rr_selection.set (to_be_removed);
701 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
703 void* gui = (*i)->get_gui ();
706 static_cast<Gtk::Widget*>(gui)->hide ();
709 if (_route->remove_redirect (*i, this)) {
711 _rr_selection.remove (*i);
718 RedirectBox::copy_redirects ()
720 vector<boost::shared_ptr<Redirect> > to_be_copied;
721 vector<boost::shared_ptr<Redirect> > copies;
723 get_selected_redirects (to_be_copied);
725 if (to_be_copied.empty()) {
729 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
730 copies.push_back (Redirect::clone (*i));
733 _rr_selection.set (copies);
737 RedirectBox::idle_delete_redirect (boost::shared_ptr<Redirect> redirect)
739 /* NOT copied to _mixer.selection() */
741 _route->remove_redirect (redirect, this);
746 RedirectBox::rename_redirect (boost::shared_ptr<Redirect> redirect)
748 ArdourPrompter name_prompter (true);
750 name_prompter.set_prompt (_("rename redirect"));
751 name_prompter.set_initial_text (redirect->name());
752 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
753 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
754 name_prompter.show_all ();
756 switch (name_prompter.run ()) {
758 case Gtk::RESPONSE_ACCEPT:
759 name_prompter.get_result (result);
760 if (result.length()) {
761 redirect->set_name (result, this);
771 RedirectBox::cut_redirect (boost::shared_ptr<Redirect> redirect)
773 /* this essentially transfers ownership of the redirect
774 of the redirect from the route to the mixer
778 _rr_selection.add (redirect);
780 void* gui = redirect->get_gui ();
783 static_cast<Gtk::Widget*>(gui)->hide ();
786 if (_route->remove_redirect (redirect, this)) {
787 _rr_selection.remove (redirect);
792 RedirectBox::copy_redirect (boost::shared_ptr<Redirect> redirect)
794 boost::shared_ptr<Redirect> copy = Redirect::clone (redirect);
795 _rr_selection.add (copy);
799 RedirectBox::paste_redirects ()
801 if (_rr_selection.redirects.empty()) {
805 paste_redirect_list (_rr_selection.redirects);
809 RedirectBox::paste_redirect_list (list<boost::shared_ptr<Redirect> >& redirects)
811 list<boost::shared_ptr<Redirect> > copies;
813 for (list<boost::shared_ptr<Redirect> >::iterator i = redirects.begin(); i != redirects.end(); ++i) {
815 boost::shared_ptr<Redirect> copy = Redirect::clone (*i);
817 copy->set_placement (_placement, this);
818 copies.push_back (copy);
821 if (_route->add_redirects (copies, this)) {
824 "Copying the set of redirects on the clipboard failed,\n\
825 probably because the I/O configuration of the plugins\n\
826 could not match the configuration of this track.");
827 MessageDialog am (msg);
833 RedirectBox::activate_redirect (boost::shared_ptr<Redirect> r)
835 r->set_active (true, 0);
839 RedirectBox::deactivate_redirect (boost::shared_ptr<Redirect> r)
841 r->set_active (false, 0);
845 RedirectBox::get_selected_redirects (vector<boost::shared_ptr<Redirect> >& redirects)
847 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
849 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter)
850 redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
854 RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>))
856 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
858 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
859 boost::shared_ptr<Redirect> redirect = (*(model->get_iter(*iter)))[columns.redirect];
860 (this->*pmf)(redirect);
865 RedirectBox::clone_redirects ()
867 RouteSelection& routes (_rr_selection.routes);
869 if (!routes.empty()) {
870 if (_route->copy_redirects (*routes.front(), _placement)) {
872 "Copying the set of redirects on the clipboard failed,\n\
873 probably because the I/O configuration of the plugins\n\
874 could not match the configuration of this track.");
875 MessageDialog am (msg);
882 RedirectBox::all_redirects_active (bool state)
884 _route->all_redirects_active (state);
888 RedirectBox::clear_redirects()
891 vector<string> choices;
893 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
894 prompt = _("Do you really want to remove all redirects from this track?\n"
895 "(this cannot be undone)");
897 prompt = _("Do you really want to remove all redirects from this bus?\n"
898 "(this cannot be undone)");
901 choices.push_back (_("Cancel"));
902 choices.push_back (_("Yes, remove them all"));
904 Gtkmm2ext::Choice prompter (prompt, choices);
906 if (prompter.run () == 1) {
907 _route->clear_redirects (this);
912 RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
914 boost::shared_ptr<Insert> insert;
916 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
918 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
923 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) == 0) {
927 if (!_session.engine().connected()) {
931 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (redirect);
933 SendUIWindow *send_ui;
935 if (send->get_gui() == 0) {
938 title = string_compose(_("ardour: %1"), send->name());
940 send_ui = new SendUIWindow (send, _session);
941 send_ui->set_title (title);
942 send->set_gui (send_ui);
945 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
948 if (send_ui->is_visible()) {
949 send_ui->get_window()->raise ();
951 send_ui->show_all ();
958 boost::shared_ptr<PluginInsert> plugin_insert;
959 boost::shared_ptr<PortInsert> port_insert;
961 if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (insert)) != 0) {
963 ARDOUR::PluginType type = plugin_insert->type();
965 if (type == ARDOUR::LADSPA || type == ARDOUR::VST) {
966 PluginUIWindow *plugin_ui;
968 if (plugin_insert->get_gui() == 0) {
970 plugin_ui = new PluginUIWindow (plugin_insert);
972 if (_owner_is_mixer) {
973 ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui);
975 ARDOUR_UI::instance()->the_editor().ensure_float (*plugin_ui);
978 plugin_ui->set_title (generate_redirect_title (plugin_insert));
979 plugin_insert->set_gui (plugin_ui);
981 // change window title when route name is changed
982 _route->name_changed.connect (bind (mem_fun(*this, &RedirectBox::route_name_changed), plugin_ui, plugin_insert));
986 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
989 if (plugin_ui->is_visible()) {
990 plugin_ui->get_window()->raise ();
992 plugin_ui->show_all ();
994 #ifdef HAVE_AUDIOUNIT
995 } else if (type == ARDOUR::AudioUnit) {
996 AUPluginUI* plugin_ui;
997 if (plugin_insert->get_gui() == 0) {
998 plugin_ui = new AUPluginUI (plugin_insert);
1000 plugin_ui = reinterpret_cast<AUPluginUI*> (plugin_insert->get_gui());
1003 // raise window, somehow
1006 warning << "Unsupported plugin sent to RedirectBox::edit_redirect()" << endmsg;
1009 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
1011 if (!_session.engine().connected()) {
1012 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1017 PortInsertWindow *io_selector;
1019 if (port_insert->get_gui() == 0) {
1020 io_selector = new PortInsertWindow (_session, port_insert);
1021 port_insert->set_gui (io_selector);
1024 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1027 if (io_selector->is_visible()) {
1028 io_selector->get_window()->raise ();
1030 io_selector->show_all ();
1037 RedirectBox::enter_box (GdkEventCrossing *ev, RedirectBox* rb)
1039 switch (ev->detail) {
1040 case GDK_NOTIFY_INFERIOR:
1043 case GDK_NOTIFY_VIRTUAL:
1047 _current_redirect_box = rb;
1054 RedirectBox::register_actions ()
1056 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("redirectmenu"));
1057 Glib::RefPtr<Action> act;
1060 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin ..."), sigc::ptr_fun (RedirectBox::rb_choose_plugin));
1062 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"), sigc::ptr_fun (RedirectBox::rb_choose_insert));
1063 ActionManager::jack_sensitive_actions.push_back (act);
1064 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."), sigc::ptr_fun (RedirectBox::rb_choose_send));
1065 ActionManager::jack_sensitive_actions.push_back (act);
1067 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear"), sigc::ptr_fun (RedirectBox::rb_clear));
1069 /* standard editing stuff */
1070 act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"), sigc::ptr_fun (RedirectBox::rb_cut));
1071 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1072 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"), sigc::ptr_fun (RedirectBox::rb_copy));
1073 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1074 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"), sigc::ptr_fun (RedirectBox::rb_paste));
1075 act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"), sigc::ptr_fun (RedirectBox::rb_rename));
1076 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1077 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"), sigc::ptr_fun (RedirectBox::rb_select_all));
1078 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"), sigc::ptr_fun (RedirectBox::rb_deselect_all));
1081 act = ActionManager::register_action (popup_act_grp, X_("activate"), _("Activate"), sigc::ptr_fun (RedirectBox::rb_activate));
1082 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1083 act = ActionManager::register_action (popup_act_grp, X_("deactivate"), _("Deactivate"), sigc::ptr_fun (RedirectBox::rb_deactivate));
1084 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1085 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"), sigc::ptr_fun (RedirectBox::rb_activate_all));
1086 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"), sigc::ptr_fun (RedirectBox::rb_deactivate_all));
1089 act = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit"), sigc::ptr_fun (RedirectBox::rb_edit));
1090 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1092 ActionManager::add_action_group (popup_act_grp);
1098 RedirectBox::rb_choose_plugin ()
1100 if (_current_redirect_box == 0) {
1103 _current_redirect_box->choose_plugin ();
1107 RedirectBox::rb_choose_insert ()
1109 if (_current_redirect_box == 0) {
1112 _current_redirect_box->choose_insert ();
1116 RedirectBox::rb_choose_send ()
1118 if (_current_redirect_box == 0) {
1121 _current_redirect_box->choose_send ();
1125 RedirectBox::rb_clear ()
1127 if (_current_redirect_box == 0) {
1131 _current_redirect_box->clear_redirects ();
1135 RedirectBox::rb_cut ()
1137 if (_current_redirect_box == 0) {
1141 _current_redirect_box->cut_redirects ();
1145 RedirectBox::rb_copy ()
1147 if (_current_redirect_box == 0) {
1150 _current_redirect_box->copy_redirects ();
1154 RedirectBox::rb_paste ()
1156 if (_current_redirect_box == 0) {
1160 _current_redirect_box->paste_redirects ();
1164 RedirectBox::rb_rename ()
1166 if (_current_redirect_box == 0) {
1169 _current_redirect_box->rename_redirects ();
1173 RedirectBox::rb_select_all ()
1175 if (_current_redirect_box == 0) {
1179 _current_redirect_box->select_all_redirects ();
1183 RedirectBox::rb_deselect_all ()
1185 if (_current_redirect_box == 0) {
1189 _current_redirect_box->deselect_all_redirects ();
1193 RedirectBox::rb_activate ()
1195 if (_current_redirect_box == 0) {
1199 _current_redirect_box->for_selected_redirects (&RedirectBox::activate_redirect);
1203 RedirectBox::rb_deactivate ()
1205 if (_current_redirect_box == 0) {
1208 _current_redirect_box->for_selected_redirects (&RedirectBox::deactivate_redirect);
1212 RedirectBox::rb_activate_all ()
1214 if (_current_redirect_box == 0) {
1218 _current_redirect_box->all_redirects_active (true);
1222 RedirectBox::rb_deactivate_all ()
1224 if (_current_redirect_box == 0) {
1227 _current_redirect_box->all_redirects_active (false);
1231 RedirectBox::rb_edit ()
1233 if (_current_redirect_box == 0) {
1237 _current_redirect_box->for_selected_redirects (&RedirectBox::edit_redirect);
1241 RedirectBox::route_name_changed (void* src, PluginUIWindow* plugin_ui, boost::shared_ptr<PluginInsert> pi)
1243 ENSURE_GUI_THREAD(bind (mem_fun (*this, &RedirectBox::route_name_changed), src, plugin_ui, pi));
1245 plugin_ui->set_title (generate_redirect_title (pi));
1249 RedirectBox::generate_redirect_title (boost::shared_ptr<PluginInsert> pi)
1251 string maker = pi->plugin()->maker();
1252 string::size_type email_pos;
1254 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1255 maker = maker.substr (0, email_pos - 1);
1258 if (maker.length() > 32) {
1259 maker = maker.substr (0, 32);
1263 return string_compose(_("ardour: %1: %2 (by %3)"), _route->name(), pi->name(), maker);