5 #include <gtkmm/comboboxtext.h>
6 #include <gtkmm/label.h>
9 #include "gtkmm2ext/utils.h"
11 #include "generic_midi_control_protocol.h"
15 class GMCPGUI : public Gtk::VBox
18 GMCPGUI (GenericMidiControlProtocol&);
22 GenericMidiControlProtocol& cp;
23 Gtk::ComboBoxText map_combo;
25 void binding_changed ();
29 using namespace ARDOUR;
32 using namespace Gtkmm2ext;
35 GenericMidiControlProtocol::get_gui () const
38 const_cast<GenericMidiControlProtocol*>(this)->build_gui ();
44 GenericMidiControlProtocol::tear_down_gui ()
46 delete (GMCPGUI*) gui;
50 GenericMidiControlProtocol::build_gui ()
52 gui = (void*) new GMCPGUI (*this);
55 /*--------------------*/
57 GMCPGUI::GMCPGUI (GenericMidiControlProtocol& p)
60 vector<string> popdowns;
61 popdowns.push_back (_("Reset All"));
63 for (list<GenericMidiControlProtocol::MapInfo>::iterator x = cp.map_info.begin(); x != cp.map_info.end(); ++x) {
64 popdowns.push_back ((*x).name);
67 set_popdown_strings (map_combo, popdowns, true, 5, 2);
69 if (cp.current_binding().empty()) {
70 map_combo.set_active_text (popdowns[0]);
72 map_combo.set_active_text (cp.current_binding());
75 map_combo.signal_changed().connect (sigc::mem_fun (*this, &GMCPGUI::binding_changed));
77 set_border_width (12);
79 Label* label = manage (new Label (_("Available MIDI bindings:")));
80 HBox* hpack = manage (new HBox);
82 hpack->set_spacing (6);
83 hpack->pack_start (*label, false, false);
84 hpack->pack_start (map_combo, false, false);
86 pack_start (*hpack, false, false);
98 GMCPGUI::binding_changed ()
100 string str = map_combo.get_active_text ();
102 if (str == _("Reset All")) {
105 for (list<GenericMidiControlProtocol::MapInfo>::iterator x = cp.map_info.begin(); x != cp.map_info.end(); ++x) {
106 if (str == (*x).name) {
107 cp.load_bindings ((*x).path);