2 Copyright (C) 2010 Paul Davis
3 Copyright (C) 2017 Ben Loftis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <gtkmm/comboboxtext.h>
21 #include <gtkmm/box.h>
22 #include <gtkmm/spinbutton.h>
23 #include <gtkmm/table.h>
24 #include <gtkmm/treeview.h>
25 #include <gtkmm/liststore.h>
26 #include <gtkmm/treestore.h>
27 #include <gtkmm/notebook.h>
28 #include <gtkmm/cellrenderercombo.h>
29 #include <gtkmm/scale.h>
30 #include <gtkmm/alignment.h>
32 #include "pbd/error.h"
33 #include "pbd/unwind.h"
34 #include "pbd/strsplit.h"
35 #include "pbd/stacktrace.h"
37 #include "gtkmm2ext/actions.h"
38 #include "gtkmm2ext/bindings.h"
39 #include "gtkmm2ext/gui_thread.h"
40 #include "gtkmm2ext/utils.h"
42 #include "ardour/audioengine.h"
43 #include "ardour/port.h"
44 #include "ardour/rc_configuration.h"
46 #include "us2400_control_protocol.h"
47 #include "device_info.h"
50 #include "surface_port.h"
56 using namespace ArdourSurface;
57 using namespace US2400;
60 US2400Protocol::get_gui () const
63 const_cast<US2400Protocol*>(this)->build_gui ();
65 static_cast<Gtk::Notebook*>(_gui)->show_all();
70 US2400Protocol::tear_down_gui ()
73 Gtk::Widget *w = static_cast<Gtk::Widget*>(_gui)->get_parent();
79 delete (US2400ProtocolGUI*) _gui;
84 US2400Protocol::build_gui ()
86 _gui = (void *) new US2400ProtocolGUI (*this);
89 US2400ProtocolGUI::US2400ProtocolGUI (US2400Protocol& p)
92 , _device_dependent_widget (0)
93 , _ignore_profile_changed (false)
94 , ignore_active_change (false)
97 Gtk::Alignment* align;
100 set_border_width (12);
102 table.set_row_spacings (4);
103 table.set_col_spacings (6);
104 table.set_border_width (12);
105 table.set_homogeneous (false);
107 _cp.DeviceChanged.connect (device_change_connection, invalidator (*this), boost::bind (&US2400ProtocolGUI::device_changed, this), gui_context());
108 _cp.ConnectionChange.connect (connection_change_connection, invalidator (*this), boost::bind (&US2400ProtocolGUI::connection_handler, this), gui_context());
110 /* device-dependent part */
112 device_dependent_row = row;
114 if (_device_dependent_widget) {
115 table.remove (*_device_dependent_widget);
116 _device_dependent_widget = 0;
119 _device_dependent_widget = device_dependent_widget ();
120 table.attach (*_device_dependent_widget, 0, 12, row, row+1, AttachOptions(0), AttachOptions(0), 0, 0);
123 /* back to the boilerplate */
125 vector<string> profiles;
127 for (std::map<std::string,DeviceProfile>::iterator i = DeviceProfile::device_profiles.begin(); i != DeviceProfile::device_profiles.end(); ++i) {
128 cerr << "add discovered profile " << i->first << endl;
129 profiles.push_back (i->first);
131 Gtkmm2ext::set_popdown_strings (_profile_combo, profiles);
132 cerr << "set active profile from " << p.device_profile().name() << endl;
133 _profile_combo.set_active_text (p.device_profile().name());
134 _profile_combo.signal_changed().connect (sigc::mem_fun (*this, &US2400ProtocolGUI::profile_combo_changed));
136 append_page (table, _("Device Setup"));
139 /* function key editor */
141 VBox* fkey_packer = manage (new VBox);
142 HBox* profile_packer = manage (new HBox);
143 HBox* observation_packer = manage (new HBox);
145 l = manage (new Gtk::Label (_("Profile/Settings:")));
146 profile_packer->pack_start (*l, false, false);
147 profile_packer->pack_start (_profile_combo, true, true);
148 profile_packer->set_spacing (12);
149 profile_packer->set_border_width (12);
151 fkey_packer->pack_start (*profile_packer, false, false);
152 fkey_packer->pack_start (function_key_scroller, true, true);
153 fkey_packer->pack_start (*observation_packer, false, false);
154 fkey_packer->set_spacing (12);
155 function_key_scroller.property_shadow_type() = Gtk::SHADOW_NONE;
156 function_key_scroller.add (function_key_editor);
157 append_page (*fkey_packer, _("Function Keys"));
159 build_available_action_menu ();
160 build_function_key_editor ();
161 refresh_function_key_editor ();
162 fkey_packer->show_all();
166 US2400ProtocolGUI::connection_handler ()
168 /* ignore all changes to combobox active strings here, because we're
169 updating them to match a new ("external") reality - we were called
170 because port connections have changed.
173 PBD::Unwinder<bool> ici (ignore_active_change, true);
175 vector<Gtk::ComboBox*>::iterator ic;
176 vector<Gtk::ComboBox*>::iterator oc;
178 vector<string> midi_inputs;
179 vector<string> midi_outputs;
181 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsTerminal), midi_inputs);
182 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsTerminal), midi_outputs);
184 for (ic = input_combos.begin(), oc = output_combos.begin(); ic != input_combos.end() && oc != output_combos.end(); ++ic, ++oc) {
186 boost::shared_ptr<Surface> surface = _cp.get_surface_by_raw_pointer ((*ic)->get_data ("surface"));
189 update_port_combos (midi_inputs, midi_outputs, *ic, *oc, surface);
195 US2400ProtocolGUI::update_port_combos (vector<string> const& midi_inputs, vector<string> const& midi_outputs,
196 Gtk::ComboBox* input_combo,
197 Gtk::ComboBox* output_combo,
198 boost::shared_ptr<Surface> surface)
200 Glib::RefPtr<Gtk::ListStore> input = build_midi_port_list (midi_inputs, true);
201 Glib::RefPtr<Gtk::ListStore> output = build_midi_port_list (midi_outputs, false);
202 bool input_found = false;
203 bool output_found = false;
206 input_combo->set_model (input);
207 output_combo->set_model (output);
209 Gtk::TreeModel::Children children = input->children();
210 Gtk::TreeModel::Children::iterator i;
211 i = children.begin();
212 ++i; /* skip "Disconnected" */
215 for (n = 1; i != children.end(); ++i, ++n) {
216 string port_name = (*i)[midi_port_columns.full_name];
217 if (surface->port().input().connected_to (port_name)) {
218 input_combo->set_active (n);
225 input_combo->set_active (0); /* disconnected */
228 children = output->children();
229 i = children.begin();
230 ++i; /* skip "Disconnected" */
232 for (n = 1; i != children.end(); ++i, ++n) {
233 string port_name = (*i)[midi_port_columns.full_name];
234 if (surface->port().output().connected_to (port_name)) {
235 output_combo->set_active (n);
242 output_combo->set_active (0); /* disconnected */
247 US2400ProtocolGUI::device_dependent_widget ()
249 Gtk::Table* dd_table;
253 uint32_t n_surfaces = 1 + _cp.device_info().extenders();
254 uint32_t main_pos = _cp.device_info().master_position();
256 dd_table = Gtk::manage (new Gtk::Table (2, n_surfaces));
257 dd_table->set_row_spacings (4);
258 dd_table->set_col_spacings (6);
259 dd_table->set_border_width (12);
261 vector<string> midi_inputs;
262 vector<string> midi_outputs;
264 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsPhysical), midi_inputs);
265 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsPhysical), midi_outputs);
267 input_combos.clear ();
268 output_combos.clear ();
270 int portcount = n_surfaces;
272 for (uint32_t n = 0; n < portcount; ++n) {
274 boost::shared_ptr<Surface> surface = _cp.nth_surface (n);
277 PBD::fatal << string_compose (_("programming error: %1\n"), string_compose ("n=%1 surface not found!", n)) << endmsg;
281 Gtk::ComboBox* input_combo = manage (new Gtk::ComboBox);
282 Gtk::ComboBox* output_combo = manage (new Gtk::ComboBox);
284 update_port_combos (midi_inputs, midi_outputs, input_combo, output_combo, surface);
286 input_combo->pack_start (midi_port_columns.short_name);
287 input_combo->set_data ("surface", surface.get());
288 input_combos.push_back (input_combo);
289 output_combo->pack_start (midi_port_columns.short_name);
290 output_combo->set_data ("surface", surface.get());
291 output_combos.push_back (output_combo);
293 boost::weak_ptr<Surface> ws (surface);
294 input_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &US2400ProtocolGUI::active_port_changed), input_combo, ws, true));
295 output_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &US2400ProtocolGUI::active_port_changed), output_combo, ws, false));
298 string receive_string;
300 //port 1,2,3 are faders & pan knobs. like mackie MCU
301 //port 4 is the joystick
302 //port 5 sends "chan" knobs (24 of them )
303 //port 6 --- ??? ( could be send to knobs... ? )
305 send_string = string_compose(_("US-2400 send port #%1 (faders %2 to %3):"), n + 1, n*8+1, n*8+8);
306 receive_string = string_compose(_("US-2400 receive port #%1 (faders %2 to %3):"), n + 1, n*8+1, n*8+8);
308 send_string = string_compose(_("US-2400 send port #%1 (joystick):"), n + 1);
309 receive_string = string_compose(_("US-2400 receive port #%1 (joystick):"), n + 1);
312 l = manage (new Gtk::Label (send_string));
313 l->set_alignment (1.0, 0.5);
314 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
315 dd_table->attach (*input_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
318 l = manage (new Gtk::Label (receive_string));
319 l->set_alignment (1.0, 0.5);
320 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
321 dd_table->attach (*output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
327 l = manage (new Gtk::Label ("US-2400 Port #5 is reserved for use as a generic USB device. (click the CHAN button to activate)"));
328 l->set_alignment (1.0, 0.5);
329 dd_table->attach (*l, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
333 l = manage (new Gtk::Label ("US-2400 Port #6 is unused."));
334 l->set_alignment (1.0, 0.5);
335 dd_table->attach (*l, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
339 l = manage (new Gtk::Label ("NOTE: you must select mode 4 on the US-2400 unit."));
340 l->set_alignment (1.0, 0.5);
341 dd_table->attach (*l, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
349 US2400ProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, Gtk::TreeModelColumnBase column)
351 CellRendererCombo* renderer = manage (new CellRendererCombo);
352 renderer->property_model() = model;
353 renderer->property_editable() = true;
354 renderer->property_text_column() = 0;
355 renderer->property_has_entry() = false;
356 renderer->signal_edited().connect (sigc::bind (sigc::mem_fun(*this, &US2400ProtocolGUI::action_changed), column));
362 US2400ProtocolGUI::build_available_action_menu ()
364 /* build a model of all available actions (needs to be tree structured
368 available_action_model = TreeStore::create (available_action_columns);
370 vector<string> paths;
371 vector<string> labels;
372 vector<string> tooltips;
374 vector<Glib::RefPtr<Gtk::Action> > actions;
376 typedef std::map<string,TreeIter> NodeMap;
380 Gtkmm2ext::ActionMap::get_all_actions (paths, labels, tooltips, keys, actions);
382 vector<string>::iterator k;
383 vector<string>::iterator p;
384 vector<string>::iterator t;
385 vector<string>::iterator l;
387 available_action_model->clear ();
389 /* Because there are button bindings built in that are not
390 in the key binding map, there needs to be a way to undo
394 TreeModel::Row parent;
395 rowp = available_action_model->append();
397 parent[available_action_columns.name] = _("Remove Binding");
401 rowp = available_action_model->append();
403 parent[available_action_columns.name] = _("Shift");
404 rowp = available_action_model->append();
406 parent[available_action_columns.name] = _("Control");
407 rowp = available_action_model->append();
409 parent[available_action_columns.name] = _("Option");
410 rowp = available_action_model->append();
412 parent[available_action_columns.name] = _("CmdAlt");
414 for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
417 vector<string> parts;
421 split (*p, parts, '/');
427 //kinda kludgy way to avoid displaying menu items as mappable
428 if ( parts[1] == _("Main_menu") )
430 if ( parts[1] == _("JACK") )
432 if ( parts[1] == _("redirectmenu") )
434 if ( parts[1] == _("Editor_menus") )
436 if ( parts[1] == _("RegionList") )
438 if ( parts[1] == _("ProcessorMenu") )
441 if ((r = nodes.find (parts[1])) == nodes.end()) {
443 /* top level is missing */
446 TreeModel::Row parent;
447 rowp = available_action_model->append();
448 nodes[parts[1]] = rowp;
450 parent[available_action_columns.name] = parts[1];
452 row = *(available_action_model->append (parent.children()));
456 row = *(available_action_model->append ((*r->second)->children()));
460 /* add this action */
463 row[available_action_columns.name] = *t;
466 row[available_action_columns.name] = *l;
470 row[available_action_columns.path] = (*p);
475 US2400ProtocolGUI::build_function_key_editor ()
477 function_key_editor.append_column (_("Key"), function_key_columns.name);
480 CellRendererCombo* renderer;
482 renderer = make_action_renderer (available_action_model, function_key_columns.plain);
483 col = manage (new TreeViewColumn (_("Plain"), *renderer));
484 col->add_attribute (renderer->property_text(), function_key_columns.plain);
485 function_key_editor.append_column (*col);
487 renderer = make_action_renderer (available_action_model, function_key_columns.shift);
488 col = manage (new TreeViewColumn (_("Shift"), *renderer));
489 col->add_attribute (renderer->property_text(), function_key_columns.shift);
490 function_key_editor.append_column (*col);
493 * renderer = make_action_renderer (available_action_model, function_key_columns.control);
494 col = manage (new TreeViewColumn (_("Control"), *renderer));
495 col->add_attribute (renderer->property_text(), function_key_columns.control);
496 function_key_editor.append_column (*col);
498 renderer = make_action_renderer (available_action_model, function_key_columns.option);
499 col = manage (new TreeViewColumn (_("Option"), *renderer));
500 col->add_attribute (renderer->property_text(), function_key_columns.option);
501 function_key_editor.append_column (*col);
503 renderer = make_action_renderer (available_action_model, function_key_columns.cmdalt);
504 col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer));
505 col->add_attribute (renderer->property_text(), function_key_columns.cmdalt);
506 function_key_editor.append_column (*col);
508 renderer = make_action_renderer (available_action_model, function_key_columns.shiftcontrol);
509 col = manage (new TreeViewColumn (_("Shift+Control"), *renderer));
510 col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol);
511 function_key_editor.append_column (*col);
514 function_key_model = ListStore::create (function_key_columns);
515 function_key_editor.set_model (function_key_model);
519 US2400ProtocolGUI::refresh_function_key_editor ()
521 function_key_editor.set_model (Glib::RefPtr<TreeModel>());
522 function_key_model->clear ();
524 /* now fill with data */
527 DeviceProfile dp (_cp.device_profile());
530 for (int n = 0; n < US2400::Button::FinalGlobalButton; ++n) {
532 US2400::Button::ID bid = (US2400::Button::ID) n;
534 row = *(function_key_model->append());
535 if (di.global_buttons().find (bid) == di.global_buttons().end()) {
536 row[function_key_columns.name] = US2400::Button::id_to_name (bid);
538 row[function_key_columns.name] = di.get_global_button_name (bid) + "*";
540 row[function_key_columns.id] = bid;
542 Glib::RefPtr<Gtk::Action> act;
544 const string defstring = "\u2022";
546 /* We only allow plain bindings for Fn keys. All others are
547 * reserved for hard-coded actions.
550 if (bid >= US2400::Button::F1 && bid <= US2400::Button::F6) {
552 action = dp.get_button_action (bid, 0);
553 if (action.empty()) {
554 row[function_key_columns.plain] = defstring;
556 if (action.find ('/') == string::npos) {
557 /* Probably a key alias */
558 row[function_key_columns.plain] = action;
561 act = ActionManager::get_action (action.c_str());
563 row[function_key_columns.plain] = act->get_label();
565 row[function_key_columns.plain] = defstring;
571 //~ /* We only allow plain bindings for Fn keys. All others are
572 //~ * reserved for hard-coded actions.
575 //~ if (bid >= US2400::Button::F1 && bid <= US2400::Button::F8) {
577 //~ action = dp.get_button_action (bid, US2400Protocol::MODIFIER_SHIFT);
578 //~ if (action.empty()) {
579 //~ row[function_key_columns.shift] = defstring;
581 //~ if (action.find ('/') == string::npos) {
582 //~ /* Probably a key alias */
583 //~ row[function_key_columns.shift] = action;
585 //~ act = ActionManager::get_action (action.c_str());
587 //~ row[function_key_columns.shift] = act->get_label();
589 //~ row[function_key_columns.shift] = defstring;
595 //~ action = dp.get_button_action (bid, US2400Protocol::MODIFIER_CONTROL);
596 //~ if (action.empty()) {
597 //~ row[function_key_columns.control] = defstring;
599 //~ if (action.find ('/') == string::npos) {
600 //~ /* Probably a key alias */
601 //~ row[function_key_columns.control] = action;
603 //~ act = ActionManager::get_action (action.c_str());
605 //~ row[function_key_columns.control] = act->get_label();
607 //~ row[function_key_columns.control] = defstring;
612 //~ action = dp.get_button_action (bid, US2400Protocol::MODIFIER_OPTION);
613 //~ if (action.empty()) {
614 //~ row[function_key_columns.option] = defstring;
616 //~ if (action.find ('/') == string::npos) {
617 //~ /* Probably a key alias */
618 //~ row[function_key_columns.option] = action;
620 //~ act = ActionManager::get_action (action.c_str());
622 //~ row[function_key_columns.option] = act->get_label();
624 //~ row[function_key_columns.option] = defstring;
629 //~ action = dp.get_button_action (bid, US2400Protocol::MODIFIER_CMDALT);
630 //~ if (action.empty()) {
631 //~ row[function_key_columns.cmdalt] = defstring;
633 //~ if (action.find ('/') == string::npos) {
634 //~ /* Probably a key alias */
635 //~ row[function_key_columns.cmdalt] = action;
637 //~ act = ActionManager::get_action (action.c_str());
639 //~ row[function_key_columns.cmdalt] = act->get_label();
641 //~ row[function_key_columns.cmdalt] = defstring;
646 //~ action = dp.get_button_action (bid, (US2400Protocol::MODIFIER_SHIFT|US2400Protocol::MODIFIER_CONTROL));
647 //~ if (action.empty()) {
648 //~ row[function_key_columns.shiftcontrol] = defstring;
650 //~ act = ActionManager::get_action (action.c_str());
652 //~ row[function_key_columns.shiftcontrol] = act->get_label();
654 //~ row[function_key_columns.shiftcontrol] = defstring;
659 function_key_editor.set_model (function_key_model);
663 US2400ProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib::ustring &text, TreeModelColumnBase col)
665 // Remove Binding is not in the action map but still valid
667 if ( text == "Remove Binding") {
670 Gtk::TreePath path(sPath);
671 Gtk::TreeModel::iterator row = function_key_model->get_iter(path);
675 std::map<std::string,std::string>::iterator i = action_map.find (text);
677 if (i == action_map.end()) {
682 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (i->second.c_str());
685 /* update visible text, using string supplied by
686 available action model so that it matches and is found
690 Glib::ustring dot = "\u2022";
691 (*row).set_value (col.index(), dot);
693 (*row).set_value (col.index(), text);
696 /* update the current DeviceProfile, using the full
702 switch (col.index()) {
704 modifier = US2400Protocol::MODIFIER_SHIFT;
707 modifier = US2400Protocol::MODIFIER_CONTROL;
710 modifier = US2400Protocol::MODIFIER_OPTION;
713 modifier = US2400Protocol::MODIFIER_CMDALT;
716 modifier = (US2400Protocol::MODIFIER_SHIFT|US2400Protocol::MODIFIER_CONTROL);
723 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, "");
725 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, i->second);
728 _ignore_profile_changed = true;
729 _profile_combo.set_active_text ( _cp.device_profile().name() );
730 _ignore_profile_changed = false;
733 std::cerr << "no such action\n";
739 US2400ProtocolGUI::device_changed ()
741 if (_device_dependent_widget) {
742 table.remove (*_device_dependent_widget);
743 _device_dependent_widget = 0;
746 _device_dependent_widget = device_dependent_widget ();
747 _device_dependent_widget->show_all ();
749 table.attach (*_device_dependent_widget, 0, 12, device_dependent_row, device_dependent_row+1, AttachOptions(0), AttachOptions(0), 0, 0);
753 US2400ProtocolGUI::profile_combo_changed ()
755 if (!_ignore_profile_changed) {
756 string profile = _profile_combo.get_active_text();
758 _cp.set_profile (profile);
760 refresh_function_key_editor ();
764 Glib::RefPtr<Gtk::ListStore>
765 US2400ProtocolGUI::build_midi_port_list (vector<string> const & ports, bool for_input)
767 Glib::RefPtr<Gtk::ListStore> store = ListStore::create (midi_port_columns);
770 row = *store->append ();
771 row[midi_port_columns.full_name] = string();
772 row[midi_port_columns.short_name] = _("Disconnected");
774 for (vector<string>::const_iterator p = ports.begin(); p != ports.end(); ++p) {
775 row = *store->append ();
776 row[midi_port_columns.full_name] = *p;
777 std::string pn = ARDOUR::AudioEngine::instance()->get_pretty_name_by_name (*p);
779 pn = (*p).substr ((*p).find (':') + 1);
781 row[midi_port_columns.short_name] = pn;
788 US2400ProtocolGUI::active_port_changed (Gtk::ComboBox* combo, boost::weak_ptr<Surface> ws, bool for_input)
790 if (ignore_active_change) {
794 boost::shared_ptr<Surface> surface = ws.lock();
800 TreeModel::iterator active = combo->get_active ();
801 string new_port = (*active)[midi_port_columns.full_name];
803 if (new_port.empty()) {
805 surface->port().input().disconnect_all ();
807 surface->port().output().disconnect_all ();
814 if (!surface->port().input().connected_to (new_port)) {
815 surface->port().input().disconnect_all ();
816 surface->port().input().connect (new_port);
819 if (!surface->port().output().connected_to (new_port)) {
820 surface->port().output().disconnect_all ();
821 surface->port().output().connect (new_port);