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>
50 #include <ardour/profile.h>
52 #include "ardour_ui.h"
53 #include "ardour_dialog.h"
54 #include "public_editor.h"
55 #include "redirect_box.h"
57 #include "plugin_selector.h"
58 #include "route_redirect_selection.h"
61 #include "plugin_ui.h"
63 #include "io_selector.h"
65 #include "gui_thread.h"
69 #ifdef HAVE_AUDIOUNITS
74 using namespace ARDOUR;
78 using namespace Gtkmm2ext;
80 RedirectBox* RedirectBox::_current_redirect_box = 0;
81 RefPtr<Action> RedirectBox::paste_action;
82 bool RedirectBox::get_colors = true;
83 Gdk::Color* RedirectBox::active_redirect_color;
84 Gdk::Color* RedirectBox::inactive_redirect_color;
86 RedirectBox::RedirectBox (Placement pcmnt, Session& sess, boost::shared_ptr<Route> rt, PluginSelector &plugsel,
87 RouteRedirectSelection & rsel, bool owner_is_mixer)
90 _owner_is_mixer (owner_is_mixer),
92 _plugin_selector(plugsel),
96 active_redirect_color = new Gdk::Color;
97 inactive_redirect_color = new Gdk::Color;
98 set_color (*active_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_ACTIVE, false ));
99 set_color (*inactive_redirect_color, rgba_from_style ("RedirectSelector", 0xff, 0, 0, 0, "fg", Gtk::STATE_NORMAL, false ));
105 send_action_menu = 0;
106 redirect_drag_in_progress = false;
107 no_redirect_redisplay = false;
108 ignore_delete = false;
110 model = ListStore::create(columns);
112 RefPtr<TreeSelection> selection = redirect_display.get_selection();
113 selection->set_mode (Gtk::SELECTION_MULTIPLE);
114 selection->signal_changed().connect (mem_fun (*this, &RedirectBox::selection_changed));
116 redirect_display.set_model (model);
117 redirect_display.append_column (X_("notshown"), columns.text);
118 redirect_display.set_name ("RedirectSelector");
119 redirect_display.set_headers_visible (false);
120 redirect_display.set_reorderable (true);
121 redirect_display.set_size_request (-1, 40);
122 redirect_display.get_column(0)->set_sizing(TREE_VIEW_COLUMN_FIXED);
123 redirect_display.get_column(0)->set_fixed_width(48);
124 redirect_display.add_object_drag (columns.redirect.index(), "redirects");
125 redirect_display.signal_object_drop.connect (mem_fun (*this, &RedirectBox::object_drop));
127 TreeViewColumn* name_col = redirect_display.get_column(0);
128 CellRendererText* renderer = dynamic_cast<CellRendererText*>(redirect_display.get_column_cell_renderer (0));
129 name_col->add_attribute(renderer->property_foreground_gdk(), columns.color);
131 redirect_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
133 model->signal_row_deleted().connect (mem_fun (*this, &RedirectBox::row_deleted));
135 redirect_scroller.add (redirect_display);
136 redirect_eventbox.add (redirect_scroller);
138 redirect_scroller.set_size_request (-1, 40);
140 pack_start (redirect_eventbox, true, true);
142 _route->redirects_changed.connect (mem_fun(*this, &RedirectBox::redisplay_redirects));
143 _route->GoingAway.connect (mem_fun (*this, &RedirectBox::route_going_away));
145 redirect_eventbox.signal_enter_notify_event().connect (bind (sigc::ptr_fun (RedirectBox::enter_box), this));
147 redirect_display.signal_button_press_event().connect (mem_fun(*this, &RedirectBox::redirect_button_press_event), false);
148 redirect_display.signal_button_release_event().connect (mem_fun(*this, &RedirectBox::redirect_button_release_event));
150 using_plugin_selector = false;
151 _plugin_selector.signal_hide().connect (mem_fun (*this, &RedirectBox::plugin_selector_hidden));
152 _plugin_selector.signal_show().connect (mem_fun (*this, &RedirectBox::plugin_selector_shown));
154 /* start off as a passthru strip. we'll correct this, if necessary,
155 in update_diskstream_display().
158 /* now force an update of all the various elements */
160 redisplay_redirects (0);
163 RedirectBox::~RedirectBox ()
168 RedirectBox::route_going_away ()
170 /* don't keep updating display as redirects are deleted */
171 no_redirect_redisplay = true;
175 RedirectBox::object_drop (string type, uint32_t cnt, const boost::shared_ptr<Redirect>* ptr)
177 if (type != "redirects" || cnt == 0 || !ptr) {
181 /* do something with the dropped redirects */
183 list<boost::shared_ptr<Redirect> > redirects;
185 for (uint32_t n = 0; n < cnt; ++n) {
186 redirects.push_back (ptr[n]);
189 paste_redirect_list (redirects);
193 RedirectBox::update()
195 redisplay_redirects (0);
200 RedirectBox::set_width (Width w)
207 redisplay_redirects (0);
211 RedirectBox::remove_redirect_gui (boost::shared_ptr<Redirect> redirect)
213 boost::shared_ptr<Insert> insert;
214 boost::shared_ptr<Send> send;
215 boost::shared_ptr<PortInsert> port_insert;
217 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) != 0) {
219 if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
220 PortInsertUI *io_selector = reinterpret_cast<PortInsertUI *> (port_insert->get_gui());
221 port_insert->set_gui (0);
225 } else if ((send = boost::dynamic_pointer_cast<Send> (insert)) != 0) {
226 SendUIWindow *sui = reinterpret_cast<SendUIWindow*> (send->get_gui());
233 RedirectBox::build_send_action_menu ()
236 using namespace Menu_Helpers;
238 send_action_menu = new Menu;
239 send_action_menu->set_name ("ArdourContextMenu");
240 MenuList& items = send_action_menu->items();
242 items.push_back (MenuElem (_("New send"), mem_fun(*this, &RedirectBox::new_send)));
243 items.push_back (MenuElem (_("Show send controls"), mem_fun(*this, &RedirectBox::show_send_controls)));
247 RedirectBox::show_send_controls ()
253 RedirectBox::new_send ()
259 RedirectBox::show_redirect_menu (gint arg)
261 if (redirect_menu == 0) {
262 redirect_menu = build_redirect_menu ();
265 Gtk::MenuItem* plugin_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/redirectmenu/newplugin"));
267 if (plugin_menu_item) {
268 plugin_menu_item->set_submenu (_plugin_selector.plugin_menu());
271 paste_action->set_sensitive (!_rr_selection.redirects.empty());
273 redirect_menu->popup (1, arg);
277 RedirectBox::redirect_drag_begin (GdkDragContext *context)
279 redirect_drag_in_progress = true;
283 RedirectBox::redirect_drag_end (GdkDragContext *context)
285 redirect_drag_in_progress = false;
289 RedirectBox::redirect_button_press_event (GdkEventButton *ev)
292 TreeModel::Path path;
293 TreeViewColumn* column;
296 boost::shared_ptr<Redirect> redirect;
298 bool selected = false;
300 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
301 if ((iter = model->get_iter (path))) {
302 redirect = (*iter)[columns.redirect];
303 selected = redirect_display.get_selection()->is_selected (iter);
308 if (redirect && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
310 if (_session.engine().connected()) {
311 /* XXX giving an error message here is hard, because we may be in the midst of a button press */
312 edit_redirect (redirect);
316 } else if (redirect && ev->button == 1 && selected) {
318 // this is purely informational but necessary
319 RedirectSelected (redirect); // emit
326 RedirectBox::redirect_button_release_event (GdkEventButton *ev)
329 TreeModel::Path path;
330 TreeViewColumn* column;
333 boost::shared_ptr<Redirect> redirect;
337 if (redirect_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
338 if ((iter = model->get_iter (path))) {
339 redirect = (*iter)[columns.redirect];
343 if (redirect && Keyboard::is_delete_event (ev)) {
345 Glib::signal_idle().connect (bind (mem_fun(*this, &RedirectBox::idle_delete_redirect), boost::weak_ptr<Redirect>(redirect)));
348 } else if (Keyboard::is_context_menu_event (ev)) {
350 show_redirect_menu(ev->time);
353 } else if (redirect && (ev->button == 2) && (Keyboard::no_modifier_keys_pressed (ev) && ((ev->state & Gdk::BUTTON2_MASK) == Gdk::BUTTON2_MASK))) {
355 /* button2-click with no modifiers */
357 redirect->set_active (!redirect->active(), this);
366 RedirectBox::build_redirect_menu ()
368 redirect_menu = dynamic_cast<Gtk::Menu*>(ActionManager::get_widget("/redirectmenu") );
369 redirect_menu->set_name ("ArdourContextMenu");
373 return redirect_menu;
377 RedirectBox::selection_changed ()
379 bool sensitive = (redirect_display.get_selection()->count_selected_rows()) ? true : false;
380 ActionManager::set_sensitive (ActionManager::plugin_selection_sensitive_actions, sensitive);
384 RedirectBox::select_all_redirects ()
386 redirect_display.get_selection()->select_all();
390 RedirectBox::deselect_all_redirects ()
392 redirect_display.get_selection()->unselect_all();
396 RedirectBox::choose_plugin ()
398 newplug_connection = _plugin_selector.PluginCreated.connect (mem_fun(*this,&RedirectBox::insert_plugin_chosen));
399 // Gtk::Menu& m = _plugin_selector.plugin_menu();
404 RedirectBox::insert_plugin_chosen (boost::shared_ptr<Plugin> plugin)
408 boost::shared_ptr<Redirect> redirect (new PluginInsert (_session, plugin, _placement));
410 uint32_t err_streams;
412 if (_route->add_redirect (redirect, this, &err_streams)) {
413 weird_plugin_dialog (*plugin, err_streams, _route);
415 if (Profile->get_sae()) {
416 redirect->set_active (true, 0);
418 redirect->active_changed.connect (bind (mem_fun (*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect)));
422 if (!using_plugin_selector) {
423 newplug_connection.disconnect();
428 RedirectBox::weird_plugin_dialog (Plugin& p, uint32_t streams, boost::shared_ptr<IO> io)
430 ArdourDialog dialog (_("ardour: weird plugin dialog"));
433 /* i hate this kind of code */
435 if (streams > (unsigned)p.get_info()->n_inputs) {
436 label.set_text (string_compose (_(
437 "You attempted to add a plugin (%1).\n"
438 "The plugin has %2 inputs\n"
439 "but at the insertion point, there are\n"
440 "%3 active signal streams.\n"
442 "This makes no sense - you are throwing away\n"
443 "part of the signal."),
445 p.get_info()->n_inputs,
447 } else if (streams < (unsigned)p.get_info()->n_inputs) {
448 label.set_text (string_compose (_(
449 "You attempted to add a plugin (%1).\n"
450 "The plugin has %2 inputs\n"
451 "but at the insertion point there are\n"
452 "only %3 active signal streams.\n"
454 "This makes no sense - unless the plugin supports\n"
455 "side-chain inputs. A future version of Ardour will\n"
456 "support this type of configuration."),
458 p.get_info()->n_inputs,
461 label.set_text (string_compose (_(
462 "You attempted to add a plugin (%1).\n"
464 "The I/O configuration doesn't make sense:\n"
466 "The plugin has %2 inputs and %3 outputs.\n"
467 "The track/bus has %4 inputs and %5 outputs.\n"
468 "The insertion point, has %6 active signals.\n"
470 "Ardour does not understand what to do in such situations.\n"),
472 p.get_info()->n_inputs,
473 p.get_info()->n_outputs,
479 dialog.get_vbox()->pack_start (label);
480 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
482 dialog.set_name (X_("PluginIODialog"));
483 dialog.set_position (Gtk::WIN_POS_MOUSE);
484 dialog.set_modal (true);
491 RedirectBox::choose_insert ()
493 boost::shared_ptr<Redirect> redirect (new PortInsert (_session, _placement));
494 redirect->active_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect)));
495 _route->add_redirect (redirect, this);
499 RedirectBox::choose_send ()
501 boost::shared_ptr<Send> send (new Send (_session, _placement));
503 /* XXX need redirect lock on route */
505 send->ensure_io (0, _route->max_redirect_outs(), false, this);
507 IOSelectorWindow *ios = new IOSelectorWindow (_session, send, false, true);
511 boost::shared_ptr<Redirect> r = boost::static_pointer_cast<Redirect>(send);
513 ios->selector().Finished.connect (bind (mem_fun(*this, &RedirectBox::send_io_finished), boost::weak_ptr<Redirect>(r), ios));
517 RedirectBox::send_io_finished (IOSelector::Result r, boost::weak_ptr<Redirect> weak_redirect, IOSelectorWindow* ios)
519 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
526 case IOSelector::Cancelled:
527 // redirect will go away when all shared_ptrs to it vanish
530 case IOSelector::Accepted:
531 _route->add_redirect (redirect, this);
535 delete_when_idle (ios);
539 RedirectBox::redisplay_redirects (void *src)
541 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::redisplay_redirects), src));
543 if (no_redirect_redisplay) {
547 ignore_delete = true;
549 ignore_delete = false;
551 redirect_active_connections.clear ();
552 redirect_name_connections.clear ();
554 void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>) = &RedirectBox::add_redirect_to_display;
555 _route->foreach_redirect (this, pmf);
557 switch (_placement) {
559 build_redirect_tooltip(redirect_eventbox, _("Pre-fader inserts, sends & plugins:"));
562 build_redirect_tooltip(redirect_eventbox, _("Post-fader inserts, sends & plugins:"));
568 RedirectBox::add_redirect_to_display (boost::shared_ptr<Redirect> redirect)
570 if (redirect->placement() != _placement) {
574 Gtk::TreeModel::Row row = *(model->append());
575 row[columns.text] = redirect_name (redirect);
576 row[columns.redirect] = redirect;
578 show_redirect_active (redirect);
580 redirect_active_connections.push_back (redirect->active_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_active_r), boost::weak_ptr<Redirect>(redirect))));
581 redirect_name_connections.push_back (redirect->name_changed.connect (bind (mem_fun(*this, &RedirectBox::show_redirect_name), boost::weak_ptr<Redirect>(redirect))));
585 RedirectBox::redirect_name (boost::weak_ptr<Redirect> weak_redirect)
587 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
593 boost::shared_ptr<Send> send;
596 if (!redirect->active()) {
600 if ((send = boost::dynamic_pointer_cast<Send> (redirect)) != 0) {
604 /* grab the send name out of its overall name */
606 string::size_type lbracket, rbracket;
607 lbracket = send->name().find ('[');
608 rbracket = send->name().find (']');
612 name_display += send->name().substr (lbracket+1, lbracket-rbracket-1);
615 name_display += PBD::short_version (send->name().substr (lbracket+1, lbracket-rbracket-1), 4);
623 name_display += redirect->name();
626 name_display += PBD::short_version (redirect->name(), 5);
632 if (!redirect->active()) {
640 RedirectBox::build_redirect_tooltip (EventBox& box, string start)
644 Gtk::TreeModel::Children children = model->children();
645 for(Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
646 Gtk::TreeModel::Row row = *iter;
648 tip += row[columns.text];
650 ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
654 RedirectBox::show_redirect_name (void* src, boost::weak_ptr<Redirect> redirect)
656 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_name), src, redirect));
657 show_redirect_active (redirect);
661 RedirectBox::show_redirect_active_r (Redirect* r, void *src, boost::weak_ptr<Redirect> weak_redirect)
663 show_redirect_active (weak_redirect);
667 RedirectBox::show_redirect_active (boost::weak_ptr<Redirect> weak_redirect)
669 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
675 ENSURE_GUI_THREAD(bind (mem_fun(*this, &RedirectBox::show_redirect_active), weak_redirect));
677 Gtk::TreeModel::Children children = model->children();
678 Gtk::TreeModel::Children::iterator iter = children.begin();
680 while (iter != children.end()) {
682 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
685 (*iter)[columns.text] = redirect_name (r);
687 if (redirect->active()) {
688 (*iter)[columns.color] = *active_redirect_color;
690 (*iter)[columns.color] = *inactive_redirect_color;
700 RedirectBox::row_deleted (const Gtk::TreeModel::Path& path)
702 if (!ignore_delete) {
703 compute_redirect_sort_keys ();
708 RedirectBox::compute_redirect_sort_keys ()
710 uint32_t sort_key = 0;
711 Gtk::TreeModel::Children children = model->children();
713 for (Gtk::TreeModel::Children::iterator iter = children.begin(); iter != children.end(); ++iter) {
714 boost::shared_ptr<Redirect> r = (*iter)[columns.redirect];
715 r->set_sort_key (sort_key);
719 if (_route->sort_redirects ()) {
721 redisplay_redirects (0);
723 /* now tell them about the problem */
725 ArdourDialog dialog (_("ardour: weird plugin dialog"));
729 You cannot reorder this set of redirects\n\
730 in that way because the inputs and\n\
731 outputs do not work correctly."));
733 dialog.get_vbox()->pack_start (label);
734 dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
736 dialog.set_name (X_("PluginIODialog"));
737 dialog.set_position (Gtk::WIN_POS_MOUSE);
738 dialog.set_modal (true);
746 RedirectBox::rename_redirects ()
748 vector<boost::shared_ptr<Redirect> > to_be_renamed;
750 get_selected_redirects (to_be_renamed);
752 if (to_be_renamed.empty()) {
756 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_renamed.begin(); i != to_be_renamed.end(); ++i) {
757 rename_redirect (*i);
762 RedirectBox::cut_redirects ()
764 vector<boost::shared_ptr<Redirect> > to_be_removed;
766 get_selected_redirects (to_be_removed);
768 if (to_be_removed.empty()) {
772 /* this essentially transfers ownership of the redirect
773 of the redirect from the route to the mixer
777 _rr_selection.set (to_be_removed);
779 no_redirect_redisplay = true;
780 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_removed.begin(); i != to_be_removed.end(); ++i) {
781 // Do not cut inserts or sends
782 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0) {
783 void* gui = (*i)->get_gui ();
786 static_cast<Gtk::Widget*>(gui)->hide ();
789 if (_route->remove_redirect (*i, this)) {
791 _rr_selection.remove (*i);
794 _rr_selection.remove (*i);
798 no_redirect_redisplay = false;
799 redisplay_redirects (this);
803 RedirectBox::copy_redirects ()
805 vector<boost::shared_ptr<Redirect> > to_be_copied;
806 vector<boost::shared_ptr<Redirect> > copies;
808 get_selected_redirects (to_be_copied);
810 if (to_be_copied.empty()) {
814 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_copied.begin(); i != to_be_copied.end(); ++i) {
815 // Do not copy inserts or sends
816 if (boost::dynamic_pointer_cast<PluginInsert>((*i)) != 0) {
817 copies.push_back (Redirect::clone (*i));
821 _rr_selection.set (copies);
826 RedirectBox::delete_redirects ()
828 vector<boost::shared_ptr<Redirect> > to_be_deleted;
830 get_selected_redirects (to_be_deleted);
832 if (to_be_deleted.empty()) {
836 for (vector<boost::shared_ptr<Redirect> >::iterator i = to_be_deleted.begin(); i != to_be_deleted.end(); ++i) {
838 void* gui = (*i)->get_gui ();
841 static_cast<Gtk::Widget*>(gui)->hide ();
844 _route->remove_redirect( *i, this);
847 no_redirect_redisplay = false;
848 redisplay_redirects (this);
852 RedirectBox::idle_delete_redirect (boost::weak_ptr<Redirect> weak_redirect)
854 boost::shared_ptr<Redirect> redirect (weak_redirect.lock());
860 /* NOT copied to _mixer.selection() */
862 no_redirect_redisplay = true;
863 _route->remove_redirect (redirect, this);
864 no_redirect_redisplay = false;
865 redisplay_redirects (this);
871 RedirectBox::rename_redirect (boost::shared_ptr<Redirect> redirect)
873 ArdourPrompter name_prompter (true);
875 name_prompter.set_prompt (_("rename redirect"));
876 name_prompter.set_initial_text (redirect->name());
877 name_prompter.add_button (_("Rename"), Gtk::RESPONSE_ACCEPT);
878 name_prompter.set_response_sensitive (Gtk::RESPONSE_ACCEPT, false);
879 name_prompter.show_all ();
881 switch (name_prompter.run ()) {
883 case Gtk::RESPONSE_ACCEPT:
884 name_prompter.get_result (result);
885 if (result.length()) {
886 redirect->set_name (result, this);
895 RedirectBox::cut_redirect (boost::shared_ptr<Redirect> redirect)
897 /* this essentially transfers ownership of the redirect
898 of the redirect from the route to the mixer
902 _rr_selection.add (redirect);
904 void* gui = redirect->get_gui ();
907 static_cast<Gtk::Widget*>(gui)->hide ();
910 no_redirect_redisplay = true;
911 if (_route->remove_redirect (redirect, this)) {
912 _rr_selection.remove (redirect);
914 no_redirect_redisplay = false;
915 redisplay_redirects (this);
919 RedirectBox::copy_redirect (boost::shared_ptr<Redirect> redirect)
921 boost::shared_ptr<Redirect> copy = Redirect::clone (redirect);
922 _rr_selection.add (copy);
926 RedirectBox::paste_redirects ()
928 if (_rr_selection.redirects.empty()) {
932 paste_redirect_list (_rr_selection.redirects);
936 RedirectBox::paste_redirect_list (list<boost::shared_ptr<Redirect> >& redirects)
938 list<boost::shared_ptr<Redirect> > copies;
940 for (list<boost::shared_ptr<Redirect> >::iterator i = redirects.begin(); i != redirects.end(); ++i) {
942 boost::shared_ptr<Redirect> copy = Redirect::clone (*i);
944 copy->set_placement (_placement, this);
945 copies.push_back (copy);
948 if (_route->add_redirects (copies, this)) {
951 "Copying the set of redirects on the clipboard failed,\n\
952 probably because the I/O configuration of the plugins\n\
953 could not match the configuration of this track.");
954 MessageDialog am (msg);
960 RedirectBox::activate_redirect (boost::shared_ptr<Redirect> r)
962 r->set_active (true, 0);
966 RedirectBox::deactivate_redirect (boost::shared_ptr<Redirect> r)
968 r->set_active (false, 0);
972 RedirectBox::get_selected_redirects (vector<boost::shared_ptr<Redirect> >& redirects)
974 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
976 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
977 redirects.push_back ((*(model->get_iter(*iter)))[columns.redirect]);
982 RedirectBox::for_selected_redirects (void (RedirectBox::*pmf)(boost::shared_ptr<Redirect>))
984 vector<Gtk::TreeModel::Path> pathlist = redirect_display.get_selection()->get_selected_rows();
986 for (vector<Gtk::TreeModel::Path>::iterator iter = pathlist.begin(); iter != pathlist.end(); ++iter) {
987 boost::shared_ptr<Redirect> redirect = (*(model->get_iter(*iter)))[columns.redirect];
988 (this->*pmf)(redirect);
993 RedirectBox::clone_redirects ()
995 RouteSelection& routes (_rr_selection.routes);
997 if (!routes.empty()) {
998 if (_route->copy_redirects (*routes.front(), _placement)) {
1000 "Copying the set of redirects on the clipboard failed,\n\
1001 probably because the I/O configuration of the plugins\n\
1002 could not match the configuration of this track.");
1003 MessageDialog am (msg);
1010 RedirectBox::all_redirects_active (bool state)
1012 _route->all_redirects_active (_placement, state);
1016 RedirectBox::clear_redirects ()
1019 vector<string> choices;
1021 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1022 if (_placement == PreFader) {
1023 prompt = _("Do you really want to remove all pre-fader redirects from this track?\n"
1024 "(this cannot be undone)");
1026 prompt = _("Do you really want to remove all post-fader redirects from this track?\n"
1027 "(this cannot be undone)");
1030 if (_placement == PreFader) {
1031 prompt = _("Do you really want to remove all pre-fader redirects from this bus?\n"
1032 "(this cannot be undone)");
1034 prompt = _("Do you really want to remove all post-fader redirects from this bus?\n"
1035 "(this cannot be undone)");
1039 choices.push_back (_("Cancel"));
1040 choices.push_back (_("Yes, remove them all"));
1042 Gtkmm2ext::Choice prompter (prompt, choices);
1044 if (prompter.run () == 1) {
1045 _route->clear_redirects (_placement, this);
1050 RedirectBox::edit_redirect (boost::shared_ptr<Redirect> redirect)
1052 boost::shared_ptr<Insert> insert;
1054 if (boost::dynamic_pointer_cast<AudioTrack>(_route) != 0) {
1056 if (boost::dynamic_pointer_cast<AudioTrack> (_route)->freeze_state() == AudioTrack::Frozen) {
1061 if ((insert = boost::dynamic_pointer_cast<Insert> (redirect)) == 0) {
1065 if (!_session.engine().connected()) {
1069 boost::shared_ptr<Send> send = boost::dynamic_pointer_cast<Send> (redirect);
1071 SendUIWindow *send_ui;
1073 if (send->get_gui() == 0) {
1075 send_ui = new SendUIWindow (send, _session);
1077 WindowTitle title(Glib::get_application_name());
1078 title += send->name();
1079 send_ui->set_title (title.get_string());
1081 send->set_gui (send_ui);
1084 send_ui = reinterpret_cast<SendUIWindow *> (send->get_gui());
1087 if (send_ui->is_visible()) {
1088 send_ui->get_window()->raise ();
1090 send_ui->show_all ();
1091 send_ui->present ();
1096 /* it's an insert */
1098 boost::shared_ptr<PluginInsert> plugin_insert;
1099 boost::shared_ptr<PortInsert> port_insert;
1101 if ((plugin_insert = boost::dynamic_pointer_cast<PluginInsert> (insert)) != 0) {
1103 PluginUIWindow *plugin_ui;
1105 /* these are both allowed to be null */
1107 Container* toplevel = get_toplevel();
1108 Window* win = dynamic_cast<Gtk::Window*>(toplevel);
1110 if (plugin_insert->get_gui() == 0) {
1112 plugin_ui = new PluginUIWindow (win, plugin_insert);
1114 WindowTitle title(Glib::get_application_name());
1115 title += generate_redirect_title (plugin_insert);
1116 plugin_ui->set_title (title.get_string());
1118 plugin_insert->set_gui (plugin_ui);
1120 // change window title when route name is changed
1121 _route->name_changed.connect (bind (mem_fun(*this, &RedirectBox::route_name_changed), plugin_ui, boost::weak_ptr<PluginInsert> (plugin_insert)));
1124 plugin_ui = reinterpret_cast<PluginUIWindow *> (plugin_insert->get_gui());
1125 plugin_ui->set_parent (win);
1128 if (plugin_ui->is_visible()) {
1129 plugin_ui->get_window()->raise ();
1131 plugin_ui->show_all ();
1132 plugin_ui->present ();
1135 } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (insert)) != 0) {
1137 if (!_session.engine().connected()) {
1138 MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
1143 PortInsertWindow *io_selector;
1145 if (port_insert->get_gui() == 0) {
1146 io_selector = new PortInsertWindow (_session, port_insert);
1147 port_insert->set_gui (io_selector);
1150 io_selector = reinterpret_cast<PortInsertWindow *> (port_insert->get_gui());
1153 if (io_selector->is_visible()) {
1154 io_selector->get_window()->raise ();
1156 io_selector->show_all ();
1157 io_selector->present ();
1164 RedirectBox::enter_box (GdkEventCrossing *ev, RedirectBox* rb)
1166 switch (ev->detail) {
1167 case GDK_NOTIFY_INFERIOR:
1170 case GDK_NOTIFY_VIRTUAL:
1174 _current_redirect_box = rb;
1181 RedirectBox::register_actions ()
1183 Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("redirectmenu"));
1184 Glib::RefPtr<Action> act;
1187 ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"), sigc::ptr_fun (RedirectBox::rb_choose_plugin));
1189 act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"), sigc::ptr_fun (RedirectBox::rb_choose_insert));
1190 ActionManager::jack_sensitive_actions.push_back (act);
1191 act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New Send ..."), sigc::ptr_fun (RedirectBox::rb_choose_send));
1192 ActionManager::jack_sensitive_actions.push_back (act);
1194 ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear"), sigc::ptr_fun (RedirectBox::rb_clear));
1196 /* standard editing stuff */
1197 act = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"), sigc::ptr_fun (RedirectBox::rb_cut));
1198 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1199 act = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"), sigc::ptr_fun (RedirectBox::rb_copy));
1200 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1202 act = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"), sigc::ptr_fun (RedirectBox::rb_delete));
1203 ActionManager::plugin_selection_sensitive_actions.push_back(act); // ??
1205 paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"), sigc::ptr_fun (RedirectBox::rb_paste));
1206 act = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"), sigc::ptr_fun (RedirectBox::rb_rename));
1207 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1208 ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"), sigc::ptr_fun (RedirectBox::rb_select_all));
1209 ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"), sigc::ptr_fun (RedirectBox::rb_deselect_all));
1212 act = ActionManager::register_action (popup_act_grp, X_("activate"), _("Activate"), sigc::ptr_fun (RedirectBox::rb_activate));
1213 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1214 act = ActionManager::register_action (popup_act_grp, X_("deactivate"), _("Deactivate"), sigc::ptr_fun (RedirectBox::rb_deactivate));
1215 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1216 ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate all"), sigc::ptr_fun (RedirectBox::rb_activate_all));
1217 ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate all"), sigc::ptr_fun (RedirectBox::rb_deactivate_all));
1220 act = ActionManager::register_action (popup_act_grp, X_("edit"), _("Edit"), sigc::ptr_fun (RedirectBox::rb_edit));
1221 ActionManager::plugin_selection_sensitive_actions.push_back(act);
1223 ActionManager::add_action_group (popup_act_grp);
1229 RedirectBox::rb_choose_plugin ()
1231 if (_current_redirect_box == 0) {
1234 _current_redirect_box->choose_plugin ();
1238 RedirectBox::rb_choose_insert ()
1240 if (_current_redirect_box == 0) {
1243 _current_redirect_box->choose_insert ();
1247 RedirectBox::rb_choose_send ()
1249 if (_current_redirect_box == 0) {
1252 _current_redirect_box->choose_send ();
1256 RedirectBox::rb_clear ()
1258 if (_current_redirect_box == 0) {
1262 _current_redirect_box->clear_redirects ();
1266 RedirectBox::rb_cut ()
1268 if (_current_redirect_box == 0) {
1272 _current_redirect_box->cut_redirects ();
1276 RedirectBox::rb_delete ()
1278 if (_current_redirect_box == 0) {
1282 _current_redirect_box->delete_redirects ();
1286 RedirectBox::rb_copy ()
1288 if (_current_redirect_box == 0) {
1291 _current_redirect_box->copy_redirects ();
1295 RedirectBox::rb_paste ()
1297 if (_current_redirect_box == 0) {
1301 _current_redirect_box->paste_redirects ();
1305 RedirectBox::rb_rename ()
1307 if (_current_redirect_box == 0) {
1310 _current_redirect_box->rename_redirects ();
1314 RedirectBox::rb_select_all ()
1316 if (_current_redirect_box == 0) {
1320 _current_redirect_box->select_all_redirects ();
1324 RedirectBox::rb_deselect_all ()
1326 if (_current_redirect_box == 0) {
1330 _current_redirect_box->deselect_all_redirects ();
1334 RedirectBox::rb_activate ()
1336 if (_current_redirect_box == 0) {
1340 _current_redirect_box->for_selected_redirects (&RedirectBox::activate_redirect);
1344 RedirectBox::rb_deactivate ()
1346 if (_current_redirect_box == 0) {
1349 _current_redirect_box->for_selected_redirects (&RedirectBox::deactivate_redirect);
1353 RedirectBox::rb_activate_all ()
1355 if (_current_redirect_box == 0) {
1359 _current_redirect_box->all_redirects_active (true);
1363 RedirectBox::rb_deactivate_all ()
1365 if (_current_redirect_box == 0) {
1368 _current_redirect_box->all_redirects_active (false);
1372 RedirectBox::rb_edit ()
1374 if (_current_redirect_box == 0) {
1378 _current_redirect_box->for_selected_redirects (&RedirectBox::edit_redirect);
1382 RedirectBox::route_name_changed (void* src, PluginUIWindow* plugin_ui, boost::weak_ptr<PluginInsert> wpi)
1384 ENSURE_GUI_THREAD(bind (mem_fun (*this, &RedirectBox::route_name_changed), src, plugin_ui, wpi));
1385 boost::shared_ptr<PluginInsert> pi (wpi.lock());
1389 WindowTitle title(Glib::get_application_name());
1390 title += generate_redirect_title (pi);
1391 plugin_ui->set_title (title.get_string());
1396 RedirectBox::generate_redirect_title (boost::shared_ptr<PluginInsert> pi)
1398 string maker = pi->plugin()->maker() ? pi->plugin()->maker() : "";
1399 string::size_type email_pos;
1401 if ((email_pos = maker.find_first_of ('<')) != string::npos) {
1402 maker = maker.substr (0, email_pos - 1);
1405 if (maker.length() > 32) {
1406 maker = maker.substr (0, 32);
1410 return string_compose(_("%1: %2 (by %3)"), _route->name(), pi->name(), maker);
1414 RedirectBox::plugin_selector_hidden ()
1416 newplug_connection.disconnect();
1417 using_plugin_selector = false;
1421 RedirectBox::plugin_selector_shown ()
1423 using_plugin_selector = true;