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>
29 #include "gtkmm2ext/utils.h"
30 #include "gtkmm2ext/actions.h"
32 #include "mackie_control_protocol.h"
33 #include "device_info.h"
39 using namespace Mackie;
43 MackieControlProtocol::get_gui () const
46 const_cast<MackieControlProtocol*>(this)->build_gui ();
53 MackieControlProtocol::tear_down_gui ()
55 delete (MackieControlProtocolGUI*) _gui;
59 MackieControlProtocol::build_gui ()
61 _gui = (void *) new MackieControlProtocolGUI (*this);
64 MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
67 set_border_width (12);
69 Gtk::Table* table = Gtk::manage (new Gtk::Table (2, 2));
70 table->set_spacings (4);
72 table->attach (*manage (new Gtk::Label (_("Surface type:"))), 0, 1, 0, 1);
73 table->attach (_surface_combo, 1, 2, 0, 1);
75 vector<string> surfaces;
77 for (std::map<std::string,DeviceInfo>::iterator i = DeviceInfo::device_info.begin(); i != DeviceInfo::device_info.end(); ++i) {
78 std::cerr << "Dveice known: " << i->first << endl;
79 surfaces.push_back (i->first);
81 Gtkmm2ext::set_popdown_strings (_surface_combo, surfaces);
82 _surface_combo.set_active_text (p.device_info().name());
83 _surface_combo.signal_changed().connect (sigc::mem_fun (*this, &MackieControlProtocolGUI::surface_combo_changed));
85 append_page (*table, _("Device Selection"));
88 /* function key editor */
90 append_page (function_key_scroller, _("Function Keys"));
91 function_key_scroller.add (function_key_editor);
93 rebuild_function_key_editor ();
94 function_key_scroller.show_all();
98 MackieControlProtocolGUI::rebuild_function_key_editor ()
100 /* build a model of all available actions (needs to be tree structured
104 available_action_model = TreeStore::create (available_action_columns);
106 vector<string> a_names;
107 vector<string> a_paths;
108 vector<string> a_tooltips;
109 vector<string> a_keys;
110 vector<Gtk::AccelKey> a_bindings;
112 ActionManager::get_all_actions (a_names, a_paths, a_tooltips, a_keys, a_bindings);
114 vector<string>::iterator n = a_names.begin();
115 vector<string>::iterator p = a_paths.begin();
118 for (; n != a_names.end(); ++n, ++p) {
119 r = *(available_action_model->append());
120 r[available_action_columns.name] = (*n);
121 r[available_action_columns.path] = (*p);
124 function_key_editor.append_column (_("Key"), function_key_columns.name);
126 CellRendererCombo* plain_renderer = manage (new CellRendererCombo);
127 plain_renderer->property_model() = available_action_model;
128 plain_renderer->property_editable() = true;
129 plain_renderer->property_text_column() = 1;
130 TreeViewColumn* plain_column = manage (new TreeViewColumn (_("plain"), *plain_renderer));
131 function_key_editor.append_column (*plain_column);
135 MackieControlProtocolGUI::surface_combo_changed ()
137 _cp.set_device (_surface_combo.get_active_text());