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