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/strsplit.h"
34 #include "gtkmm2ext/actions.h"
35 #include "gtkmm2ext/gui_thread.h"
36 #include "gtkmm2ext/utils.h"
38 #include "ardour/audioengine.h"
39 #include "ardour/port.h"
40 #include "ardour/rc_configuration.h"
42 #include "mackie_control_protocol.h"
43 #include "device_info.h"
46 #include "surface_port.h"
52 using namespace ArdourSurface;
53 using namespace Mackie;
56 MackieControlProtocol::get_gui () const
59 const_cast<MackieControlProtocol*>(this)->build_gui ();
61 static_cast<Gtk::Notebook*>(_gui)->show_all();
66 MackieControlProtocol::tear_down_gui ()
69 Gtk::Widget *w = static_cast<Gtk::Widget*>(_gui)->get_parent();
75 delete (MackieControlProtocolGUI*) _gui;
80 MackieControlProtocol::build_gui ()
82 _gui = (void *) new MackieControlProtocolGUI (*this);
85 MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
88 , touch_sensitivity_adjustment (0, 0, 9, 1, 4)
89 , touch_sensitivity_scale (touch_sensitivity_adjustment)
90 , recalibrate_fader_button (_("Recalibrate Faders"))
91 , ipmidi_base_port_adjustment (_cp.ipmidi_base(), 0, 32767, 1, 1000)
92 , discover_button (_("Discover Mackie Devices"))
93 , _device_dependent_widget (0)
96 Gtk::Alignment* align;
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 l = manage (new Gtk::Label (_("Device Type:")));
107 l->set_alignment (1.0, 0.5);
108 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
109 table.attach (_surface_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
112 vector<string> surfaces;
114 for (std::map<std::string,DeviceInfo>::iterator i = DeviceInfo::device_info.begin(); i != DeviceInfo::device_info.end(); ++i) {
115 surfaces.push_back (i->first);
117 Gtkmm2ext::set_popdown_strings (_surface_combo, surfaces);
118 _surface_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::surface_combo_changed));
120 _cp.DeviceChanged.connect (device_change_connection, invalidator (*this), boost::bind (&MackieControlProtocolGUI::device_changed, this), gui_context());
121 _cp.ConnectionChange.connect (connection_change_connection, invalidator (*this), boost::bind (&MackieControlProtocolGUI::connection_handler, this), gui_context());
123 ipmidi_base_port_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::ipmidi_spinner_changed));
125 /* device-dependent part */
127 device_dependent_row = row;
129 if (_device_dependent_widget) {
130 table.remove (*_device_dependent_widget);
131 _device_dependent_widget = 0;
134 _device_dependent_widget = device_dependent_widget ();
135 table.attach (*_device_dependent_widget, 0, 12, row, row+1, AttachOptions(0), AttachOptions(0), 0, 0);
138 /* back to the boilerplate */
140 RadioButtonGroup rb_group = absolute_touch_mode_button.get_group();
141 touch_move_mode_button.set_group (rb_group);
143 recalibrate_fader_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::recalibrate_faders));
144 backlight_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::toggle_backlight));
146 touch_sensitivity_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::touch_sensitive_change));
147 touch_sensitivity_scale.set_update_policy (Gtk::UPDATE_DISCONTINUOUS);
149 l = manage (new Gtk::Label (_("Button click")));
150 l->set_alignment (1.0, 0.5);
151 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
152 align = manage (new Alignment);
153 align->set (0.0, 0.5);
154 align->add (relay_click_button);
155 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
158 l = manage (new Gtk::Label (_("Backlight")));
159 l->set_alignment (1.0, 0.5);
160 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
161 align = manage (new Alignment);
162 align->set (0.0, 0.5);
163 align->add (backlight_button);
164 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
167 l = manage (new Gtk::Label (_("Send Fader Position Only When Touched")));
168 l->set_alignment (1.0, 0.5);
169 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
170 align = manage (new Alignment);
171 align->set (0.0, 0.5);
172 align->add (absolute_touch_mode_button);
173 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
176 l = manage (new Gtk::Label (_("Send Fader Position When Moved")));
177 l->set_alignment (1.0, 0.5);
178 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
179 align = manage (new Alignment);
180 align->set (0.0, 0.5);
181 align->add (touch_move_mode_button);
182 table.attach (*align, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
185 l = manage (new Gtk::Label (_("Fader Touch Sense Sensitivity")));
186 l->set_alignment (1.0, 0.5);
187 table.attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
188 touch_sensitivity_scale.property_digits() = 0;
189 touch_sensitivity_scale.property_draw_value() = false;
190 table.attach (touch_sensitivity_scale, 1, 2, 5, 6, AttachOptions(FILL|EXPAND), AttachOptions (0));
192 table.attach (recalibrate_fader_button, row, row+1, 6, 7, AttachOptions(FILL|EXPAND), AttachOptions (0));
196 table.attach (discover_button, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
197 discover_button.signal_clicked().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::discover_clicked));
200 vector<string> profiles;
202 profiles.push_back ("default");
204 for (std::map<std::string,DeviceProfile>::iterator i = DeviceProfile::device_profiles.begin(); i != DeviceProfile::device_profiles.end(); ++i) {
205 profiles.push_back (i->first);
207 Gtkmm2ext::set_popdown_strings (_profile_combo, profiles);
208 _profile_combo.set_active_text (p.device_profile().name());
209 _profile_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::profile_combo_changed));
211 append_page (table, _("Device Setup"));
214 /* function key editor */
216 VBox* fkey_packer = manage (new VBox);
217 HBox* profile_packer = manage (new HBox);
218 HBox* observation_packer = manage (new HBox);
220 l = manage (new Gtk::Label (_("Profile/Settings:")));
221 profile_packer->pack_start (*l, false, false);
222 profile_packer->pack_start (_profile_combo, true, true);
223 profile_packer->set_spacing (12);
224 profile_packer->set_border_width (12);
226 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.")));
227 observation_packer->pack_start (*l, false, false);
229 fkey_packer->pack_start (*profile_packer, false, false);
230 fkey_packer->pack_start (function_key_scroller, true, true);
231 fkey_packer->pack_start (*observation_packer, false, false);
232 fkey_packer->set_spacing (12);
233 function_key_scroller.property_shadow_type() = Gtk::SHADOW_NONE;
234 function_key_scroller.add (function_key_editor);
235 append_page (*fkey_packer, _("Function Keys"));
237 build_available_action_menu ();
238 build_function_key_editor ();
239 refresh_function_key_editor ();
240 fkey_packer->show_all();
244 MackieControlProtocolGUI::connection_handler ()
246 vector<Gtk::ComboBoxText*>::iterator ic;
247 vector<Gtk::ComboBoxText*>::iterator oc;
249 vector<string> midi_inputs;
250 vector<string> midi_outputs;
252 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsPhysical), midi_inputs);
253 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsPhysical), midi_outputs);
256 for (ic = input_combos.begin(), oc = output_combos.begin(); ic != input_combos.end() && oc != output_combos.end(); ++ic, ++oc) {
258 boost::shared_ptr<Surface> surface = _cp.get_surface_by_raw_pointer ((*ic)->get_data ("surface"));
261 update_port_combos (midi_inputs, midi_outputs, *ic, *oc, surface);
267 MackieControlProtocolGUI::update_port_combos (vector<string> const& midi_inputs, vector<string> const& midi_outputs,
268 Gtk::ComboBoxText* input_combo,
269 Gtk::ComboBoxText* output_combo,
270 boost::shared_ptr<Surface> surface)
272 vector<string> short_midi_inputs;
273 vector<string> short_midi_outputs;
275 /* Prepend "Disconnected" */
277 short_midi_inputs.push_back (_("Disconnected"));
278 short_midi_outputs.push_back (_("Disconnected"));
280 /* generate short versions of all the port names */
282 for (vector<string>::const_iterator s = midi_inputs.begin(); s != midi_inputs.end(); ++s) {
283 short_midi_inputs.push_back ((*s).substr ((*s).find (':') + 1));
285 for (vector<string>::const_iterator s = midi_outputs.begin(); s != midi_outputs.end(); ++s) {
286 short_midi_outputs.push_back ((*s).substr ((*s).find (':') + 1));
289 bool input_found = false;
290 bool output_found = true;
292 Gtkmm2ext::set_popdown_strings (*input_combo, short_midi_inputs);
294 vector<string>::iterator shrt = short_midi_inputs.begin();
295 shrt++; /* skip "Disconnected" */
297 for (vector<string>::const_iterator s = midi_inputs.begin(); s != midi_inputs.end(); ++s, ++shrt) {
298 if (surface->port().input().connected_to (*s)) {
299 input_combo->set_active_text (*shrt);
306 input_combo->set_active_text (_("Disconnected"));
309 Gtkmm2ext::set_popdown_strings (*output_combo, short_midi_outputs);
311 shrt = short_midi_outputs.begin();
312 shrt++; /* skip "Disconnected" */
314 for (vector<string>::const_iterator s = midi_outputs.begin(); s != midi_outputs.end(); ++s, ++shrt) {
315 if (surface->port().output().connected_to (*s)) {
316 output_combo->set_active_text (*shrt);
323 output_combo->set_active_text (_("Disconnected"));
328 MackieControlProtocolGUI::device_dependent_widget ()
330 Gtk::Table* dd_table;
334 uint32_t n_surfaces = 1 + _cp.device_info().extenders();
336 if (!_cp.device_info().uses_ipmidi()) {
337 dd_table = Gtk::manage (new Gtk::Table (n_surfaces, 2));
339 dd_table = Gtk::manage (new Gtk::Table (1, 2));
342 dd_table = Gtk::manage (new Gtk::Table (2, n_surfaces));
343 dd_table->set_row_spacings (4);
344 dd_table->set_col_spacings (6);
345 dd_table->set_border_width (12);
347 _surface_combo.set_active_text (_cp.device_info().name());
349 vector<string> midi_inputs;
350 vector<string> midi_outputs;
352 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsOutput|ARDOUR::IsPhysical), midi_inputs);
353 ARDOUR::AudioEngine::instance()->get_ports ("", ARDOUR::DataType::MIDI, ARDOUR::PortFlags (ARDOUR::IsInput|ARDOUR::IsPhysical), midi_outputs);
355 input_combos.clear ();
356 output_combos.clear ();
358 if (!_cp.device_info().uses_ipmidi()) {
360 for (uint32_t n = 0; n < n_surfaces; ++n) {
362 boost::shared_ptr<Surface> surface = _cp.nth_surface (n);
365 PBD::fatal << string_compose (_("programming error: %1\n"), string_compose ("n=%1 surface not found!", n)) << endmsg;
369 Gtk::ComboBoxText* input_combo = manage (new Gtk::ComboBoxText);
370 Gtk::ComboBoxText* output_combo = manage (new Gtk::ComboBoxText);
372 input_combo->set_data ("surface", surface.get());
373 output_combo->set_data ("surface", surface.get());
375 input_combos.push_back (input_combo);
376 output_combos.push_back (output_combo);
378 update_port_combos (midi_inputs, midi_outputs, input_combo, output_combo, surface);
381 string receive_string;
383 if (n_surfaces > 1) {
385 send_string = _("Main surface sends via:");
386 receive_string = _("Main surface receives via:");
388 send_string = string_compose (_("Extender %1 sends via:"), n);
389 receive_string = string_compose (_("Extender %1 receives via:"), n);
392 send_string = _("Surface sends via:");
393 receive_string = _("Surface receives via:");
396 l = manage (new Gtk::Label (send_string));
397 l->set_alignment (1.0, 0.5);
398 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0));
399 dd_table->attach (*input_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
402 l = manage (new Gtk::Label (receive_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 (*output_combo, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions(0), 0, 0);
411 l = manage (new Gtk::Label (_("ipMIDI Port (lowest)")));
412 l->set_alignment (1.0, 0.5);
414 Gtk::SpinButton* ipmidi_base_port_spinner = manage (new Gtk::SpinButton (ipmidi_base_port_adjustment));
415 dd_table->attach (*l, 0, 1, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
416 dd_table->attach (*ipmidi_base_port_spinner, 1, 2, row, row+1, AttachOptions(FILL|EXPAND), AttachOptions (0));
424 MackieControlProtocolGUI::make_action_renderer (Glib::RefPtr<TreeStore> model, Gtk::TreeModelColumnBase column)
426 CellRendererCombo* renderer = manage (new CellRendererCombo);
427 renderer->property_model() = model;
428 renderer->property_editable() = true;
429 renderer->property_text_column() = 0;
430 renderer->property_has_entry() = false;
431 renderer->signal_edited().connect (sigc::bind (sigc::mem_fun(*this, &MackieControlProtocolGUI::action_changed), column));
437 MackieControlProtocolGUI::build_available_action_menu ()
439 /* build a model of all available actions (needs to be tree structured
443 available_action_model = TreeStore::create (available_action_columns);
445 vector<string> paths;
446 vector<string> labels;
447 vector<string> tooltips;
449 vector<AccelKey> bindings;
450 typedef std::map<string,TreeIter> NodeMap;
454 ActionManager::get_all_actions (labels, paths, tooltips, keys, bindings);
456 vector<string>::iterator k;
457 vector<string>::iterator p;
458 vector<string>::iterator t;
459 vector<string>::iterator l;
461 available_action_model->clear ();
463 /* Because there are button bindings built in that are not
464 in the key binding map, there needs to be a way to undo
467 TreeModel::Row parent;
468 rowp = available_action_model->append();
470 parent[available_action_columns.name] = _("Remove Binding");
474 rowp = available_action_model->append();
476 parent[available_action_columns.name] = _("Shift");
477 rowp = available_action_model->append();
479 parent[available_action_columns.name] = _("Control");
480 rowp = available_action_model->append();
482 parent[available_action_columns.name] = _("Option");
483 rowp = available_action_model->append();
485 parent[available_action_columns.name] = _("CmdAlt");
488 for (l = labels.begin(), k = keys.begin(), p = paths.begin(), t = tooltips.begin(); l != labels.end(); ++k, ++p, ++t, ++l) {
491 vector<string> parts;
495 split (*p, parts, '/');
501 //kinda kludgy way to avoid displaying menu items as mappable
502 if ( parts[1] == _("Main_menu") )
504 if ( parts[1] == _("JACK") )
506 if ( parts[1] == _("redirectmenu") )
508 if ( parts[1] == _("Editor_menus") )
510 if ( parts[1] == _("RegionList") )
512 if ( parts[1] == _("ProcessorMenu") )
515 if ((r = nodes.find (parts[1])) == nodes.end()) {
517 /* top level is missing */
520 TreeModel::Row parent;
521 rowp = available_action_model->append();
522 nodes[parts[1]] = rowp;
524 parent[available_action_columns.name] = parts[1];
526 row = *(available_action_model->append (parent.children()));
530 row = *(available_action_model->append ((*r->second)->children()));
534 /* add this action */
537 row[available_action_columns.name] = *t;
540 row[available_action_columns.name] = *l;
544 row[available_action_columns.path] = (*p);
549 MackieControlProtocolGUI::build_function_key_editor ()
551 function_key_editor.append_column (_("Key"), function_key_columns.name);
554 CellRendererCombo* renderer;
556 renderer = make_action_renderer (available_action_model, function_key_columns.plain);
557 col = manage (new TreeViewColumn (_("Plain"), *renderer));
558 col->add_attribute (renderer->property_text(), function_key_columns.plain);
559 function_key_editor.append_column (*col);
561 renderer = make_action_renderer (available_action_model, function_key_columns.shift);
562 col = manage (new TreeViewColumn (_("Shift"), *renderer));
563 col->add_attribute (renderer->property_text(), function_key_columns.shift);
564 function_key_editor.append_column (*col);
566 renderer = make_action_renderer (available_action_model, function_key_columns.control);
567 col = manage (new TreeViewColumn (_("Control"), *renderer));
568 col->add_attribute (renderer->property_text(), function_key_columns.control);
569 function_key_editor.append_column (*col);
571 renderer = make_action_renderer (available_action_model, function_key_columns.option);
572 col = manage (new TreeViewColumn (_("Option"), *renderer));
573 col->add_attribute (renderer->property_text(), function_key_columns.option);
574 function_key_editor.append_column (*col);
576 renderer = make_action_renderer (available_action_model, function_key_columns.cmdalt);
577 col = manage (new TreeViewColumn (_("Cmd/Alt"), *renderer));
578 col->add_attribute (renderer->property_text(), function_key_columns.cmdalt);
579 function_key_editor.append_column (*col);
581 renderer = make_action_renderer (available_action_model, function_key_columns.shiftcontrol);
582 col = manage (new TreeViewColumn (_("Shift+Control"), *renderer));
583 col->add_attribute (renderer->property_text(), function_key_columns.shiftcontrol);
584 function_key_editor.append_column (*col);
586 function_key_model = ListStore::create (function_key_columns);
587 function_key_editor.set_model (function_key_model);
591 MackieControlProtocolGUI::refresh_function_key_editor ()
593 function_key_editor.set_model (Glib::RefPtr<TreeModel>());
594 function_key_model->clear ();
596 /* now fill with data */
599 DeviceProfile dp (_cp.device_profile());
602 for (int n = 0; n < Mackie::Button::FinalGlobalButton; ++n) {
604 Mackie::Button::ID bid = (Mackie::Button::ID) n;
606 row = *(function_key_model->append());
607 if (di.global_buttons().find (bid) == di.global_buttons().end()) {
608 row[function_key_columns.name] = Mackie::Button::id_to_name (bid);
610 row[function_key_columns.name] = di.get_global_button_name (bid) + "*";
612 row[function_key_columns.id] = bid;
614 Glib::RefPtr<Gtk::Action> act;
616 const string defstring = "\u2022";
618 action = dp.get_button_action (bid, 0);
619 if (action.empty()) {
620 row[function_key_columns.plain] = defstring;
622 if (action.find ('/') == string::npos) {
623 /* Probably a key alias */
624 row[function_key_columns.plain] = action;
627 act = ActionManager::get_action (action.c_str());
629 row[function_key_columns.plain] = act->get_label();
631 row[function_key_columns.plain] = defstring;
636 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_CONTROL);
637 if (action.empty()) {
638 row[function_key_columns.control] = defstring;
640 if (action.find ('/') == string::npos) {
641 /* Probably a key alias */
642 row[function_key_columns.control] = action;
644 act = ActionManager::get_action (action.c_str());
646 row[function_key_columns.control] = act->get_label();
648 row[function_key_columns.control] = defstring;
653 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_SHIFT);
654 if (action.empty()) {
655 row[function_key_columns.shift] = defstring;
657 if (action.find ('/') == string::npos) {
658 /* Probably a key alias */
659 row[function_key_columns.shift] = action;
661 act = ActionManager::get_action (action.c_str());
663 row[function_key_columns.shift] = act->get_label();
665 row[function_key_columns.shift] = defstring;
670 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_OPTION);
671 if (action.empty()) {
672 row[function_key_columns.option] = defstring;
674 if (action.find ('/') == string::npos) {
675 /* Probably a key alias */
676 row[function_key_columns.option] = action;
678 act = ActionManager::get_action (action.c_str());
680 row[function_key_columns.option] = act->get_label();
682 row[function_key_columns.option] = defstring;
687 action = dp.get_button_action (bid, MackieControlProtocol::MODIFIER_CMDALT);
688 if (action.empty()) {
689 row[function_key_columns.cmdalt] = defstring;
691 if (action.find ('/') == string::npos) {
692 /* Probably a key alias */
693 row[function_key_columns.cmdalt] = action;
695 act = ActionManager::get_action (action.c_str());
697 row[function_key_columns.cmdalt] = act->get_label();
699 row[function_key_columns.cmdalt] = defstring;
704 action = dp.get_button_action (bid, (MackieControlProtocol::MODIFIER_SHIFT|MackieControlProtocol::MODIFIER_CONTROL));
705 if (action.empty()) {
706 row[function_key_columns.shiftcontrol] = defstring;
708 act = ActionManager::get_action (action.c_str());
710 row[function_key_columns.shiftcontrol] = act->get_label();
712 row[function_key_columns.shiftcontrol] = defstring;
717 function_key_editor.set_model (function_key_model);
721 MackieControlProtocolGUI::action_changed (const Glib::ustring &sPath, const Glib::ustring &text, TreeModelColumnBase col)
723 // Remove Binding is not in the action map but still valid
725 if ( text == "Remove Binding") {
728 Gtk::TreePath path(sPath);
729 Gtk::TreeModel::iterator row = function_key_model->get_iter(path);
733 std::map<std::string,std::string>::iterator i = action_map.find (text);
735 if (i == action_map.end()) {
740 Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (i->second.c_str());
743 /* update visible text, using string supplied by
744 available action model so that it matches and is found
748 Glib::ustring dot = "\u2022";
749 (*row).set_value (col.index(), dot);
751 (*row).set_value (col.index(), text);
754 /* update the current DeviceProfile, using the full
760 switch (col.index()) {
762 modifier = MackieControlProtocol::MODIFIER_SHIFT;
765 modifier = MackieControlProtocol::MODIFIER_CONTROL;
768 modifier = MackieControlProtocol::MODIFIER_OPTION;
771 modifier = MackieControlProtocol::MODIFIER_CMDALT;
774 modifier = (MackieControlProtocol::MODIFIER_SHIFT|MackieControlProtocol::MODIFIER_CONTROL);
781 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, "");
783 _cp.device_profile().set_button_action ((*row)[function_key_columns.id], modifier, i->second);
787 std::cerr << "no such action\n";
793 MackieControlProtocolGUI::surface_combo_changed ()
795 _cp.not_session_load();
796 _cp.set_device (_surface_combo.get_active_text(), false);
800 MackieControlProtocolGUI::device_changed ()
802 if (_device_dependent_widget) {
803 table.remove (*_device_dependent_widget);
804 _device_dependent_widget = 0;
807 _device_dependent_widget = device_dependent_widget ();
808 _device_dependent_widget->show_all ();
810 table.attach (*_device_dependent_widget, 0, 12, device_dependent_row, device_dependent_row+1, AttachOptions(0), AttachOptions(0), 0, 0);
814 MackieControlProtocolGUI::profile_combo_changed ()
816 string profile = _profile_combo.get_active_text();
818 _cp.set_profile (profile);
820 refresh_function_key_editor ();
824 MackieControlProtocolGUI::ipmidi_spinner_changed ()
826 _cp.set_ipmidi_base ((int16_t) lrintf (ipmidi_base_port_adjustment.get_value()));
830 MackieControlProtocolGUI::discover_clicked ()
832 /* this should help to get things started */
837 MackieControlProtocolGUI::recalibrate_faders ()
839 _cp.recalibrate_faders ();
843 MackieControlProtocolGUI::toggle_backlight ()
845 _cp.toggle_backlight ();
849 MackieControlProtocolGUI::touch_sensitive_change ()
851 int sensitivity = (int) touch_sensitivity_adjustment.get_value ();
852 _cp.set_touch_sensitivity (sensitivity);