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)
99 set_border_width (12);
101 table.set_row_spacings (4);
102 table.set_col_spacings (6);
103 table.set_border_width (12);
104 table.set_homogeneous (false);
106 _cp.DeviceChanged.connect (device_change_connection, invalidator (*this), boost::bind (&US2400ProtocolGUI::device_changed, this), gui_context());
107 _cp.ConnectionChange.connect (connection_change_connection, invalidator (*this), boost::bind (&US2400ProtocolGUI::connection_handler, this), gui_context());
109 /* device-dependent part */
111 device_dependent_row = row;
113 if (_device_dependent_widget) {
114 table.remove (*_device_dependent_widget);
115 _device_dependent_widget = 0;
118 _device_dependent_widget = device_dependent_widget ();
119 table.attach (*_device_dependent_widget, 0, 12, row, row+1, AttachOptions(0), AttachOptions(0), 0, 0);
122 /* back to the boilerplate */
124 vector<string> profiles;
126 for (std::map<std::string,DeviceProfile>::iterator i = DeviceProfile::device_profiles.begin(); i != DeviceProfile::device_profiles.end(); ++i) {
127 cerr << "add discovered profile " << i->first << endl;
128 profiles.push_back (i->first);
130 Gtkmm2ext::set_popdown_strings (_profile_combo, profiles);
131 cerr << "set active profile from " << p.device_profile().name() << endl;
132 _profile_combo.set_active_text (p.device_profile().name());
133 _profile_combo.signal_changed().connect (sigc::mem_fun (*this, &US2400ProtocolGUI::profile_combo_changed));
135 append_page (table, _("Device Setup"));
138 /* function key editor */
140 VBox* fkey_packer = manage (new VBox);
141 HBox* profile_packer = manage (new HBox);
142 HBox* observation_packer = manage (new HBox);
144 l = manage (new Gtk::Label (_("Profile/Settings:")));
145 profile_packer->pack_start (*l, false, false);
146 profile_packer->pack_start (_profile_combo, true, true);
147 profile_packer->set_spacing (12);
148 profile_packer->set_border_width (12);
150 fkey_packer->pack_start (*profile_packer, false, false);
151 fkey_packer->pack_start (function_key_scroller, true, true);
152 fkey_packer->pack_start (*observation_packer, false, false);
153 fkey_packer->set_spacing (12);
154 function_key_scroller.property_shadow_type() = Gtk::SHADOW_NONE;
155 function_key_scroller.add (function_key_editor);
156 append_page (*fkey_packer, _("Function Keys"));
158 build_available_action_menu ();
159 build_function_key_editor ();
160 refresh_function_key_editor ();
161 fkey_packer->show_all();
165 US2400ProtocolGUI::connection_handler ()
167 /* ignore all changes to combobox active strings here, because we're
168 updating them to match a new ("external") reality - we were called
169 because port connections have changed.
172 PBD::Unwinder<bool> ici (ignore_active_change, true);
174 vector<Gtk::ComboBox*>::iterator ic;
175 vector<Gtk::ComboBox*>::iterator oc;
177 vector<string> midi_inputs;
178 vector<string> midi_outputs;
180 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsTerminal), midi_inputs);
181 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsTerminal), midi_outputs);
183 for (ic = input_combos.begin(), oc = output_combos.begin(); ic != input_combos.end() && oc != output_combos.end(); ++ic, ++oc) {
185 boost::shared_ptr<Surface> surface = _cp.get_surface_by_raw_pointer ((*ic)->get_data ("surface"));
188 update_port_combos (midi_inputs, midi_outputs, *ic, *oc, surface);
194 US2400ProtocolGUI::update_port_combos (vector<string> const& midi_inputs, vector<string> const& midi_outputs,
195 Gtk::ComboBox* input_combo,
196 Gtk::ComboBox* output_combo,
197 boost::shared_ptr<Surface> surface)
199 Glib::RefPtr<Gtk::ListStore> input = build_midi_port_list (midi_inputs, true);
200 Glib::RefPtr<Gtk::ListStore> output = build_midi_port_list (midi_outputs, false);
201 bool input_found = false;
202 bool output_found = false;
205 input_combo->set_model (input);
206 output_combo->set_model (output);
208 Gtk::TreeModel::Children children = input->children();
209 Gtk::TreeModel::Children::iterator i;
210 i = children.begin();
211 ++i; /* skip "Disconnected" */
214 for (n = 1; i != children.end(); ++i, ++n) {
215 string port_name = (*i)[midi_port_columns.full_name];
216 if (surface->port().input().connected_to (port_name)) {
217 input_combo->set_active (n);
224 input_combo->set_active (0); /* disconnected */
227 children = output->children();
228 i = children.begin();
229 ++i; /* skip "Disconnected" */
231 for (n = 1; i != children.end(); ++i, ++n) {
232 string port_name = (*i)[midi_port_columns.full_name];
233 if (surface->port().output().connected_to (port_name)) {
234 output_combo->set_active (n);
241 output_combo->set_active (0); /* disconnected */
246 US2400ProtocolGUI::device_dependent_widget ()
248 Gtk::Table* dd_table;
252 uint32_t n_surfaces = 1 + _cp.device_info().extenders();
254 dd_table = Gtk::manage (new Gtk::Table (2, n_surfaces));
255 dd_table->set_row_spacings (4);
256 dd_table->set_col_spacings (6);
257 dd_table->set_border_width (12);
259 vector<string> midi_inputs;
260 vector<string> midi_outputs;
262 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsPhysical), midi_inputs);
263 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsPhysical), midi_outputs);
265 input_combos.clear ();
266 output_combos.clear ();
268 int portcount = n_surfaces;
270 for (int32_t n = 0; n < portcount; ++n) {
272 boost::shared_ptr<Surface> surface = _cp.nth_surface (n);
275 PBD::fatal << string_compose (_("programming error: %1\n"), string_compose ("n=%1 surface not found!", n)) << endmsg;
279 Gtk::ComboBox* input_combo = manage (new Gtk::ComboBox);
280 Gtk::ComboBox* output_combo = manage (new Gtk::ComboBox);
282 update_port_combos (midi_inputs, midi_outputs, input_combo, output_combo, surface);
284 input_combo->pack_start (midi_port_columns.short_name);
285 input_combo->set_data ("surface", surface.get());
286 input_combos.push_back (input_combo);
287 output_combo->pack_start (midi_port_columns.short_name);
288 output_combo->set_data ("surface", surface.get());
289 output_combos.push_back (output_combo);
291 boost::weak_ptr<Surface> ws (surface);
292 input_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &US2400ProtocolGUI::active_port_changed), input_combo, ws, true));
293 output_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &US2400ProtocolGUI::active_port_changed), output_combo, ws, false));
296 string receive_string;
298 //port 1,2,3 are faders & pan knobs. like mackie MCU
299 //port 4 is the joystick
300 //port 5 sends "chan" knobs (24 of them )
301 //port 6 --- ??? ( could be send to knobs... ? )
303 send_string = string_compose(_("US-2400 send port #%1 (faders %2 to %3):"), n + 1, n*8+1, n*8+8);
304 receive_string = string_compose(_("US-2400 receive port #%1 (faders %2 to %3):"), n + 1, n*8+1, n*8+8);
306 send_string = string_compose(_("US-2400 send port #%1 (joystick):"), n + 1);
307 receive_string = string_compose(_("US-2400 receive port #%1 (joystick):"), n + 1);
310 l = manage (new Gtk::Label (send_string));
311 l->set_alignment (1.0, 0.5);
312 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
313 dd_table->attach (*input_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
316 l = manage (new Gtk::Label (receive_string));
317 l->set_alignment (1.0, 0.5);
318 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
319 dd_table->attach (*output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
325 l = manage (new Gtk::Label ("US-2400 Port #5 is reserved for use as a generic USB device. (click the CHAN button to activate)"));
326 l->set_alignment (1.0, 0.5);
327 dd_table->attach (*l, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
331 l = manage (new Gtk::Label ("US-2400 Port #6 is unused."));
332 l->set_alignment (1.0, 0.5);
333 dd_table->attach (*l, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
337 l = manage (new Gtk::Label ("NOTE: you must select mode 4 on the US-2400 unit."));
338 l->set_alignment (1.0, 0.5);
339 dd_table->attach (*l, 0, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
347 US2400ProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, Gtk::TreeModelColumnBase column)
349 CellRendererCombo* renderer = manage (new CellRendererCombo);
350 renderer->property_model() = model;
351 renderer->property_editable() = true;
352 renderer->property_text_column() = 0;
353 renderer->property_has_entry() = false;
354 renderer->signal_edited().connect (sigc::bind (sigc::mem_fun(*this, &US2400ProtocolGUI::action_changed), column));
360 US2400ProtocolGUI::build_available_action_menu ()
362 /* build a model of all available actions (needs to be tree structured
366 available_action_model = TreeStore::create (available_action_columns);
368 vector<string> paths;
369 vector<string> labels;
370 vector<string> tooltips;
372 vector<Glib::RefPtr<Gtk::Action> > actions;
374 typedef std::map<string,TreeIter> NodeMap;
378 Gtkmm2ext::ActionMap::get_all_actions (paths, labels, tooltips, keys, actions);
380 vector<string>::iterator k;
381 vector<string>::iterator p;
382 vector<string>::iterator t;
383 vector<string>::iterator l;
385 available_action_model->clear ();
387 /* Because there are button bindings built in that are not
388 in the key binding map, there needs to be a way to undo
392 TreeModel::Row parent;
393 rowp = available_action_model->append();
395 parent[available_action_columns.name] = _("Remove Binding");
399 rowp = available_action_model->append();
401 parent[available_action_columns.name] = _("Shift");
402 rowp = available_action_model->append();
404 parent[available_action_columns.name] = _("Control");
405 rowp = available_action_model->append();
407 parent[available_action_columns.name] = _("Option");
408 rowp = available_action_model->append();
410 parent[available_action_columns.name] = _("CmdAlt");
412 for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
415 vector<string> parts;
419 split (*p, parts, '/');
425 //kinda kludgy way to avoid displaying menu items as mappable
426 if ( parts[1] == _("Main_menu") )
428 if ( parts[1] == _("JACK") )
430 if ( parts[1] == _("redirectmenu") )
432 if ( parts[1] == _("Editor_menus") )
434 if ( parts[1] == _("RegionList") )
436 if ( parts[1] == _("ProcessorMenu") )
439 if ((r = nodes.find (parts[1])) == nodes.end()) {
441 /* top level is missing */
444 TreeModel::Row parent;
445 rowp = available_action_model->append();
446 nodes[parts[1]] = rowp;
448 parent[available_action_columns.name] = parts[1];
450 row = *(available_action_model->append (parent.children()));
454 row = *(available_action_model->append ((*r->second)->children()));
458 /* add this action */
461 row[available_action_columns.name] = *t;
464 row[available_action_columns.name] = *l;
468 row[available_action_columns.path] = (*p);
473 US2400ProtocolGUI::build_function_key_editor ()
475 function_key_editor.append_column (_("Key"), function_key_columns.name);
478 CellRendererCombo* renderer;
480 renderer = make_action_renderer (available_action_model, function_key_columns.plain);
481 col = manage (new TreeViewColumn (_("Plain"), *renderer));
482 col->add_attribute (renderer->property_text(), function_key_columns.plain);
483 function_key_editor.append_column (*col);
485 renderer = make_action_renderer (available_action_model, function_key_columns.shift);
486 col = manage (new TreeViewColumn (_("Shift"), *renderer));
487 col->add_attribute (renderer->property_text(), function_key_columns.shift);
488 function_key_editor.append_column (*col);
491 * renderer = make_action_renderer (available_action_model, function_key_columns.control);
492 col = manage (new TreeViewColumn (_("Control"), *renderer));
493 col->add_attribute (renderer->property_text(), function_key_columns.control);
494 function_key_editor.append_column (*col);
496 renderer = make_action_renderer (available_action_model, function_key_columns.option);
497 col = manage (new TreeViewColumn (_("Option"), *renderer));
498 col->add_attribute (renderer->property_text(), function_key_columns.option);
499 function_key_editor.append_column (*col);
501 renderer = make_action_renderer (available_action_model, function_key_columns.cmdalt);
502 col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer));
503 col->add_attribute (renderer->property_text(), function_key_columns.cmdalt);
504 function_key_editor.append_column (*col);
506 renderer = make_action_renderer (available_action_model, function_key_columns.shiftcontrol);
507 col = manage (new TreeViewColumn (_("Shift+Control"), *renderer));
508 col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol);
509 function_key_editor.append_column (*col);
512 function_key_model = ListStore::create (function_key_columns);
513 function_key_editor.set_model (function_key_model);
517 US2400ProtocolGUI::refresh_function_key_editor ()
519 function_key_editor.set_model (Glib::RefPtr<TreeModel>());
520 function_key_model->clear ();
522 /* now fill with data */
525 DeviceProfile dp (_cp.device_profile());
528 for (int n = 0; n < US2400::Button::FinalGlobalButton; ++n) {
530 US2400::Button::ID bid = (US2400::Button::ID) n;
532 row = *(function_key_model->append());
533 if (di.global_buttons().find (bid) == di.global_buttons().end()) {
534 row[function_key_columns.name] = US2400::Button::id_to_name (bid);
536 row[function_key_columns.name] = di.get_global_button_name (bid) + "*";
538 row[function_key_columns.id] = bid;
540 Glib::RefPtr<Gtk::Action> act;
542 const string defstring = "\u2022";
544 /* We only allow plain bindings for Fn keys. All others are
545 * reserved for hard-coded actions.
548 if (bid >= US2400::Button::F1 && bid <= US2400::Button::F6) {
550 action = dp.get_button_action (bid, 0);
551 if (action.empty()) {
552 row[function_key_columns.plain] = defstring;
554 if (action.find ('/') == string::npos) {
555 /* Probably a key alias */
556 row[function_key_columns.plain] = action;
559 act = ActionManager::get_action (action.c_str());
561 row[function_key_columns.plain] = act->get_label();
563 row[function_key_columns.plain] = defstring;
569 //~ /* We only allow plain bindings for Fn keys. All others are
570 //~ * reserved for hard-coded actions.
573 //~ if (bid >= US2400::Button::F1 && bid <= US2400::Button::F8) {
575 //~ action = dp.get_button_action (bid, US2400Protocol::MODIFIER_SHIFT);
576 //~ if (action.empty()) {
577 //~ row[function_key_columns.shift] = defstring;
579 //~ if (action.find ('/') == string::npos) {
580 //~ /* Probably a key alias */
581 //~ row[function_key_columns.shift] = action;
583 //~ act = ActionManager::get_action (action.c_str());
585 //~ row[function_key_columns.shift] = act->get_label();
587 //~ row[function_key_columns.shift] = defstring;
593 //~ action = dp.get_button_action (bid, US2400Protocol::MODIFIER_CONTROL);
594 //~ if (action.empty()) {
595 //~ row[function_key_columns.control] = defstring;
597 //~ if (action.find ('/') == string::npos) {
598 //~ /* Probably a key alias */
599 //~ row[function_key_columns.control] = action;
601 //~ act = ActionManager::get_action (action.c_str());
603 //~ row[function_key_columns.control] = act->get_label();
605 //~ row[function_key_columns.control] = defstring;
610 //~ action = dp.get_button_action (bid, US2400Protocol::MODIFIER_OPTION);
611 //~ if (action.empty()) {
612 //~ row[function_key_columns.option] = defstring;
614 //~ if (action.find ('/') == string::npos) {
615 //~ /* Probably a key alias */
616 //~ row[function_key_columns.option] = action;
618 //~ act = ActionManager::get_action (action.c_str());
620 //~ row[function_key_columns.option] = act->get_label();
622 //~ row[function_key_columns.option] = defstring;
627 //~ action = dp.get_button_action (bid, US2400Protocol::MODIFIER_CMDALT);
628 //~ if (action.empty()) {
629 //~ row[function_key_columns.cmdalt] = defstring;
631 //~ if (action.find ('/') == string::npos) {
632 //~ /* Probably a key alias */
633 //~ row[function_key_columns.cmdalt] = action;
635 //~ act = ActionManager::get_action (action.c_str());
637 //~ row[function_key_columns.cmdalt] = act->get_label();
639 //~ row[function_key_columns.cmdalt] = defstring;
644 //~ action = dp.get_button_action (bid, (US2400Protocol::MODIFIER_SHIFT|US2400Protocol::MODIFIER_CONTROL));
645 //~ if (action.empty()) {
646 //~ row[function_key_columns.shiftcontrol] = defstring;
648 //~ act = ActionManager::get_action (action.c_str());
650 //~ row[function_key_columns.shiftcontrol] = act->get_label();
652 //~ row[function_key_columns.shiftcontrol] = defstring;
657 function_key_editor.set_model (function_key_model);
661 US2400ProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib::ustring &text, TreeModelColumnBase col)
663 // Remove Binding is not in the action map but still valid
665 if ( text == "Remove Binding") {
668 Gtk::TreePath path(sPath);
669 Gtk::TreeModel::iterator row = function_key_model->get_iter(path);
673 std::map<std::string,std::string>::iterator i = action_map.find (text);
675 if (i == action_map.end()) {
680 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (i->second.c_str());
683 /* update visible text, using string supplied by
684 available action model so that it matches and is found
688 Glib::ustring dot = "\u2022";
689 (*row).set_value (col.index(), dot);
691 (*row).set_value (col.index(), text);
694 /* update the current DeviceProfile, using the full
700 switch (col.index()) {
702 modifier = US2400Protocol::MODIFIER_SHIFT;
705 modifier = US2400Protocol::MODIFIER_CONTROL;
708 modifier = US2400Protocol::MODIFIER_OPTION;
711 modifier = US2400Protocol::MODIFIER_CMDALT;
714 modifier = (US2400Protocol::MODIFIER_SHIFT|US2400Protocol::MODIFIER_CONTROL);
721 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, "");
723 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, i->second);
726 _ignore_profile_changed = true;
727 _profile_combo.set_active_text ( _cp.device_profile().name() );
728 _ignore_profile_changed = false;
731 std::cerr << "no such action\n";
737 US2400ProtocolGUI::device_changed ()
739 if (_device_dependent_widget) {
740 table.remove (*_device_dependent_widget);
741 _device_dependent_widget = 0;
744 _device_dependent_widget = device_dependent_widget ();
745 _device_dependent_widget->show_all ();
747 table.attach (*_device_dependent_widget, 0, 12, device_dependent_row, device_dependent_row+1, AttachOptions(0), AttachOptions(0), 0, 0);
751 US2400ProtocolGUI::profile_combo_changed ()
753 if (!_ignore_profile_changed) {
754 string profile = _profile_combo.get_active_text();
756 _cp.set_profile (profile);
758 refresh_function_key_editor ();
762 Glib::RefPtr<Gtk::ListStore>
763 US2400ProtocolGUI::build_midi_port_list (vector<string> const & ports, bool for_input)
765 Glib::RefPtr<Gtk::ListStore> store = ListStore::create (midi_port_columns);
768 row = *store->append ();
769 row[midi_port_columns.full_name] = string();
770 row[midi_port_columns.short_name] = _("Disconnected");
772 for (vector<string>::const_iterator p = ports.begin(); p != ports.end(); ++p) {
773 row = *store->append ();
774 row[midi_port_columns.full_name] = *p;
775 std::string pn = ARDOUR::AudioEngine::instance()->get_pretty_name_by_name (*p);
777 pn = (*p).substr ((*p).find (':') + 1);
779 row[midi_port_columns.short_name] = pn;
786 US2400ProtocolGUI::active_port_changed (Gtk::ComboBox* combo, boost::weak_ptr<Surface> ws, bool for_input)
788 if (ignore_active_change) {
792 boost::shared_ptr<Surface> surface = ws.lock();
798 TreeModel::iterator active = combo->get_active ();
799 string new_port = (*active)[midi_port_columns.full_name];
801 if (new_port.empty()) {
803 surface->port().input().disconnect_all ();
805 surface->port().output().disconnect_all ();
812 if (!surface->port().input().connected_to (new_port)) {
813 surface->port().input().disconnect_all ();
814 surface->port().input().connect (new_port);
817 if (!surface->port().output().connected_to (new_port)) {
818 surface->port().output().disconnect_all ();
819 surface->port().output().connect (new_port);