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"
58 #include "plugin_ui.h"
60 #include "io_selector.h"
62 #include "gui_thread.h"
67 using namespace ARDOUR;
71 using namespace Gtkmm2ext;
73 RedirectBox* RedirectBox::_current_redirect_box = 0;
74 RefPtr<Action> RedirectBox::paste_action;
75 bool RedirectBox::get_colors = true;
76 Gdk::Color* RedirectBox::active_redirect_color;
77 Gdk::Color* RedirectBox::inactive_redirect_color;
79 RedirectBox::RedirectBox (Placement pcmnt, Session& sess, boost::shared_ptr<Route> rt, PluginSelector &plugsel,
80 RouteRedirectSelection & rsel, bool owner_is_mixer)
83 _owner_is_mixer (owner_is_mixer),
85 _plugin_selector(plugsel),
89 active_redirect_color = new Gdk::Color;
90 inactive_redirect_color = new Gdk::Color;
91 set_color (*active_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_ACTIVE, false ));
92 set_color (*inactive_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false ));
99 redirect_drag_in_progress = false;
100 no_redirect_redisplay = false;
101 ignore_delete = false;
103 model = ListStore::create(columns);
105 RefPtr<TreeSelection> selection = redirect_display.get_selection();
106 selection->set_mode (Gtk::SELECTION_MULTIPLE);
107 selection->signal_changed().connect (mem_fun (*this, &RedirectBox::selection_changed));
109 redirect_display.set_model (model);
110 redirect_display.append_column (X_("notshown"), columns.text);
111 redirect_display.set_name ("RedirectSelector");
112 redirect_display.set_headers_visible (false);
113 redirect_display.set_reorderable (true);
114 redirect_display.set_size_request (-1, 40);
115 redirect_display.get_column(0)->set_sizing(TREE_VIEW_COLUMN_FIXED);
116 redirect_display.get_column(0)->set_fixed_width(48);
117 redirect_display.add_object_drag (columns.redirect.index(), "redirects");
118 redirect_display.signal_object_drop.connect (mem_fun (*this, &RedirectBox::object_drop));
120 TreeViewColumn* name_col = redirect_display.get_column(0);
121 CellRendererText* renderer = dynamic_cast<CellRendererText*>(redirect_display.get_column_cell_renderer (0));
122 name_col->add_attribute(renderer->property_foreground_gdk(), columns.color);
124 redirect_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
126 model->signal_row_deleted().connect (mem_fun (*this, &RedirectBox::row_deleted));
128 redirect_scroller.add (redirect_display);
129 redirect_eventbox.add (redirect_scroller);
131 redirect_scroller.set_size_request (-1, 40);
133 pack_start (redirect_eventbox, true, true);
135 _route->redirects_changed.connect (mem_fun(*this, &RedirectBox::redisplay_redirects));
137 redirect_eventbox.signal_enter_notify_event().connect (bind (sigc::ptr_fun (RedirectBox::enter_box), this));
139 redirect_display.signal_button_press_event().connect (mem_fun(*this, &RedirectBox::redirect_button_press_event), false);
140 redirect_display.signal_button_release_event().connect (mem_fun(*this, &RedirectBox::redirect_button_press_event));
142 /* start off as a passthru strip. we'll correct this, if necessary,
143 in update_diskstream_display().
146 /* now force an update of all the various elements */
148 redisplay_redirects (0);
151 RedirectBox::~RedirectBox ()
156 RedirectBox::object_drop (string type, uint32_t cnt, void** ptr)
158 if (type != "redirects" || cnt == 0 || ptr == 0) {
162 /* do something with the dropped redirects */
164 list<boost::shared_ptr<Redirect> > redirects;
166 for (uint32_t n = 0; n < cnt; ++n) {
167 redirects.push_back (boost::shared_ptr<Redirect> ((Redirect*) ptr[n]));
170 paste_redirect_list (redirects);
174 RedirectBox::update()
176 redisplay_redirects (0);
181 RedirectBox::set_width (Width w)
188 redisplay_redirects (0);
192 RedirectBox::remove_redirect_gui (boost::shared_ptr<Redirect> redirect)
194 boost::shared_ptr<Insert> insert;
195 boost::shared_ptr<Send> send;
196 boost::shared_ptr<PortInsert> port_insert;
198 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) != 0) {
200 if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
201 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
202 port_insert->set_gui (0);
206 } else if ((send = boost::dynamic_pointer_cast<Send> (insert)) != 0) {
207 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
214 RedirectBox::build_send_action_menu ()
217 using namespace Menu_Helpers;
219 send_action_menu = new Menu;
220 send_action_menu->set_name ("ArdourContextMenu");
221 MenuList& items = send_action_menu->items();
223 items.push_back (MenuElem (_("New send"), mem_fun(*this, &RedirectBox::new_send)));
224 items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &RedirectBox::show_send_controls)));
228 RedirectBox::show_send_controls ()
234 RedirectBox::new_send ()
240 RedirectBox::show_redirect_menu (gint arg)
242 if (redirect_menu == 0) {
243 redirect_menu = build_redirect_menu ();
246 paste_action->set_sensitive (!_rr_selection.redirects.empty());
248 redirect_menu->popup (1, arg);
252 RedirectBox::redirect_drag_begin (GdkDragContext *context)
254 redirect_drag_in_progress = true;
258 RedirectBox::redirect_drag_end (GdkDragContext *context)
260 redirect_drag_in_progress = false;
264 RedirectBox::redirect_button_press_event (GdkEventButton *ev)
267 TreeModel::Path path;
268 TreeViewColumn* column;
271 boost::shared_ptr<Redirect> redirect;
273 bool selected = false;
275 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
276 if ((iter = model->get_iter (path))) {
277 redirect = (*iter)[columns.redirect];
278 selected = redirect_display.get_selection()->is_selected (iter);
283 if (redirect && Keyboard::is_delete_event (ev)) {
285 Glib::signal_idle().connect (bind (mem_fun(*this, &RedirectBox::idle_delete_redirect), redirect));
288 } else if (redirect && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS && ev->state == 0))) {
290 if (_session.engine().connected()) {
291 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
292 edit_redirect (redirect);
296 } else if (Keyboard::is_context_menu_event (ev)) {
298 show_redirect_menu(ev->time);
301 } else if (redirect && ev->button == 2 && ev->state == 0) {
303 redirect->set_active (!redirect->active(), this);
307 else if (redirect && ev->button == 1 && selected) {
309 // this is purely informational but necessary
310 RedirectSelected (redirect); // emit
317 RedirectBox::build_redirect_menu ()
319 redirect_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/redirectmenu") );
320 redirect_menu->set_name ("ArdourContextMenu");
324 return redirect_menu;
328 RedirectBox::selection_changed ()
330 bool sensitive = (redirect_display.get_selection()->count_selected_rows()) ? true : false;
331 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
335 RedirectBox::select_all_redirects ()
337 redirect_display.get_selection()->select_all();
341 RedirectBox::deselect_all_redirects ()
343 redirect_display.get_selection()->unselect_all();
347 RedirectBox::choose_plugin ()
349 sigc::connection newplug_connection = _plugin_selector.PluginCreated.connect (mem_fun(*this,&RedirectBox::insert_plugin_chosen));
350 _plugin_selector.show_all();
351 _plugin_selector.run ();
352 newplug_connection.disconnect();
356 RedirectBox::insert_plugin_chosen (boost::shared_ptr<Plugin> plugin)
360 boost::shared_ptr<Redirect> redirect (new PluginInsert (_session, plugin, _placement));
362 redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active));
364 uint32_t err_streams;
366 if (_route->add_redirect (redirect, this, &err_streams)) {
367 wierd_plugin_dialog (*plugin, err_streams, _route);
368 // XXX SHAREDPTR delete plugin here .. do we even need to care?
374 RedirectBox::wierd_plugin_dialog (Plugin& p, uint32_t streams, boost::shared_ptr<IO> io)
376 ArdourDialog dialog ("wierd plugin dialog");
379 /* i hate this kind of code */
381 if (streams > p.get_info()->n_inputs) {
382 label.set_text (string_compose (_(
383 "You attempted to add a plugin (%1).\n"
384 "The plugin has %2 inputs\n"
385 "but at the insertion point, there are\n"
386 "%3 active signal streams.\n"
388 "This makes no sense - you are throwing away\n"
389 "part of the signal."),
391 p.get_info()->n_inputs,
393 } else if (streams < p.get_info()->n_inputs) {
394 label.set_text (string_compose (_(
395 "You attempted to add a plugin (%1).\n"
396 "The plugin has %2 inputs\n"
397 "but at the insertion point there are\n"
398 "only %3 active signal streams.\n"
400 "This makes no sense - unless the plugin supports\n"
401 "side-chain inputs. A future version of Ardour will\n"
402 "support this type of configuration."),
404 p.get_info()->n_inputs,
407 label.set_text (string_compose (_(
408 "You attempted to add a plugin (%1).\n"
410 "The I/O configuration doesn't make sense:\n"
412 "The plugin has %2 inputs and %3 outputs.\n"
413 "The track/bus has %4 inputs and %5 outputs.\n"
414 "The insertion point, has %6 active signals.\n"
416 "Ardour does not understand what to do in such situations.\n"),
418 p.get_info()->n_inputs,
419 p.get_info()->n_outputs,
425 dialog.get_vbox()->pack_start (label);
426 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
428 dialog.set_name (X_("PluginIODialog"));
429 dialog.set_position (Gtk::WIN_POS_MOUSE);
430 dialog.set_modal (true);
437 RedirectBox::choose_insert ()
439 boost::shared_ptr<Redirect> redirect (new PortInsert (_session, _placement));
440 redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active));
441 _route->add_redirect (redirect, this);
445 RedirectBox::choose_send ()
447 boost::shared_ptr<Send> send (new Send (_session, _placement));
449 /* XXX need redirect lock on route */
451 send->ensure_io (0, _route->max_redirect_outs(), false, this);
453 IOSelectorWindow *ios = new IOSelectorWindow (_session, send, false, true);
456 ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), boost::static_pointer_cast<Redirect>(send), ios));
460 RedirectBox::send_io_finished (IOSelector::Result r, boost::shared_ptr<Redirect> redirect, IOSelectorWindow* ios)
463 case IOSelector::Cancelled:
464 // delete redirect; XXX SHAREDPTR HOW TO DESTROY THE REDIRECT ? do we even need to think about it?
467 case IOSelector::Accepted:
468 _route->add_redirect (redirect, this);
472 delete_when_idle (ios);
476 RedirectBox::redisplay_redirects (void *src)
478 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::redisplay_redirects), src));
480 if (no_redirect_redisplay) {
484 ignore_delete = true;
486 ignore_delete = false;
488 redirect_active_connections.clear ();
489 redirect_name_connections.clear ();
491 void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>) = &RedirectBox::add_redirect_to_display;
492 _route->foreach_redirect (this, pmf);
494 switch (_placement) {
496 build_redirect_tooltip(redirect_eventbox, _("Pre-fader inserts, sends & plugins:"));
499 build_redirect_tooltip(redirect_eventbox, _("Post-fader inserts, sends & plugins:"));
505 RedirectBox::add_redirect_to_display (boost::shared_ptr<Redirect> redirect)
507 if (redirect->placement() != _placement) {
511 Gtk::TreeModel::Row row = *(model->append());
512 row[columns.text] = redirect_name (redirect);
513 row[columns.redirect] = redirect;
515 show_redirect_active (redirect.get(), this);
517 redirect_active_connections.push_back (redirect->active_changed.connect (mem_fun(*this, &RedirectBox::show_redirect_active)));
518 redirect_name_connections.push_back (redirect->name_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_name), redirect)));
522 RedirectBox::redirect_name (boost::shared_ptr<Redirect> redirect)
524 boost::shared_ptr<Send> send;
527 if (!redirect->active()) {
531 if ((send = boost::dynamic_pointer_cast<Send> (redirect)) != 0) {
535 /* grab the send name out of its overall name */
537 string::size_type lbracket, rbracket;
538 lbracket = send->name().find ('[');
539 rbracket = send->name().find (']');
543 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
546 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
554 name_display += redirect->name();
557 name_display += PBD::short_version (redirect->name(), 5);
563 if (!redirect->active()) {
571 RedirectBox::build_redirect_tooltip (EventBox& box, string start)
575 Gtk::TreeModel::Children children = model->children();
576 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
577 Gtk::TreeModel::Row row = *iter;
579 tip += row[columns.text];
581 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
585 RedirectBox::show_redirect_name (void* src, boost::shared_ptr<Redirect> redirect)
587 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_name), src, redirect));
588 show_redirect_active (redirect.get(), src);
592 RedirectBox::show_redirect_active (Redirect* redirect, void *src)
594 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_active), redirect, src));
596 Gtk::TreeModel::Children children = model->children();
597 Gtk::TreeModel::Children::iterator iter = children.begin();
599 while (iter != children.end()) {
601 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
603 if (r.get() == redirect) {
604 (*iter)[columns.text] = redirect_name (r);
606 if (redirect->active()) {
607 (*iter)[columns.color] = *active_redirect_color;
609 (*iter)[columns.color] = *inactive_redirect_color;
619 RedirectBox::row_deleted (const Gtk::TreeModel::Path& path)
621 if (!ignore_delete) {
622 compute_redirect_sort_keys ();
627 RedirectBox::compute_redirect_sort_keys ()
629 uint32_t sort_key = 0;
630 Gtk::TreeModel::Children children = model->children();
632 for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
633 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
634 r->set_sort_key (sort_key);
638 if (_route->sort_redirects ()) {
640 redisplay_redirects (0);
642 /* now tell them about the problem */
644 ArdourDialog dialog ("wierd plugin dialog");
648 You cannot reorder this set of redirects\n\
649 in that way because the inputs and\n\
650 outputs do not work correctly."));
652 dialog.get_vbox()->pack_start (label);
653 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
655 dialog.set_name (X_("PluginIODialog"));
656 dialog.set_position (Gtk::WIN_POS_MOUSE);
657 dialog.set_modal (true);
665 RedirectBox::rename_redirects ()
667 vector<boost::shared_ptr<Redirect> > to_be_renamed;
669 get_selected_redirects (to_be_renamed);
671 if (to_be_renamed.empty()) {
675 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
676 rename_redirect (*i);
681 RedirectBox::cut_redirects ()
683 vector<boost::shared_ptr<Redirect> > to_be_removed;
685 get_selected_redirects (to_be_removed);
687 if (to_be_removed.empty()) {
691 /* this essentially transfers ownership of the redirect
692 of the redirect from the route to the mixer
696 _rr_selection.set (to_be_removed);
698 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
700 void* gui = (*i)->get_gui ();
703 static_cast<Gtk::Widget*>(gui)->hide ();
706 if (_route->remove_redirect (*i, this)) {
708 _rr_selection.remove (*i);
715 RedirectBox::copy_redirects ()
717 vector<boost::shared_ptr<Redirect> > to_be_copied;
718 vector<boost::shared_ptr<Redirect> > copies;
720 get_selected_redirects (to_be_copied);
722 if (to_be_copied.empty()) {
726 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
727 copies.push_back (Redirect::clone (*i));
730 _rr_selection.set (copies);
734 RedirectBox::idle_delete_redirect (boost::shared_ptr<Redirect> redirect)
736 /* NOT copied to _mixer.selection() */
738 _route->remove_redirect (redirect, this);
743 RedirectBox::rename_redirect (boost::shared_ptr<Redirect> redirect)
745 ArdourPrompter name_prompter (true);
747 name_prompter.set_prompt (_("rename redirect"));
748 name_prompter.set_initial_text (redirect->name());
749 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
750 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
751 name_prompter.show_all ();
753 switch (name_prompter.run ()) {
755 case Gtk::RESPONSE_ACCEPT:
756 name_prompter.get_result (result);
757 if (result.length()) {
758 redirect->set_name (result, this);
768 RedirectBox::cut_redirect (boost::shared_ptr<Redirect> redirect)
770 /* this essentially transfers ownership of the redirect
771 of the redirect from the route to the mixer
775 _rr_selection.add (redirect);
777 void* gui = redirect->get_gui ();
780 static_cast<Gtk::Widget*>(gui)->hide ();
783 if (_route->remove_redirect (redirect, this)) {
784 _rr_selection.remove (redirect);
789 RedirectBox::copy_redirect (boost::shared_ptr<Redirect> redirect)
791 boost::shared_ptr<Redirect> copy = Redirect::clone (redirect);
792 _rr_selection.add (copy);
796 RedirectBox::paste_redirects ()
798 if (_rr_selection.redirects.empty()) {
802 paste_redirect_list (_rr_selection.redirects);
806 RedirectBox::paste_redirect_list (list<boost::shared_ptr<Redirect> >& redirects)
808 list<boost::shared_ptr<Redirect> > copies;
810 for (list<boost::shared_ptr<Redirect> >::iterator i = redirects.begin(); i != redirects.end(); ++i) {
812 boost::shared_ptr<Redirect> copy = Redirect::clone (*i);
814 copy->set_placement (_placement, this);
815 copies.push_back (copy);
818 if (_route->add_redirects (copies, this)) {
821 "Copying the set of redirects on the clipboard failed,\n\
822 probably because the I/O configuration of the plugins\n\
823 could not match the configuration of this track.");
824 MessageDialog am (msg);
830 RedirectBox::activate_redirect (boost::shared_ptr<Redirect> r)
832 r->set_active (true, 0);
836 RedirectBox::deactivate_redirect (boost::shared_ptr<Redirect> r)
838 r->set_active (false, 0);
842 RedirectBox::get_selected_redirects (vector<boost::shared_ptr<Redirect> >& redirects)
844 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
846 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter)
847 redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
851 RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>))
853 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
855 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
856 boost::shared_ptr<Redirect> redirect = (*(model->get_iter(*iter)))[columns.redirect];
857 (this->*pmf)(redirect);
862 RedirectBox::clone_redirects ()
864 RouteSelection& routes (_rr_selection.routes);
866 if (!routes.empty()) {
867 if (_route->copy_redirects (*routes.front(), _placement)) {
869 "Copying the set of redirects on the clipboard failed,\n\
870 probably because the I/O configuration of the plugins\n\
871 could not match the configuration of this track.");
872 MessageDialog am (msg);
879 RedirectBox::all_redirects_active (bool state)
881 _route->all_redirects_active (state);
885 RedirectBox::clear_redirects()
888 vector<string> choices;
890 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
891 prompt = _("Do you really want to remove all redirects from this track?\n"
892 "(this cannot be undone)");
894 prompt = _("Do you really want to remove all redirects from this bus?\n"
895 "(this cannot be undone)");
898 choices.push_back (_("Cancel"));
899 choices.push_back (_("Yes, remove them all"));
901 Gtkmm2ext::Choice prompter (prompt, choices);
903 if (prompter.run () == 1) {
904 _route->clear_redirects (this);
909 RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
911 boost::shared_ptr<Insert> insert;
913 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
915 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
920 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) == 0) {
924 if (!_session.engine().connected()) {
928 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (redirect);
930 SendUIWindow *send_ui;
932 if (send->get_gui() == 0) {
935 title = string_compose(_("ardour: %1"), send->name());
937 send_ui = new SendUIWindow (send, _session);
938 send_ui->set_title (title);
939 send->set_gui (send_ui);
942 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
945 if (send_ui->is_visible()) {
946 send_ui->get_window()->raise ();
948 send_ui->show_all ();
955 boost::shared_ptr<PluginInsert> plugin_insert;
956 boost::shared_ptr<PortInsert> port_insert;
958 if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (insert)) != 0) {
960 PluginUIWindow *plugin_ui;
962 if (plugin_insert->get_gui() == 0) {
965 string maker = plugin_insert->plugin()->maker();
966 string::size_type email_pos;
968 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
969 maker = maker.substr (0, email_pos - 1);
972 if (maker.length() > 32) {
973 maker = maker.substr (0, 32);
977 title = string_compose(_("ardour: %1: %2 (by %3)"), _route->name(), plugin_insert->name(), maker);
979 plugin_ui = new PluginUIWindow (_session.engine(), plugin_insert);
980 if (_owner_is_mixer) {
981 ARDOUR_UI::instance()->the_mixer()->ensure_float (*plugin_ui);
983 ARDOUR_UI::instance()->the_editor().ensure_float (*plugin_ui);
985 plugin_ui->set_title (title);
986 plugin_insert->set_gui (plugin_ui);
989 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
992 if (plugin_ui->is_visible()) {
993 plugin_ui->get_window()->raise ();
995 plugin_ui->show_all ();
998 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
1000 if (!_session.engine().connected()) {
1001 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1006 PortInsertWindow *io_selector;
1008 if (port_insert->get_gui() == 0) {
1009 io_selector = new PortInsertWindow (_session, port_insert);
1010 port_insert->set_gui (io_selector);
1013 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1016 if (io_selector->is_visible()) {
1017 io_selector->get_window()->raise ();
1019 io_selector->show_all ();
1026 RedirectBox::enter_box (GdkEventCrossing *ev, RedirectBox* rb)
1028 switch (ev->detail) {
1029 case GDK_NOTIFY_INFERIOR:
1032 case GDK_NOTIFY_VIRTUAL:
1036 _current_redirect_box = rb;
1043 RedirectBox::register_actions ()
1045 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("redirectmenu"));
1046 Glib::RefPtr<Action> act;
1049 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin ..."), sigc::ptr_fun (RedirectBox::rb_choose_plugin));
1050 ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"), sigc::ptr_fun (RedirectBox::rb_choose_insert));
1051 ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."), sigc::ptr_fun (RedirectBox::rb_choose_send));
1052 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear"), sigc::ptr_fun (RedirectBox::rb_clear));
1054 /* standard editing stuff */
1055 act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"), sigc::ptr_fun (RedirectBox::rb_cut));
1056 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1057 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"), sigc::ptr_fun (RedirectBox::rb_copy));
1058 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1059 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"), sigc::ptr_fun (RedirectBox::rb_paste));
1060 act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"), sigc::ptr_fun (RedirectBox::rb_rename));
1061 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1062 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"), sigc::ptr_fun (RedirectBox::rb_select_all));
1063 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"), sigc::ptr_fun (RedirectBox::rb_deselect_all));
1066 act = ActionManager::register_action (popup_act_grp, X_("activate"), _("Activate"), sigc::ptr_fun (RedirectBox::rb_activate));
1067 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1068 act = ActionManager::register_action (popup_act_grp, X_("deactivate"), _("Deactivate"), sigc::ptr_fun (RedirectBox::rb_deactivate));
1069 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1070 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"), sigc::ptr_fun (RedirectBox::rb_activate_all));
1071 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"), sigc::ptr_fun (RedirectBox::rb_deactivate_all));
1074 act = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit"), sigc::ptr_fun (RedirectBox::rb_edit));
1075 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1077 ActionManager::add_action_group (popup_act_grp);
1081 RedirectBox::rb_choose_plugin ()
1083 if (_current_redirect_box == 0) {
1086 _current_redirect_box->choose_plugin ();
1090 RedirectBox::rb_choose_insert ()
1092 if (_current_redirect_box == 0) {
1095 _current_redirect_box->choose_insert ();
1099 RedirectBox::rb_choose_send ()
1101 if (_current_redirect_box == 0) {
1104 _current_redirect_box->choose_send ();
1108 RedirectBox::rb_clear ()
1110 if (_current_redirect_box == 0) {
1114 _current_redirect_box->clear_redirects ();
1118 RedirectBox::rb_cut ()
1120 if (_current_redirect_box == 0) {
1124 _current_redirect_box->cut_redirects ();
1128 RedirectBox::rb_copy ()
1130 if (_current_redirect_box == 0) {
1133 _current_redirect_box->copy_redirects ();
1137 RedirectBox::rb_paste ()
1139 if (_current_redirect_box == 0) {
1143 _current_redirect_box->paste_redirects ();
1147 RedirectBox::rb_rename ()
1149 if (_current_redirect_box == 0) {
1152 _current_redirect_box->rename_redirects ();
1156 RedirectBox::rb_select_all ()
1158 if (_current_redirect_box == 0) {
1162 _current_redirect_box->select_all_redirects ();
1166 RedirectBox::rb_deselect_all ()
1168 if (_current_redirect_box == 0) {
1172 _current_redirect_box->deselect_all_redirects ();
1176 RedirectBox::rb_activate ()
1178 if (_current_redirect_box == 0) {
1182 _current_redirect_box->for_selected_redirects (&RedirectBox::activate_redirect);
1186 RedirectBox::rb_deactivate ()
1188 if (_current_redirect_box == 0) {
1191 _current_redirect_box->for_selected_redirects (&RedirectBox::deactivate_redirect);
1195 RedirectBox::rb_activate_all ()
1197 if (_current_redirect_box == 0) {
1201 _current_redirect_box->all_redirects_active (true);
1205 RedirectBox::rb_deactivate_all ()
1207 if (_current_redirect_box == 0) {
1210 _current_redirect_box->all_redirects_active (false);
1214 RedirectBox::rb_edit ()
1216 if (_current_redirect_box == 0) {
1220 _current_redirect_box->for_selected_redirects (&RedirectBox::edit_redirect);