switch to using boost::signals2 instead of sigc++, at least for libardour. not finish...
[ardour.git] / gtk2_ardour / rc_option_editor.cc
1 #include <gtkmm/liststore.h>
2 #include <gtkmm/stock.h>
3 #include <gtkmm/scale.h>
4 #include <gtkmm2ext/utils.h>
5 #include <gtkmm2ext/slider_controller.h>
6 #include "pbd/fpu.h"
7 #include "midi++/manager.h"
8 #include "midi++/factory.h"
9 #include "ardour/dB.h"
10 #include "ardour/rc_configuration.h"
11 #include "ardour/control_protocol_manager.h"
12 #include "control_protocol/control_protocol.h"
13 #include "rc_option_editor.h"
14 #include "utils.h"
15 #include "midi_port_dialog.h"
16 #include "sfdb_ui.h"
17 #include "keyboard.h"
18 #include "i18n.h"
19
20 using namespace std;
21 using namespace Gtk;
22 using namespace Gtkmm2ext;
23 using namespace PBD;
24 using namespace ARDOUR;
25
26 class MIDIPorts : public OptionEditorBox
27 {
28 public:
29         MIDIPorts (RCConfiguration* c, list<ComboOption<string>* > const & o)
30                 : _rc_config (c),
31                   _add_port_button (Stock::ADD),
32                   _port_combos (o)
33         {
34                 _store = ListStore::create (_model);
35                 _view.set_model (_store);
36                 _view.append_column (_("Name"), _model.name);
37                 _view.get_column(0)->set_resizable (true);
38                 _view.get_column(0)->set_expand (true);
39                 _view.append_column_editable (_("Online"), _model.online);
40                 _view.append_column_editable (_("Trace input"), _model.trace_input);
41                 _view.append_column_editable (_("Trace output"), _model.trace_output);
42
43                 HBox* h = manage (new HBox);
44                 h->set_spacing (4);
45                 h->pack_start (_view, true, true);
46
47                 VBox* v = manage (new VBox);
48                 v->set_spacing (4);
49                 v->pack_start (_add_port_button, false, false);
50                 h->pack_start (*v, false, false);
51
52                 _box->pack_start (*h);
53
54                 ports_changed ();
55
56                 _store->signal_row_changed().connect (sigc::mem_fun (*this, &MIDIPorts::model_changed));
57
58                 _add_port_button.signal_clicked().connect (sigc::mem_fun (*this, &MIDIPorts::add_port_clicked));
59         }
60
61         void parameter_changed (string const &) {}
62         void set_state_from_config () {}
63
64 private:
65
66         void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
67         {
68                 TreeModel::Row r = *i;
69
70                 MIDI::Port* port = r[_model.port];
71                 if (!port) {
72                         return;
73                 }
74
75                 if (port->input()) {
76
77                         if (r[_model.online] == port->input()->offline()) {
78                                 port->input()->set_offline (!r[_model.online]);
79                         }
80
81                         if (r[_model.trace_input] != port->input()->tracing()) {
82                                 port->input()->trace (r[_model.trace_input], &cerr, string (port->name()) + _(" input: "));
83                         }
84                 }
85
86                 if (port->output()) {
87
88                         if (r[_model.trace_output] != port->output()->tracing()) {
89                                 port->output()->trace (r[_model.trace_output], &cerr, string (port->name()) + _(" output: "));
90                         }
91
92                 }
93         }
94
95         void setup_ports_combo (ComboOption<string>* c)
96         {
97                 c->clear ();
98                 MIDI::Manager::PortList const & ports = MIDI::Manager::instance()->get_midi_ports ();
99                 for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) {
100                         c->add ((*i)->name(), (*i)->name());
101                 }
102         }       
103
104         void ports_changed ()
105         {
106                 /* XXX: why is this coming from here? */
107                 MIDI::Manager::PortList const & ports = MIDI::Manager::instance()->get_midi_ports ();
108
109                 _store->clear ();
110
111                 for (MIDI::Manager::PortList::const_iterator i = ports.begin(); i != ports.end(); ++i) {
112
113                         TreeModel::Row r = *_store->append ();
114
115                         r[_model.name] = (*i)->name();
116
117                         if ((*i)->input()) {
118                                 r[_model.online] = !(*i)->input()->offline();
119                                 (*i)->input()->OfflineStatusChanged.connect (sigc::bind (sigc::mem_fun (*this, &MIDIPorts::port_offline_changed), (*i)));
120                                 r[_model.trace_input] = (*i)->input()->tracing();
121                         }
122
123                         if ((*i)->output()) {
124                                 r[_model.trace_output] = (*i)->output()->tracing();
125                         }
126
127                         r[_model.port] = (*i);
128                 }
129
130                 for (list<ComboOption<string>* >::iterator i = _port_combos.begin(); i != _port_combos.end(); ++i) {
131                         setup_ports_combo (*i);
132                 }
133         }
134
135         void port_offline_changed (MIDI::Port* p)
136         {
137                 if (!p->input()) {
138                         return;
139                 }
140
141                 for (TreeModel::Children::iterator i = _store->children().begin(); i != _store->children().end(); ++i) {
142                         if ((*i)[_model.port] == p) {
143                                 (*i)[_model.online] = !p->input()->offline();
144                         }
145                 }
146         }
147
148         void add_port_clicked ()
149         {
150                 MidiPortDialog dialog;
151
152                 dialog.set_position (WIN_POS_MOUSE);
153
154                 dialog.show ();
155
156                 int const r = dialog.run ();
157
158                 switch (r) {
159                 case RESPONSE_ACCEPT:
160                         break;
161                 default:
162                         return;
163                         break;
164                 }
165
166                 Glib::ustring const mode = dialog.port_mode_combo.get_active_text ();
167                 string smod;
168
169                 if (mode == _("input")) {
170                         smod = X_("input");
171                 } else if (mode == (_("output"))) {
172                         smod = X_("output");
173                 } else {
174                         smod = "duplex";
175                 }
176
177                 XMLNode node (X_("MIDI-port"));
178
179                 node.add_property ("tag", dialog.port_name.get_text());
180                 node.add_property ("device", X_("ardour")); // XXX this can't be right for all types
181                 node.add_property ("type", MIDI::PortFactory::default_port_type());
182                 node.add_property ("mode", smod);
183
184                 if (MIDI::Manager::instance()->add_port (node) != 0) {
185                         cerr << " there are now " << MIDI::Manager::instance()->nports() << endl;
186                         ports_changed ();
187                 }
188         }
189
190         class MIDIModelColumns : public TreeModelColumnRecord
191         {
192         public:
193                 MIDIModelColumns ()
194                 {
195                         add (name);
196                         add (online);
197                         add (trace_input);
198                         add (trace_output);
199                         add (port);
200                 }
201
202                 TreeModelColumn<string> name;
203                 TreeModelColumn<bool> online;
204                 TreeModelColumn<bool> trace_input;
205                 TreeModelColumn<bool> trace_output;
206                 TreeModelColumn<MIDI::Port*> port;
207         };
208
209         RCConfiguration* _rc_config;
210         Glib::RefPtr<ListStore> _store;
211         MIDIModelColumns _model;
212         TreeView _view;
213         Button _add_port_button;
214         ComboBoxText _mtc_combo;
215         ComboBoxText _midi_clock_combo;
216         ComboBoxText _mmc_combo;
217         ComboBoxText _mpc_combo;
218         list<ComboOption<string>* > _port_combos;
219 };
220
221
222 class ClickOptions : public OptionEditorBox
223 {
224 public:
225         ClickOptions (RCConfiguration* c, ArdourDialog* p)
226                 : _rc_config (c),
227                   _parent (p)
228         {
229                 Table* t = manage (new Table (2, 3));
230                 t->set_spacings (4);
231
232                 Label* l = manage (new Label (_("Click audio file:")));
233                 l->set_alignment (0, 0.5);
234                 t->attach (*l, 0, 1, 0, 1, FILL);
235                 t->attach (_click_path_entry, 1, 2, 0, 1, FILL);
236                 Button* b = manage (new Button (_("Browse...")));
237                 b->signal_clicked().connect (sigc::mem_fun (*this, &ClickOptions::click_browse_clicked));
238                 t->attach (*b, 2, 3, 0, 1, FILL);
239
240                 l = manage (new Label (_("Click emphasis audio file:")));
241                 l->set_alignment (0, 0.5);
242                 t->attach (*l, 0, 1, 1, 2, FILL);
243                 t->attach (_click_emphasis_path_entry, 1, 2, 1, 2, FILL);
244                 b = manage (new Button (_("Browse...")));
245                 b->signal_clicked().connect (sigc::mem_fun (*this, &ClickOptions::click_emphasis_browse_clicked));
246                 t->attach (*b, 2, 3, 1, 2, FILL);
247
248                 _box->pack_start (*t, false, false);
249         }
250
251         void parameter_changed (string const & p)
252         {
253                 if (p == "click-sound") {
254                         _click_path_entry.set_text (_rc_config->get_click_sound());
255                 } else if (p == "click-emphasis-sound") {
256                         _click_emphasis_path_entry.set_text (_rc_config->get_click_emphasis_sound());
257                 }
258         }
259
260         void set_state_from_config ()
261         {
262                 parameter_changed ("click-sound");
263                 parameter_changed ("click-emphasis-sound");
264         }
265
266 private:
267
268         void click_browse_clicked ()
269         {
270                 SoundFileChooser sfdb (*_parent, _("Choose Click"));
271
272                 sfdb.show_all ();
273                 sfdb.present ();
274
275                 if (sfdb.run () == RESPONSE_OK) {
276                         click_chosen (sfdb.get_filename());
277                 }
278         }
279
280         void click_chosen (string const & path)
281         {
282                 _click_path_entry.set_text (path);
283                 _rc_config->set_click_sound (path);
284         }
285
286         void click_emphasis_browse_clicked ()
287         {
288                 SoundFileChooser sfdb (*_parent, _("Choose Click Emphasis"));
289
290                 sfdb.show_all ();
291                 sfdb.present ();
292
293                 if (sfdb.run () == RESPONSE_OK) {
294                         click_emphasis_chosen (sfdb.get_filename());
295                 }
296         }
297
298         void click_emphasis_chosen (string const & path)
299         {
300                 _click_emphasis_path_entry.set_text (path);
301                 _rc_config->set_click_emphasis_sound (path);
302         }
303
304         RCConfiguration* _rc_config;
305         ArdourDialog* _parent;
306         Entry _click_path_entry;
307         Entry _click_emphasis_path_entry;
308 };
309
310 class UndoOptions : public OptionEditorBox
311 {
312 public:
313         UndoOptions (RCConfiguration* c) :
314                 _rc_config (c),
315                 _limit_undo_button (_("Limit undo history to")),
316                 _save_undo_button (_("Save undo history of"))
317         {
318                 Table* t = new Table (2, 3);
319                 t->set_spacings (4);
320
321                 t->attach (_limit_undo_button, 0, 1, 0, 1, FILL);
322                 _limit_undo_spin.set_range (0, 512);
323                 _limit_undo_spin.set_increments (1, 10);
324                 t->attach (_limit_undo_spin, 1, 2, 0, 1, FILL | EXPAND);
325                 Label* l = manage (new Label (_("commands")));
326                 l->set_alignment (0, 0.5);
327                 t->attach (*l, 2, 3, 0, 1);
328
329                 t->attach (_save_undo_button, 0, 1, 1, 2, FILL);
330                 _save_undo_spin.set_range (0, 512);
331                 _save_undo_spin.set_increments (1, 10);
332                 t->attach (_save_undo_spin, 1, 2, 1, 2, FILL | EXPAND);
333                 l = manage (new Label (_("commands")));
334                 l->set_alignment (0, 0.5);
335                 t->attach (*l, 2, 3, 1, 2);
336
337                 _box->pack_start (*t);
338
339                 _limit_undo_button.signal_toggled().connect (sigc::mem_fun (*this, &UndoOptions::limit_undo_toggled));
340                 _limit_undo_spin.signal_value_changed().connect (sigc::mem_fun (*this, &UndoOptions::limit_undo_changed));
341                 _save_undo_button.signal_toggled().connect (sigc::mem_fun (*this, &UndoOptions::save_undo_toggled));
342                 _save_undo_spin.signal_value_changed().connect (sigc::mem_fun (*this, &UndoOptions::save_undo_changed));
343         }
344
345         void parameter_changed (string const & p)
346         {
347                 if (p == "history-depth") {
348                         int32_t const d = _rc_config->get_history_depth();
349                         _limit_undo_button.set_active (d != 0);
350                         _limit_undo_spin.set_sensitive (d != 0);
351                         _limit_undo_spin.set_value (d);
352                 } else if (p == "save-history") {
353                         bool const x = _rc_config->get_save_history ();
354                         _save_undo_button.set_active (x);
355                         _save_undo_spin.set_sensitive (x);
356                 } else if (p == "save-history-depth") {
357                         _save_undo_spin.set_value (_rc_config->get_saved_history_depth());
358                 }
359         }
360
361         void set_state_from_config ()
362         {
363                 parameter_changed ("save-history");
364                 parameter_changed ("history-depth");
365                 parameter_changed ("save-history-depth");
366         }
367
368         void limit_undo_toggled ()
369         {
370                 bool const x = _limit_undo_button.get_active ();
371                 _limit_undo_spin.set_sensitive (x);
372                 int32_t const n = x ? 16 : 0;
373                 _limit_undo_spin.set_value (n);
374                 _rc_config->set_history_depth (n);
375         }
376
377         void limit_undo_changed ()
378         {
379                 _rc_config->set_history_depth (_limit_undo_spin.get_value_as_int ());
380         }
381
382         void save_undo_toggled ()
383         {
384                 bool const x = _save_undo_button.get_active ();
385                 _rc_config->set_save_history (x);
386         }
387
388         void save_undo_changed ()
389         {
390                 _rc_config->set_saved_history_depth (_save_undo_spin.get_value_as_int ());
391         }
392
393 private:
394         RCConfiguration* _rc_config;
395         CheckButton _limit_undo_button;
396         SpinButton _limit_undo_spin;
397         CheckButton _save_undo_button;
398         SpinButton _save_undo_spin;
399 };
400
401
402
403 static const struct {
404     const char *name;
405     guint modifier;
406 } modifiers[] = {
407
408         { "Unmodified", 0 },
409
410 #ifdef GTKOSX
411
412         /* Command = Meta
413            Option/Alt = Mod1
414         */
415         { "Shift", GDK_SHIFT_MASK },
416         { "Command", GDK_META_MASK },
417         { "Control", GDK_CONTROL_MASK },
418         { "Option", GDK_MOD1_MASK },
419         { "Command-Shift", GDK_MOD1_MASK|GDK_SHIFT_MASK },
420         { "Command-Option", GDK_MOD1_MASK|GDK_MOD5_MASK },
421         { "Shift-Option", GDK_SHIFT_MASK|GDK_MOD5_MASK },
422         { "Shift-Command-Option", GDK_MOD5_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
423
424 #else
425         { "Shift", GDK_SHIFT_MASK },
426         { "Control", GDK_CONTROL_MASK },
427         { "Alt (Mod1)", GDK_MOD1_MASK },
428         { "Control-Shift", GDK_CONTROL_MASK|GDK_SHIFT_MASK },
429         { "Control-Alt", GDK_CONTROL_MASK|GDK_MOD1_MASK },
430         { "Shift-Alt", GDK_SHIFT_MASK|GDK_MOD1_MASK },
431         { "Control-Shift-Alt", GDK_CONTROL_MASK|GDK_SHIFT_MASK|GDK_MOD1_MASK },
432         { "Mod2", GDK_MOD2_MASK },
433         { "Mod3", GDK_MOD3_MASK },
434         { "Mod4", GDK_MOD4_MASK },
435         { "Mod5", GDK_MOD5_MASK },
436 #endif
437         { 0, 0 }
438 };
439
440
441 class KeyboardOptions : public OptionEditorBox
442 {
443 public:
444         KeyboardOptions () :
445                   _delete_button_adjustment (3, 1, 12),
446                   _delete_button_spin (_delete_button_adjustment),
447                   _edit_button_adjustment (3, 1, 5),
448                   _edit_button_spin (_edit_button_adjustment)
449
450         {
451                 /* internationalize and prepare for use with combos */
452
453                 vector<string> dumb;
454                 for (int i = 0; modifiers[i].name; ++i) {
455                         dumb.push_back (_(modifiers[i].name));
456                 }
457
458                 set_popdown_strings (_edit_modifier_combo, dumb);
459                 _edit_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::edit_modifier_chosen));
460
461                 for (int x = 0; modifiers[x].name; ++x) {
462                         if (modifiers[x].modifier == Keyboard::edit_modifier ()) {
463                                 _edit_modifier_combo.set_active_text (_(modifiers[x].name));
464                                 break;
465                         }
466                 }
467
468                 Table* t = manage (new Table (4, 4));
469                 t->set_spacings (4);
470
471                 Label* l = manage (new Label (_("Edit using:")));
472                 l->set_name ("OptionsLabel");
473                 l->set_alignment (0, 0.5);
474
475                 t->attach (*l, 0, 1, 0, 1, FILL | EXPAND, FILL);
476                 t->attach (_edit_modifier_combo, 1, 2, 0, 1, FILL | EXPAND, FILL);
477
478                 l = manage (new Label (_("+ button")));
479                 l->set_name ("OptionsLabel");
480
481                 t->attach (*l, 3, 4, 0, 1, FILL | EXPAND, FILL);
482                 t->attach (_edit_button_spin, 4, 5, 0, 1, FILL | EXPAND, FILL);
483
484                 _edit_button_spin.set_name ("OptionsEntry");
485                 _edit_button_adjustment.set_value (Keyboard::edit_button());
486                 _edit_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::edit_button_changed));
487
488                 set_popdown_strings (_delete_modifier_combo, dumb);
489                 _delete_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_modifier_chosen));
490
491                 for (int x = 0; modifiers[x].name; ++x) {
492                         if (modifiers[x].modifier == Keyboard::delete_modifier ()) {
493                                 _delete_modifier_combo.set_active_text (_(modifiers[x].name));
494                                 break;
495                         }
496                 }
497
498                 l = manage (new Label (_("Delete using:")));
499                 l->set_name ("OptionsLabel");
500                 l->set_alignment (0, 0.5);
501
502                 t->attach (*l, 0, 1, 1, 2, FILL | EXPAND, FILL);
503                 t->attach (_delete_modifier_combo, 1, 2, 1, 2, FILL | EXPAND, FILL);
504
505                 l = manage (new Label (_("+ button")));
506                 l->set_name ("OptionsLabel");
507
508                 t->attach (*l, 3, 4, 1, 2, FILL | EXPAND, FILL);
509                 t->attach (_delete_button_spin, 4, 5, 1, 2, FILL | EXPAND, FILL);
510
511                 _delete_button_spin.set_name ("OptionsEntry");
512                 _delete_button_adjustment.set_value (Keyboard::delete_button());
513                 _delete_button_adjustment.signal_value_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::delete_button_changed));
514
515                 set_popdown_strings (_snap_modifier_combo, dumb);
516                 _snap_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_modifier_chosen));
517
518                 for (int x = 0; modifiers[x].name; ++x) {
519                         if (modifiers[x].modifier == (guint) Keyboard::snap_modifier ()) {
520                                 _snap_modifier_combo.set_active_text (_(modifiers[x].name));
521                                 break;
522                         }
523                 }
524
525                 l = manage (new Label (_("Toggle snap using:")));
526                 l->set_name ("OptionsLabel");
527                 l->set_alignment (0, 0.5);
528
529                 t->attach (*l, 0, 1, 2, 3, FILL | EXPAND, FILL);
530                 t->attach (_snap_modifier_combo, 1, 2, 2, 3, FILL | EXPAND, FILL);
531
532                 vector<string> strs;
533
534                 for (map<string,string>::iterator bf = Keyboard::binding_files.begin(); bf != Keyboard::binding_files.end(); ++bf) {
535                         strs.push_back (bf->first);
536                 }
537
538                 set_popdown_strings (_keyboard_layout_selector, strs);
539                 _keyboard_layout_selector.set_active_text (Keyboard::current_binding_name());
540                 _keyboard_layout_selector.signal_changed().connect (sigc::mem_fun (*this, &KeyboardOptions::bindings_changed));
541
542                 l = manage (new Label (_("Keyboard layout:")));
543                 l->set_name ("OptionsLabel");
544                 l->set_alignment (0, 0.5);
545
546                 t->attach (*l, 0, 1, 3, 4, FILL | EXPAND, FILL);
547                 t->attach (_keyboard_layout_selector, 1, 2, 3, 4, FILL | EXPAND, FILL);
548
549                 _box->pack_start (*t, false, false);
550         }
551
552         void parameter_changed (string const &)
553         {
554                 /* XXX: these aren't really config options... */
555         }
556
557         void set_state_from_config ()
558         {
559                 /* XXX: these aren't really config options... */
560         }
561
562 private:
563
564         void bindings_changed ()
565         {
566                 string const txt = _keyboard_layout_selector.get_active_text();
567
568                 /* XXX: config...?  for all this keyboard stuff */
569
570                 for (map<string,string>::iterator i = Keyboard::binding_files.begin(); i != Keyboard::binding_files.end(); ++i) {
571                         if (txt == i->first) {
572                                 if (Keyboard::load_keybindings (i->second)) {
573                                         Keyboard::save_keybindings ();
574                                 }
575                         }
576                 }
577         }
578
579         void edit_modifier_chosen ()
580         {
581                 string const txt = _edit_modifier_combo.get_active_text();
582
583                 for (int i = 0; modifiers[i].name; ++i) {
584                         if (txt == _(modifiers[i].name)) {
585                                 Keyboard::set_edit_modifier (modifiers[i].modifier);
586                                 break;
587                         }
588                 }
589         }
590
591         void delete_modifier_chosen ()
592         {
593                 string const txt = _delete_modifier_combo.get_active_text();
594
595                 for (int i = 0; modifiers[i].name; ++i) {
596                         if (txt == _(modifiers[i].name)) {
597                                 Keyboard::set_delete_modifier (modifiers[i].modifier);
598                                 break;
599                         }
600                 }
601         }
602
603         void snap_modifier_chosen ()
604         {
605                 string const txt = _snap_modifier_combo.get_active_text();
606
607                 for (int i = 0; modifiers[i].name; ++i) {
608                         if (txt == _(modifiers[i].name)) {
609                                 Keyboard::set_snap_modifier (modifiers[i].modifier);
610                                 break;
611                         }
612                 }
613         }
614
615         void delete_button_changed ()
616         {
617                 Keyboard::set_delete_button (_delete_button_spin.get_value_as_int());
618         }
619
620         void edit_button_changed ()
621         {
622                 Keyboard::set_edit_button (_edit_button_spin.get_value_as_int());
623         }
624
625         ComboBoxText _keyboard_layout_selector;
626         ComboBoxText _edit_modifier_combo;
627         ComboBoxText _delete_modifier_combo;
628         ComboBoxText _snap_modifier_combo;
629         Adjustment _delete_button_adjustment;
630         SpinButton _delete_button_spin;
631         Adjustment _edit_button_adjustment;
632         SpinButton _edit_button_spin;
633 };
634
635 class FontScalingOptions : public OptionEditorBox
636 {
637 public:
638         FontScalingOptions (RCConfiguration* c) :
639                 _rc_config (c),
640                 _dpi_adjustment (50, 50, 250, 1, 10),
641                 _dpi_slider (_dpi_adjustment)
642         {
643                 _dpi_adjustment.set_value (_rc_config->get_font_scale () / 1024);
644
645                 Label* l = manage (new Label (_("Font scaling:")));
646                 l->set_name ("OptionsLabel");
647
648                 _dpi_slider.set_update_policy (UPDATE_DISCONTINUOUS);
649                 HBox* h = manage (new HBox);
650                 h->set_spacing (4);
651                 h->pack_start (*l, false, false);
652                 h->pack_start (_dpi_slider, true, true);
653
654                 _box->pack_start (*h, false, false);
655
656                 _dpi_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &FontScalingOptions::dpi_changed));
657         }
658
659         void parameter_changed (string const & p)
660         {
661                 if (p == "font-scale") {
662                         _dpi_adjustment.set_value (_rc_config->get_font_scale() / 1024);
663                 }
664         }
665
666         void set_state_from_config ()
667         {
668                 parameter_changed ("font-scale");
669         }
670
671 private:
672
673         void dpi_changed ()
674         {
675                 _rc_config->set_font_scale ((long) floor (_dpi_adjustment.get_value() * 1024));
676                 /* XXX: should be triggered from the parameter changed signal */
677                 reset_dpi ();
678         }
679
680         RCConfiguration* _rc_config;
681         Adjustment _dpi_adjustment;
682         HScale _dpi_slider;
683 };
684
685 class SoloMuteOptions : public OptionEditorBox
686 {
687 public:
688         SoloMuteOptions (RCConfiguration* c) :
689                 _rc_config (c),
690                 // 0.781787 is the value needed for gain to be set to 0.
691                 _db_adjustment (0.781787, 0.0, 1.0, 0.01, 0.1)
692
693         {
694                 if ((pix = ::get_icon ("fader_belt_h")) == 0) {
695                         throw failed_constructor();
696                 }
697
698                 _db_slider = manage (new HSliderController (pix,
699                                                             &_db_adjustment,
700                                                             false,
701                                                             115));
702
703
704                 parameter_changed ("solo-mute-gain");
705
706                 Label* l = manage (new Label (_("Solo mute cut (dB):")));
707                 l->set_name ("OptionsLabel");
708
709                 HBox* h = manage (new HBox);
710                 h->set_spacing (4);
711                 h->pack_start (*l, false, false);
712                 h->pack_start (*_db_slider, false, false);
713                 h->pack_start (_db_display, false, false);
714
715                 set_size_request_to_display_given_text (_db_display, "-99.0", 12, 12);
716
717                 _box->pack_start (*h, false, false);
718
719                 _db_adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SoloMuteOptions::db_changed));
720         }
721
722         void parameter_changed (string const & p)
723         {
724                 if (p == "solo-mute-gain") {
725                         gain_t val = _rc_config->get_solo_mute_gain();
726
727                         _db_adjustment.set_value (gain_to_slider_position (val));
728
729                         char buf[16];
730
731                         if (val == 0.0) {
732                                 snprintf (buf, sizeof (buf), "-inf");
733                         } else {
734                                 snprintf (buf, sizeof (buf), "%.2f", accurate_coefficient_to_dB (val));
735                         }
736
737                         _db_display.set_text (buf);
738                 }
739         }
740
741         void set_state_from_config ()
742         {
743                 parameter_changed ("solo-mute-gain");
744         }
745
746 private:
747
748         void db_changed ()
749         {
750                 _rc_config->set_solo_mute_gain (slider_position_to_gain (_db_adjustment.get_value()));
751         }
752
753         RCConfiguration* _rc_config;
754         Adjustment _db_adjustment;
755         Gtkmm2ext::HSliderController* _db_slider;
756         Glib::RefPtr<Gdk::Pixbuf> pix;
757         Entry _db_display;
758 };
759
760
761 class ControlSurfacesOptions : public OptionEditorBox
762 {
763 public:
764         ControlSurfacesOptions ()
765         {
766                 _store = ListStore::create (_model);
767                 _view.set_model (_store);
768                 _view.append_column (_("Name"), _model.name);
769                 _view.get_column(0)->set_resizable (true);
770                 _view.get_column(0)->set_expand (true);
771                 _view.append_column_editable (_("Enabled"), _model.enabled);
772                 _view.append_column_editable (_("Feedback"), _model.feedback);
773
774                 _box->pack_start (_view, false, false);
775
776                 _store->signal_row_changed().connect (sigc::mem_fun (*this, &ControlSurfacesOptions::model_changed));
777         }
778
779         void parameter_changed (std::string const &)
780         {
781
782         }
783
784         void set_state_from_config ()
785         {
786                 _store->clear ();
787
788                 ControlProtocolManager& m = ControlProtocolManager::instance ();
789                 for (list<ControlProtocolInfo*>::iterator i = m.control_protocol_info.begin(); i != m.control_protocol_info.end(); ++i) {
790
791                         if (!(*i)->mandatory) {
792                                 TreeModel::Row r = *_store->append ();
793                                 r[_model.name] = (*i)->name;
794                                 r[_model.enabled] = ((*i)->protocol || (*i)->requested);
795                                 r[_model.feedback] = ((*i)->protocol && (*i)->protocol->get_feedback ());
796                                 r[_model.protocol_info] = *i;
797                         }
798                 }
799         }
800
801 private:
802
803         void model_changed (TreeModel::Path const &, TreeModel::iterator const & i)
804         {
805                 TreeModel::Row r = *i;
806
807                 ControlProtocolInfo* cpi = r[_model.protocol_info];
808                 if (!cpi) {
809                         return;
810                 }
811
812                 bool const was_enabled = (cpi->protocol != 0);
813                 bool const is_enabled = r[_model.enabled];
814
815                 if (was_enabled != is_enabled) {
816                         if (!was_enabled) {
817                                 ControlProtocolManager::instance().instantiate (*cpi);
818                         } else {
819                                 ControlProtocolManager::instance().teardown (*cpi);
820                         }
821                 }
822
823                 bool const was_feedback = (cpi->protocol && cpi->protocol->get_feedback ());
824                 bool const is_feedback = r[_model.feedback];
825
826                 if (was_feedback != is_feedback && cpi->protocol) {
827                         cpi->protocol->set_feedback (is_feedback);
828                 }
829         }
830
831         class ControlSurfacesModelColumns : public TreeModelColumnRecord
832         {
833         public:
834
835                 ControlSurfacesModelColumns ()
836                 {
837                         add (name);
838                         add (enabled);
839                         add (feedback);
840                         add (protocol_info);
841                 }
842
843                 TreeModelColumn<string> name;
844                 TreeModelColumn<bool> enabled;
845                 TreeModelColumn<bool> feedback;
846                 TreeModelColumn<ControlProtocolInfo*> protocol_info;
847         };
848
849         Glib::RefPtr<ListStore> _store;
850         ControlSurfacesModelColumns _model;
851         TreeView _view;
852 };
853
854
855 RCOptionEditor::RCOptionEditor ()
856         : OptionEditor (Config, _("Ardour Preferences")),
857           _rc_config (Config)
858 {
859         /* MISC */
860
861         add_option (_("Misc"), new OptionEditorHeading (_("Metering")));
862
863         ComboOption<float>* mht = new ComboOption<float> (
864                 "meter-hold",
865                 _("Meter hold time"),
866                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_hold),
867                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_hold)
868                 );
869
870         mht->add (MeterHoldOff, _("off"));
871         mht->add (MeterHoldShort, _("short"));
872         mht->add (MeterHoldMedium, _("medium"));
873         mht->add (MeterHoldLong, _("long"));
874
875         add_option (_("Misc"), mht);
876
877         ComboOption<float>* mfo = new ComboOption<float> (
878                 "meter-falloff",
879                 _("Meter fall-off"),
880                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_meter_falloff),
881                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_meter_falloff)
882                 );
883
884         mfo->add (METER_FALLOFF_OFF, _("off"));
885         mfo->add (METER_FALLOFF_SLOWEST, _("slowest"));
886         mfo->add (METER_FALLOFF_SLOW, _("slow"));
887         mfo->add (METER_FALLOFF_MEDIUM, _("medium"));
888         mfo->add (METER_FALLOFF_FAST, _("fast"));
889         mfo->add (METER_FALLOFF_FASTER, _("faster"));
890         mfo->add (METER_FALLOFF_FASTEST, _("fastest"));
891
892         add_option (_("Misc"), mfo);
893
894         add_option (_("Misc"), new OptionEditorHeading (_("Undo")));
895
896         add_option (_("Misc"), new UndoOptions (_rc_config));
897
898         add_option (_("Misc"), new OptionEditorHeading (_("Misc")));
899
900 #ifndef GTKOSX
901         /* font scaling does nothing with GDK/Quartz */
902         add_option (_("Misc"), new FontScalingOptions (_rc_config));
903 #endif
904
905         add_option (_("Misc"),
906              new BoolOption (
907                      "verify-remove-last-capture",
908                      _("Verify removal of last capture"),
909                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_verify_remove_last_capture),
910                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_verify_remove_last_capture)
911                      ));
912
913         add_option (_("Misc"),
914              new BoolOption (
915                      "periodic-safety-backups",
916                      _("Make periodic backups of the session file"),
917                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_periodic_safety_backups),
918                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_periodic_safety_backups)
919                      ));
920
921         add_option (_("Misc"),
922              new BoolOption (
923                      "sync-all-route-ordering",
924                      _("Syncronise editor and mixer track order"),
925                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_sync_all_route_ordering),
926                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_sync_all_route_ordering)
927                      ));
928
929         add_option (_("Misc"),
930              new BoolOption (
931                      "only-copy-imported-files",
932                      _("Always copy imported files"),
933                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_only_copy_imported_files),
934                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_only_copy_imported_files)
935                      ));
936
937         add_option (_("Misc"),
938              new BoolOption (
939                      "default-narrow_ms",
940                      _("Use narrow mixer strips"),
941                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_default_narrow_ms),
942                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_default_narrow_ms)
943                      ));
944
945         add_option (_("Misc"),
946              new BoolOption (
947                      "name-new-markers",
948                      _("Name new markers"),
949                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_name_new_markers),
950                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_name_new_markers)
951                      ));
952
953         /* TRANSPORT */
954
955         add_option (_("Transport"),
956              new BoolOption (
957                      "latched-record-enable",
958                      _("Keep record-enable engaged on stop"),
959                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_latched_record_enable),
960                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_latched_record_enable)
961                      ));
962
963         add_option (_("Transport"),
964              new BoolOption (
965                      "stop-recording-on-xrun",
966                      _("Stop recording when an xrun occurs"),
967                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_recording_on_xrun),
968                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_recording_on_xrun)
969                      ));
970
971         add_option (_("Transport"),
972              new BoolOption (
973                      "create-xrun-marker",
974                      _("Create markers where xruns occur"),
975                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_create_xrun_marker),
976                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_create_xrun_marker)
977                      ));
978
979         add_option (_("Transport"),
980              new BoolOption (
981                      "stop-at-session-end",
982                      _("Stop at the end of the session"),
983                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_stop_at_session_end),
984                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_stop_at_session_end)
985                      ));
986
987         add_option (_("Transport"),
988              new BoolOption (
989                      "primary-clock-delta-edit-cursor",
990                      _("Primary clock delta to edit cursor"),
991                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_primary_clock_delta_edit_cursor),
992                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_primary_clock_delta_edit_cursor)
993                      ));
994
995         add_option (_("Transport"),
996              new BoolOption (
997                      "secondary-clock-delta-edit-cursor",
998                      _("Secondary clock delta to edit cursor"),
999                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_secondary_clock_delta_edit_cursor),
1000                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_secondary_clock_delta_edit_cursor)
1001                      ));
1002
1003         add_option (_("Transport"),
1004              new BoolOption (
1005                      "disable-disarm-during-roll",
1006                      _("Disable per-track record disarm while rolling"),
1007                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_disable_disarm_during_roll),
1008                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_disable_disarm_during_roll)
1009                      ));
1010
1011         /* EDITOR */
1012
1013         add_option (_("Editor"),
1014              new BoolOption (
1015                      "link-region-and-track-selection",
1016                      _("Link selection of regions and tracks"),
1017                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_link_region_and_track_selection),
1018                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_link_region_and_track_selection)
1019                      ));
1020
1021         add_option (_("Editor"),
1022              new BoolOption (
1023                      "automation-follows-regions",
1024                      _("Move relevant automation when regions are moved"),
1025                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_automation_follows_regions),
1026                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_automation_follows_regions)
1027                      ));
1028
1029         add_option (_("Editor"),
1030              new BoolOption (
1031                      "show-track-meters",
1032                      _("Show meters on tracks in the editor"),
1033                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_track_meters),
1034                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_track_meters)
1035                      ));
1036
1037         add_option (_("Editor"),
1038              new BoolOption (
1039                      "use-overlap-equivalency",
1040                      _("Use overlap equivalency for regions"),
1041                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_use_overlap_equivalency),
1042                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_use_overlap_equivalency)
1043                      ));
1044
1045         add_option (_("Editor"),
1046              new BoolOption (
1047                      "rubberbanding-snaps-to-grid",
1048                      _("Make rubberband selection rectangle snap to the grid"),
1049                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_rubberbanding_snaps_to_grid),
1050                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_rubberbanding_snaps_to_grid)
1051                      ));
1052
1053         add_option (_("Editor"),
1054              new BoolOption (
1055                      "show-waveforms",
1056                      _("Show waveforms in regions"),
1057                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_waveforms),
1058                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_waveforms)
1059                      ));
1060
1061         ComboOption<WaveformScale>* wfs = new ComboOption<WaveformScale> (
1062                 "waveform-scale",
1063                 _("Waveform scale"),
1064                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_scale),
1065                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_scale)
1066                 );
1067
1068         wfs->add (Linear, _("linear"));
1069         wfs->add (Logarithmic, _("logarithmic"));
1070
1071         add_option (_("Editor"), wfs);
1072
1073         ComboOption<WaveformShape>* wfsh = new ComboOption<WaveformShape> (
1074                 "waveform-shape",
1075                 _("Waveform shape"),
1076                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_waveform_shape),
1077                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_waveform_shape)
1078                 );
1079
1080         wfsh->add (Traditional, _("traditional"));
1081         wfsh->add (Rectified, _("rectified"));
1082
1083         add_option (_("Editor"), wfsh);
1084
1085         /* AUDIO */
1086
1087         add_option (_("Audio"), new OptionEditorHeading (_("Solo")));
1088
1089
1090         add_option (_("Audio"),
1091              new BoolOption (
1092                      "solo-control-is-listen-control",
1093                      _("Solo controls are Listen controls"),
1094                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_control_is_listen_control),
1095                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_control_is_listen_control)
1096                      ));
1097
1098         ComboOption<ListenPosition>* lp = new ComboOption<ListenPosition> (
1099                 "listen-position",
1100                 _("Listen Position"),
1101                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_listen_position),
1102                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_listen_position)
1103                 );
1104
1105         lp->add (AfterFaderListen, _("after-fader listen"));
1106         lp->add (PreFaderListen, _("pre-fader listen"));
1107
1108         add_option (_("Audio"), lp);
1109         add_option (_("Audio"), new SoloMuteOptions (_rc_config));
1110
1111         add_option (_("Audio"),
1112              new BoolOption (
1113                      "solo-latched",
1114                      _("Latched solo"),
1115                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_latched),
1116                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_latched)
1117                      ));
1118
1119         add_option (_("Audio"),
1120              new BoolOption (
1121                      "show-solo-mutes",
1122                      _("Show solo muting"),
1123                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_show_solo_mutes),
1124                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_show_solo_mutes)
1125                      ));
1126
1127         add_option (_("Audio"),
1128              new BoolOption (
1129                      "solo-mute-override",
1130                      _("Override muting"),
1131                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_solo_mute_override),
1132                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_solo_mute_override)
1133                      ));
1134
1135         add_option (_("Audio"), new OptionEditorHeading (_("Monitoring")));
1136
1137         ComboOption<MonitorModel>* mm = new ComboOption<MonitorModel> (
1138                 "monitoring-model",
1139                 _("Monitoring handled by"),
1140                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_monitoring_model),
1141                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_monitoring_model)
1142                 );
1143
1144         mm->add (HardwareMonitoring, _("JACK"));
1145         mm->add (SoftwareMonitoring, _("ardour"));
1146         mm->add (ExternalMonitoring, _("audio hardware"));
1147
1148         add_option (_("Audio"), mm);
1149
1150         add_option (_("Audio"),
1151              new BoolOption (
1152                      "tape-machine-mode",
1153                      _("Tape machine mode"),
1154                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_tape_machine_mode),
1155                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_tape_machine_mode)
1156                      ));
1157
1158         add_option (_("Audio"), new OptionEditorHeading (_("Connection of tracks and busses")));
1159
1160         add_option (_("Audio"),
1161                     new BoolOption (
1162                             "auto-connect-standard-busses",
1163                             _("Auto-connect master/monitor busses"),
1164                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_connect_standard_busses),
1165                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_connect_standard_busses)
1166                             ));
1167
1168         ComboOption<AutoConnectOption>* iac = new ComboOption<AutoConnectOption> (
1169                 "input-auto-connect",
1170                 _("Connect track and bus inputs"),
1171                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_input_auto_connect),
1172                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_input_auto_connect)
1173                 );
1174
1175         iac->add (AutoConnectPhysical, _("automatically to physical inputs"));
1176         iac->add (ManualConnect, _("manually"));
1177
1178         add_option (_("Audio"), iac);
1179
1180         ComboOption<AutoConnectOption>* oac = new ComboOption<AutoConnectOption> (
1181                 "output-auto-connect",
1182                 _("Connect track and bus outputs"),
1183                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_output_auto_connect),
1184                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_output_auto_connect)
1185                 );
1186
1187         oac->add (AutoConnectPhysical, _("automatically to physical outputs"));
1188         oac->add (AutoConnectMaster, _("automatically to master outputs"));
1189         oac->add (ManualConnect, _("manually"));
1190
1191         add_option (_("Audio"), oac);
1192
1193         add_option (_("Audio"), new OptionEditorHeading (_("Denormals")));
1194
1195         add_option (_("Audio"),
1196              new BoolOption (
1197                      "denormal-protection",
1198                      _("Use DC bias to protect against denormals"),
1199                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_protection),
1200                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_protection)
1201                      ));
1202
1203         ComboOption<DenormalModel>* dm = new ComboOption<DenormalModel> (
1204                 "denormal-model",
1205                 _("Processor handling"),
1206                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_denormal_model),
1207                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_denormal_model)
1208                 );
1209
1210         dm->add (DenormalNone, _("no processor handling"));
1211
1212         FPU fpu;
1213
1214         if (fpu.has_flush_to_zero()) {
1215                 dm->add (DenormalFTZ, _("use FlushToZero"));
1216         }
1217
1218         if (fpu.has_denormals_are_zero()) {
1219                 dm->add (DenormalDAZ, _("use DenormalsAreZero"));
1220         }
1221
1222         if (fpu.has_flush_to_zero() && fpu.has_denormals_are_zero()) {
1223                 dm->add (DenormalFTZDAZ, _("use FlushToZero and DenormalsAreZerO"));
1224         }
1225
1226         add_option (_("Audio"), dm);
1227
1228         add_option (_("Audio"), new OptionEditorHeading (_("Plugins")));
1229
1230         add_option (_("Audio"),
1231              new BoolOption (
1232                      "plugins-stop-with-transport",
1233                      _("Stop plugins when the transport is stopped"),
1234                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_plugins_stop_with_transport),
1235                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_plugins_stop_with_transport)
1236                      ));
1237
1238         add_option (_("Audio"),
1239              new BoolOption (
1240                      "do-not-record-plugins",
1241                      _("Disable plugins during recording"),
1242                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_do_not_record_plugins),
1243                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_do_not_record_plugins)
1244                      ));
1245
1246         add_option (_("Audio"),
1247              new BoolOption (
1248                      "new-plugins-active",
1249                      _("Make new plugins active"),
1250                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_new_plugins_active),
1251                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_new_plugins_active)
1252                      ));
1253
1254         add_option (_("Audio"),
1255              new BoolOption (
1256                      "auto-analyse-audio",
1257                      _("Enable automatic analysis of audio"),
1258                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_auto_analyse_audio),
1259                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_auto_analyse_audio)
1260                      ));
1261
1262         /* MIDI CONTROL */
1263
1264         list<ComboOption<string>* > midi_combos;
1265
1266         midi_combos.push_back (new ComboOption<string> (
1267                                        "mtc-port-name",
1268                                        _("Send/Receive MTC via"),
1269                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_mtc_port_name),
1270                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_mtc_port_name)
1271                                        ));
1272
1273         midi_combos.push_back (new ComboOption<string> (
1274                                        "midi-clock-port-name",
1275                                        _("Send/Receive MIDI clock via"),
1276                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_clock_port_name),
1277                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_clock_port_name)
1278                                        ));
1279
1280         midi_combos.push_back (new ComboOption<string> (
1281                                        "mmc-port-name",
1282                                        _("Send/Receive MMC via"),
1283                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_port_name),
1284                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_port_name)
1285                                        ));
1286
1287         midi_combos.push_back (new ComboOption<string> (
1288                                        "midi-port-name",
1289                                        _("Send/Receive MIDI parameter control via"),
1290                                        sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_port_name),
1291                                        sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_port_name)
1292                                        ));
1293         
1294         add_option (_("MIDI control"), new MIDIPorts (_rc_config, midi_combos));
1295
1296         for (list<ComboOption<string>* >::iterator i = midi_combos.begin(); i != midi_combos.end(); ++i) {
1297                 add_option (_("MIDI control"), *i);
1298         }
1299
1300         add_option (_("MIDI control"),
1301                     new BoolOption (
1302                             "mmc-control",
1303                             _("Obey MIDI Machine Control commands"),
1304                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_control),
1305                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_control)
1306                             ));
1307
1308
1309         add_option (_("MIDI control"),
1310                     new BoolOption (
1311                             "send-mmc",
1312                             _("Send MIDI Machine Control commands"),
1313                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_send_mmc),
1314                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_send_mmc)
1315                             ));
1316
1317         add_option (_("MIDI control"),
1318                     new BoolOption (
1319                             "midi-feedback",
1320                             _("Send MIDI control feedback"),
1321                             sigc::mem_fun (*_rc_config, &RCConfiguration::get_midi_feedback),
1322                             sigc::mem_fun (*_rc_config, &RCConfiguration::set_midi_feedback)
1323                             ));
1324
1325         add_option (_("MIDI control"),
1326              new SpinOption<uint8_t> (
1327                      "mmc-receive-device-id",
1328                      _("Inbound MMC device ID"),
1329                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_receive_device_id),
1330                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_receive_device_id),
1331                      0, 128, 1, 10
1332                      ));
1333
1334         add_option (_("MIDI control"),
1335              new SpinOption<uint8_t> (
1336                      "mmc-send-device-id",
1337                      _("Outbound MMC device ID"),
1338                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_mmc_send_device_id),
1339                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_mmc_send_device_id),
1340                      0, 128, 1, 10
1341                      ));
1342
1343         add_option (_("MIDI control"),
1344              new SpinOption<int32_t> (
1345                      "initial-program-change",
1346                      _("Initial program change"),
1347                      sigc::mem_fun (*_rc_config, &RCConfiguration::get_initial_program_change),
1348                      sigc::mem_fun (*_rc_config, &RCConfiguration::set_initial_program_change),
1349                      -1, 65536, 1, 10
1350                      ));
1351
1352         /* CONTROL SURFACES */
1353
1354         add_option (_("Control surfaces"), new ControlSurfacesOptions);
1355
1356         ComboOption<RemoteModel>* rm = new ComboOption<RemoteModel> (
1357                 "remote-model",
1358                 _("Control surface remote ID"),
1359                 sigc::mem_fun (*_rc_config, &RCConfiguration::get_remote_model),
1360                 sigc::mem_fun (*_rc_config, &RCConfiguration::set_remote_model)
1361                 );
1362
1363         rm->add (UserOrdered, _("assigned by user"));
1364         rm->add (MixerOrdered, _("follows order of mixer"));
1365         rm->add (EditorOrdered, _("follows order of editor"));
1366
1367         add_option (_("Control surfaces"), rm);
1368
1369         /* CLICK */
1370
1371         add_option (_("Click"), new ClickOptions (_rc_config, this));
1372
1373         /* KEYBOARD */
1374
1375         add_option (_("Keyboard"), new KeyboardOptions);
1376 }
1377
1378