2 Copyright (C) 2010 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.
19 #include <gtkmm/comboboxtext.h>
20 #include <gtkmm/box.h>
21 #include <gtkmm/spinbutton.h>
22 #include <gtkmm/table.h>
23 #include <gtkmm/treeview.h>
24 #include <gtkmm/liststore.h>
25 #include <gtkmm/treestore.h>
26 #include <gtkmm/notebook.h>
27 #include <gtkmm/cellrenderercombo.h>
28 #include <gtkmm/scale.h>
29 #include <gtkmm/alignment.h>
31 #include "pbd/error.h"
32 #include "pbd/unwind.h"
33 #include "pbd/strsplit.h"
34 #include "pbd/stacktrace.h"
36 #include "gtkmm2ext/actions.h"
37 #include "gtkmm2ext/bindings.h"
38 #include "gtkmm2ext/gui_thread.h"
39 #include "gtkmm2ext/utils.h"
41 #include "ardour/audioengine.h"
42 #include "ardour/port.h"
43 #include "ardour/rc_configuration.h"
45 #include "mackie_control_protocol.h"
46 #include "device_info.h"
49 #include "surface_port.h"
55 using namespace ArdourSurface;
56 using namespace Mackie;
59 MackieControlProtocol::get_gui () const
62 const_cast<MackieControlProtocol*>(this)->build_gui ();
64 static_cast<Gtk::Notebook*>(_gui)->show_all();
69 MackieControlProtocol::tear_down_gui ()
72 Gtk::Widget *w = static_cast<Gtk::Widget*>(_gui)->get_parent();
78 delete (MackieControlProtocolGUI*) _gui;
83 MackieControlProtocol::build_gui ()
85 _gui = (void *) new MackieControlProtocolGUI (*this);
88 MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
91 , touch_sensitivity_adjustment (0, 0, 9, 1, 4)
92 , touch_sensitivity_scale (touch_sensitivity_adjustment)
93 , recalibrate_fader_button (_("Recalibrate Faders"))
94 , ipmidi_base_port_adjustment (_cp.ipmidi_base(), 0, 32767, 1, 1000)
95 , discover_button (_("Discover Mackie Devices"))
96 , _device_dependent_widget (0)
97 , ignore_active_change (false)
100 Gtk::Alignment* align;
103 set_border_width (12);
105 table.set_row_spacings (4);
106 table.set_col_spacings (6);
107 table.set_border_width (12);
108 table.set_homogeneous (false);
110 l = manage (new Gtk::Label (_("Device Type:")));
111 l->set_alignment (1.0, 0.5);
112 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
113 table.attach (_surface_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
116 vector<string> surfaces;
118 for (std::map<std::string,DeviceInfo>::iterator i = DeviceInfo::device_info.begin(); i != DeviceInfo::device_info.end(); ++i) {
119 surfaces.push_back (i->first);
121 Gtkmm2ext::set_popdown_strings (_surface_combo, surfaces);
122 _surface_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::surface_combo_changed));
124 _cp.DeviceChanged.connect (device_change_connection, invalidator (*this), boost::bind (&MackieControlProtocolGUI::device_changed, this), gui_context());
125 _cp.ConnectionChange.connect (connection_change_connection, invalidator (*this), boost::bind (&MackieControlProtocolGUI::connection_handler, this), gui_context());
127 ipmidi_base_port_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::ipmidi_spinner_changed));
129 /* device-dependent part */
131 device_dependent_row = row;
133 if (_device_dependent_widget) {
134 table.remove (*_device_dependent_widget);
135 _device_dependent_widget = 0;
138 _device_dependent_widget = device_dependent_widget ();
139 table.attach (*_device_dependent_widget, 0, 12, row, row+1, AttachOptions(0), AttachOptions(0), 0, 0);
142 /* back to the boilerplate */
144 RadioButtonGroup rb_group = absolute_touch_mode_button.get_group();
145 touch_move_mode_button.set_group (rb_group);
147 recalibrate_fader_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::recalibrate_faders));
148 backlight_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::toggle_backlight));
150 touch_sensitivity_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::touch_sensitive_change));
151 touch_sensitivity_scale.set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
153 l = manage (new Gtk::Label (_("Button click")));
154 l->set_alignment (1.0, 0.5);
155 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
156 align = manage (new Alignment);
157 align->set (0.0, 0.5);
158 align->add (relay_click_button);
159 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
162 l = manage (new Gtk::Label (_("Backlight")));
163 l->set_alignment (1.0, 0.5);
164 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
165 align = manage (new Alignment);
166 align->set (0.0, 0.5);
167 align->add (backlight_button);
168 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
171 l = manage (new Gtk::Label (_("Send Fader Position Only When Touched")));
172 l->set_alignment (1.0, 0.5);
173 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
174 align = manage (new Alignment);
175 align->set (0.0, 0.5);
176 align->add (absolute_touch_mode_button);
177 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
180 l = manage (new Gtk::Label (_("Send Fader Position When Moved")));
181 l->set_alignment (1.0, 0.5);
182 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
183 align = manage (new Alignment);
184 align->set (0.0, 0.5);
185 align->add (touch_move_mode_button);
186 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
189 l = manage (new Gtk::Label (_("Fader Touch Sense Sensitivity")));
190 l->set_alignment (1.0, 0.5);
191 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
192 touch_sensitivity_scale.property_digits() = 0;
193 touch_sensitivity_scale.property_draw_value() = false;
194 table.attach (touch_sensitivity_scale, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
196 table.attach (recalibrate_fader_button, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
200 table.attach (discover_button, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
201 discover_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::discover_clicked));
204 vector<string> profiles;
206 for (std::map<std::string,DeviceProfile>::iterator i = DeviceProfile::device_profiles.begin(); i != DeviceProfile::device_profiles.end(); ++i) {
207 cerr << "add discovered profile " << i->first << endl;
208 profiles.push_back (i->first);
210 Gtkmm2ext::set_popdown_strings (_profile_combo, profiles);
211 cerr << "set active profile from " << p.device_profile().name() << endl;
212 _profile_combo.set_active_text (p.device_profile().name());
213 _profile_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::profile_combo_changed));
215 append_page (table, _("Device Setup"));
218 /* function key editor */
220 VBox* fkey_packer = manage (new VBox);
221 HBox* profile_packer = manage (new HBox);
222 HBox* observation_packer = manage (new HBox);
224 l = manage (new Gtk::Label (_("Profile/Settings:")));
225 profile_packer->pack_start (*l, false, false);
226 profile_packer->pack_start (_profile_combo, true, true);
227 profile_packer->set_spacing (12);
228 profile_packer->set_border_width (12);
230 l = manage (new Gtk::Label (_("* Button available at the original Mackie MCU PRO or current device if enabled (NOT implemented yet). Device specific name presented.")));
231 observation_packer->pack_start (*l, false, false);
233 fkey_packer->pack_start (*profile_packer, false, false);
234 fkey_packer->pack_start (function_key_scroller, true, true);
235 fkey_packer->pack_start (*observation_packer, false, false);
236 fkey_packer->set_spacing (12);
237 function_key_scroller.property_shadow_type() = Gtk::SHADOW_NONE;
238 function_key_scroller.add (function_key_editor);
239 append_page (*fkey_packer, _("Function Keys"));
241 build_available_action_menu ();
242 build_function_key_editor ();
243 refresh_function_key_editor ();
244 fkey_packer->show_all();
248 MackieControlProtocolGUI::connection_handler ()
250 /* ignore all changes to combobox active strings here, because we're
251 updating them to match a new ("external") reality - we were called
252 because port connections have changed.
255 PBD::Unwinder<bool> ici (ignore_active_change, true);
257 vector<Gtk::ComboBox*>::iterator ic;
258 vector<Gtk::ComboBox*>::iterator oc;
260 vector<string> midi_inputs;
261 vector<string> midi_outputs;
263 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsTerminal), midi_inputs);
264 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsTerminal), midi_outputs);
266 for (ic = input_combos.begin(), oc = output_combos.begin(); ic != input_combos.end() && oc != output_combos.end(); ++ic, ++oc) {
268 boost::shared_ptr<Surface> surface = _cp.get_surface_by_raw_pointer ((*ic)->get_data ("surface"));
271 update_port_combos (midi_inputs, midi_outputs, *ic, *oc, surface);
277 MackieControlProtocolGUI::update_port_combos (vector<string> const& midi_inputs, vector<string> const& midi_outputs,
278 Gtk::ComboBox* input_combo,
279 Gtk::ComboBox* output_combo,
280 boost::shared_ptr<Surface> surface)
282 Glib::RefPtr<Gtk::ListStore> input = build_midi_port_list (midi_inputs, true);
283 Glib::RefPtr<Gtk::ListStore> output = build_midi_port_list (midi_outputs, false);
284 bool input_found = false;
285 bool output_found = false;
288 input_combo->set_model (input);
289 output_combo->set_model (output);
291 Gtk::TreeModel::Children children = input->children();
292 Gtk::TreeModel::Children::iterator i;
293 i = children.begin();
294 ++i; /* skip "Disconnected" */
297 for (n = 1; i != children.end(); ++i, ++n) {
298 string port_name = (*i)[midi_port_columns.full_name];
299 if (surface->port().input().connected_to (port_name)) {
300 input_combo->set_active (n);
307 input_combo->set_active (0); /* disconnected */
310 children = output->children();
311 i = children.begin();
312 ++i; /* skip "Disconnected" */
314 for (n = 1; i != children.end(); ++i, ++n) {
315 string port_name = (*i)[midi_port_columns.full_name];
316 if (surface->port().output().connected_to (port_name)) {
317 output_combo->set_active (n);
324 output_combo->set_active (0); /* disconnected */
329 MackieControlProtocolGUI::device_dependent_widget ()
331 Gtk::Table* dd_table;
335 uint32_t n_surfaces = 1 + _cp.device_info().extenders();
337 if (!_cp.device_info().uses_ipmidi()) {
338 dd_table = Gtk::manage (new Gtk::Table (n_surfaces, 2));
340 dd_table = Gtk::manage (new Gtk::Table (1, 2));
343 dd_table = Gtk::manage (new Gtk::Table (2, n_surfaces));
344 dd_table->set_row_spacings (4);
345 dd_table->set_col_spacings (6);
346 dd_table->set_border_width (12);
348 _surface_combo.set_active_text (_cp.device_info().name());
350 vector<string> midi_inputs;
351 vector<string> midi_outputs;
353 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsPhysical), midi_inputs);
354 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsPhysical), midi_outputs);
356 input_combos.clear ();
357 output_combos.clear ();
359 if (!_cp.device_info().uses_ipmidi()) {
361 for (uint32_t n = 0; n < n_surfaces; ++n) {
363 boost::shared_ptr<Surface> surface = _cp.nth_surface (n);
366 PBD::fatal << string_compose (_("programming error: %1\n"), string_compose ("n=%1 surface not found!", n)) << endmsg;
370 Gtk::ComboBox* input_combo = manage (new Gtk::ComboBox);
371 Gtk::ComboBox* output_combo = manage (new Gtk::ComboBox);
373 update_port_combos (midi_inputs, midi_outputs, input_combo, output_combo, surface);
375 input_combo->pack_start (midi_port_columns.short_name);
376 input_combo->set_data ("surface", surface.get());
377 input_combos.push_back (input_combo);
378 output_combo->pack_start (midi_port_columns.short_name);
379 output_combo->set_data ("surface", surface.get());
380 output_combos.push_back (output_combo);
382 boost::weak_ptr<Surface> ws (surface);
383 input_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &MackieControlProtocolGUI::active_port_changed), input_combo, ws, true));
384 output_combo->signal_changed().connect (sigc::bind (sigc::mem_fun (*this, &MackieControlProtocolGUI::active_port_changed), output_combo, ws, false));
387 string receive_string;
389 if (n_surfaces > 1) {
391 send_string = _("Main surface sends via:");
392 receive_string = _("Main surface receives via:");
394 send_string = string_compose (_("Extender %1 sends via:"), n);
395 receive_string = string_compose (_("Extender %1 receives via:"), n);
398 send_string = _("Surface sends via:");
399 receive_string = _("Surface receives via:");
402 l = manage (new Gtk::Label (send_string));
403 l->set_alignment (1.0, 0.5);
404 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
405 dd_table->attach (*input_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
408 l = manage (new Gtk::Label (receive_string));
409 l->set_alignment (1.0, 0.5);
410 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
411 dd_table->attach (*output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
417 l = manage (new Gtk::Label (_("ipMIDI Port (lowest)")));
418 l->set_alignment (1.0, 0.5);
420 Gtk::SpinButton* ipmidi_base_port_spinner = manage (new Gtk::SpinButton (ipmidi_base_port_adjustment));
421 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
422 dd_table->attach (*ipmidi_base_port_spinner, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
430 MackieControlProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, Gtk::TreeModelColumnBase column)
432 CellRendererCombo* renderer = manage (new CellRendererCombo);
433 renderer->property_model() = model;
434 renderer->property_editable() = true;
435 renderer->property_text_column() = 0;
436 renderer->property_has_entry() = false;
437 renderer->signal_edited().connect (sigc::bind (sigc::mem_fun(*this, &MackieControlProtocolGUI::action_changed), column));
443 MackieControlProtocolGUI::build_available_action_menu ()
445 /* build a model of all available actions (needs to be tree structured
449 available_action_model = TreeStore::create (available_action_columns);
451 vector<string> paths;
452 vector<string> labels;
453 vector<string> tooltips;
455 vector<Glib::RefPtr<Gtk::Action> > actions;
457 typedef std::map<string,TreeIter> NodeMap;
461 Gtkmm2ext::ActionMap::get_all_actions (paths, labels, tooltips, keys, actions);
463 vector<string>::iterator k;
464 vector<string>::iterator p;
465 vector<string>::iterator t;
466 vector<string>::iterator l;
468 available_action_model->clear ();
470 /* Because there are button bindings built in that are not
471 in the key binding map, there needs to be a way to undo
475 TreeModel::Row parent;
476 rowp = available_action_model->append();
478 parent[available_action_columns.name] = _("Remove Binding");
482 rowp = available_action_model->append();
484 parent[available_action_columns.name] = _("Shift");
485 rowp = available_action_model->append();
487 parent[available_action_columns.name] = _("Control");
488 rowp = available_action_model->append();
490 parent[available_action_columns.name] = _("Option");
491 rowp = available_action_model->append();
493 parent[available_action_columns.name] = _("CmdAlt");
495 for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
498 vector<string> parts;
502 split (*p, parts, '/');
508 //kinda kludgy way to avoid displaying menu items as mappable
509 if ( parts[1] == _("Main_menu") )
511 if ( parts[1] == _("JACK") )
513 if ( parts[1] == _("redirectmenu") )
515 if ( parts[1] == _("Editor_menus") )
517 if ( parts[1] == _("RegionList") )
519 if ( parts[1] == _("ProcessorMenu") )
522 if ((r = nodes.find (parts[1])) == nodes.end()) {
524 /* top level is missing */
527 TreeModel::Row parent;
528 rowp = available_action_model->append();
529 nodes[parts[1]] = rowp;
531 parent[available_action_columns.name] = parts[1];
533 row = *(available_action_model->append (parent.children()));
537 row = *(available_action_model->append ((*r->second)->children()));
541 /* add this action */
544 row[available_action_columns.name] = *t;
547 row[available_action_columns.name] = *l;
551 row[available_action_columns.path] = (*p);
556 MackieControlProtocolGUI::build_function_key_editor ()
558 function_key_editor.append_column (_("Key"), function_key_columns.name);
561 CellRendererCombo* renderer;
563 renderer = make_action_renderer (available_action_model, function_key_columns.plain);
564 col = manage (new TreeViewColumn (_("Plain"), *renderer));
565 col->add_attribute (renderer->property_text(), function_key_columns.plain);
566 function_key_editor.append_column (*col);
568 renderer = make_action_renderer (available_action_model, function_key_columns.shift);
569 col = manage (new TreeViewColumn (_("Shift"), *renderer));
570 col->add_attribute (renderer->property_text(), function_key_columns.shift);
571 function_key_editor.append_column (*col);
573 renderer = make_action_renderer (available_action_model, function_key_columns.control);
574 col = manage (new TreeViewColumn (_("Control"), *renderer));
575 col->add_attribute (renderer->property_text(), function_key_columns.control);
576 function_key_editor.append_column (*col);
578 renderer = make_action_renderer (available_action_model, function_key_columns.option);
579 col = manage (new TreeViewColumn (_("Option"), *renderer));
580 col->add_attribute (renderer->property_text(), function_key_columns.option);
581 function_key_editor.append_column (*col);
583 renderer = make_action_renderer (available_action_model, function_key_columns.cmdalt);
584 col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer));
585 col->add_attribute (renderer->property_text(), function_key_columns.cmdalt);
586 function_key_editor.append_column (*col);
588 renderer = make_action_renderer (available_action_model, function_key_columns.shiftcontrol);
589 col = manage (new TreeViewColumn (_("Shift+Control"), *renderer));
590 col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol);
591 function_key_editor.append_column (*col);
593 function_key_model = ListStore::create (function_key_columns);
594 function_key_editor.set_model (function_key_model);
598 MackieControlProtocolGUI::refresh_function_key_editor ()
600 function_key_editor.set_model (Glib::RefPtr<TreeModel>());
601 function_key_model->clear ();
603 /* now fill with data */
606 DeviceProfile dp (_cp.device_profile());
609 for (int n = 0; n < Mackie::Button::FinalGlobalButton; ++n) {
611 Mackie::Button::ID bid = (Mackie::Button::ID) n;
613 row = *(function_key_model->append());
614 if (di.global_buttons().find (bid) == di.global_buttons().end()) {
615 row[function_key_columns.name] = Mackie::Button::id_to_name (bid);
617 row[function_key_columns.name] = di.get_global_button_name (bid) + "*";
619 row[function_key_columns.id] = bid;
621 Glib::RefPtr<Gtk::Action> act;
623 const string defstring = "\u2022";
625 /* We only allow plain bindings for Fn keys. All others are
626 * reserved for hard-coded actions.
629 if (bid >= Mackie::Button::F1 && bid <= Mackie::Button::F8) {
631 action = dp.get_button_action (bid, 0);
632 if (action.empty()) {
633 row[function_key_columns.plain] = defstring;
635 if (action.find ('/') == string::npos) {
636 /* Probably a key alias */
637 row[function_key_columns.plain] = action;
640 act = ActionManager::get_action (action.c_str());
642 row[function_key_columns.plain] = act->get_label();
644 row[function_key_columns.plain] = defstring;
650 /* We only allow plain bindings for Fn keys. All others are
651 * reserved for hard-coded actions.
654 if (bid >= Mackie::Button::F1 && bid <= Mackie::Button::F8) {
656 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_SHIFT);
657 if (action.empty()) {
658 row[function_key_columns.shift] = defstring;
660 if (action.find ('/') == string::npos) {
661 /* Probably a key alias */
662 row[function_key_columns.shift] = action;
664 act = ActionManager::get_action (action.c_str());
666 row[function_key_columns.shift] = act->get_label();
668 row[function_key_columns.shift] = defstring;
674 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_CONTROL);
675 if (action.empty()) {
676 row[function_key_columns.control] = defstring;
678 if (action.find ('/') == string::npos) {
679 /* Probably a key alias */
680 row[function_key_columns.control] = action;
682 act = ActionManager::get_action (action.c_str());
684 row[function_key_columns.control] = act->get_label();
686 row[function_key_columns.control] = defstring;
691 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_OPTION);
692 if (action.empty()) {
693 row[function_key_columns.option] = defstring;
695 if (action.find ('/') == string::npos) {
696 /* Probably a key alias */
697 row[function_key_columns.option] = action;
699 act = ActionManager::get_action (action.c_str());
701 row[function_key_columns.option] = act->get_label();
703 row[function_key_columns.option] = defstring;
708 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_CMDALT);
709 if (action.empty()) {
710 row[function_key_columns.cmdalt] = defstring;
712 if (action.find ('/') == string::npos) {
713 /* Probably a key alias */
714 row[function_key_columns.cmdalt] = action;
716 act = ActionManager::get_action (action.c_str());
718 row[function_key_columns.cmdalt] = act->get_label();
720 row[function_key_columns.cmdalt] = defstring;
725 action = dp.get_button_action (bid, (MackieControlProtocol::MODIFIER_SHIFT|MackieControlProtocol::MODIFIER_CONTROL));
726 if (action.empty()) {
727 row[function_key_columns.shiftcontrol] = defstring;
729 act = ActionManager::get_action (action.c_str());
731 row[function_key_columns.shiftcontrol] = act->get_label();
733 row[function_key_columns.shiftcontrol] = defstring;
738 function_key_editor.set_model (function_key_model);
742 MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib::ustring &text, TreeModelColumnBase col)
744 // Remove Binding is not in the action map but still valid
746 if ( text == "Remove Binding") {
749 Gtk::TreePath path(sPath);
750 Gtk::TreeModel::iterator row = function_key_model->get_iter(path);
754 std::map<std::string,std::string>::iterator i = action_map.find (text);
756 if (i == action_map.end()) {
761 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (i->second.c_str());
764 /* update visible text, using string supplied by
765 available action model so that it matches and is found
769 Glib::ustring dot = "\u2022";
770 (*row).set_value (col.index(), dot);
772 (*row).set_value (col.index(), text);
775 /* update the current DeviceProfile, using the full
781 switch (col.index()) {
783 modifier = MackieControlProtocol::MODIFIER_SHIFT;
786 modifier = MackieControlProtocol::MODIFIER_CONTROL;
789 modifier = MackieControlProtocol::MODIFIER_OPTION;
792 modifier = MackieControlProtocol::MODIFIER_CMDALT;
795 modifier = (MackieControlProtocol::MODIFIER_SHIFT|MackieControlProtocol::MODIFIER_CONTROL);
802 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, "");
804 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, i->second);
808 std::cerr << "no such action\n";
814 MackieControlProtocolGUI::surface_combo_changed ()
816 _cp.set_device (_surface_combo.get_active_text(), false);
820 MackieControlProtocolGUI::device_changed ()
822 if (_device_dependent_widget) {
823 table.remove (*_device_dependent_widget);
824 _device_dependent_widget = 0;
827 _device_dependent_widget = device_dependent_widget ();
828 _device_dependent_widget->show_all ();
830 table.attach (*_device_dependent_widget, 0, 12, device_dependent_row, device_dependent_row+1, AttachOptions(0), AttachOptions(0), 0, 0);
834 MackieControlProtocolGUI::profile_combo_changed ()
836 string profile = _profile_combo.get_active_text();
838 _cp.set_profile (profile);
840 refresh_function_key_editor ();
844 MackieControlProtocolGUI::ipmidi_spinner_changed ()
846 _cp.set_ipmidi_base ((int16_t) lrintf (ipmidi_base_port_adjustment.get_value()));
850 MackieControlProtocolGUI::discover_clicked ()
852 /* this should help to get things started */
857 MackieControlProtocolGUI::recalibrate_faders ()
859 _cp.recalibrate_faders ();
863 MackieControlProtocolGUI::toggle_backlight ()
865 _cp.toggle_backlight ();
869 MackieControlProtocolGUI::touch_sensitive_change ()
871 int sensitivity = (int) touch_sensitivity_adjustment.get_value ();
872 _cp.set_touch_sensitivity (sensitivity);
875 Glib::RefPtr<Gtk::ListStore>
876 MackieControlProtocolGUI::build_midi_port_list (vector<string> const & ports, bool for_input)
878 Glib::RefPtr<Gtk::ListStore> store = ListStore::create (midi_port_columns);
881 row = *store->append ();
882 row[midi_port_columns.full_name] = string();
883 row[midi_port_columns.short_name] = _("Disconnected");
885 for (vector<string>::const_iterator p = ports.begin(); p != ports.end(); ++p) {
886 row = *store->append ();
887 row[midi_port_columns.full_name] = *p;
888 std::string pn = ARDOUR::AudioEngine::instance()->get_pretty_name_by_name (*p);
890 pn = (*p).substr ((*p).find (':') + 1);
892 row[midi_port_columns.short_name] = pn;
899 MackieControlProtocolGUI::active_port_changed (Gtk::ComboBox* combo, boost::weak_ptr<Surface> ws, bool for_input)
901 if (ignore_active_change) {
905 boost::shared_ptr<Surface> surface = ws.lock();
911 TreeModel::iterator active = combo->get_active ();
912 string new_port = (*active)[midi_port_columns.full_name];
914 if (new_port.empty()) {
916 surface->port().input().disconnect_all ();
918 surface->port().output().disconnect_all ();
925 if (!surface->port().input().connected_to (new_port)) {
926 surface->port().input().disconnect_all ();
927 surface->port().input().connect (new_port);
930 if (!surface->port().output().connected_to (new_port)) {
931 surface->port().output().disconnect_all ();
932 surface->port().output().connect (new_port);