restore visual DC bias on/off indicator
[ardour.git] / gtk2_ardour / ardour_ui_options.cc
1 /*
2     Copyright (C) 2005 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <pbd/convert.h>
21 #include <pbd/stacktrace.h>
22
23 #include <gtkmm2ext/utils.h>
24
25 #include <ardour/configuration.h>
26 #include <ardour/session.h>
27 #include <ardour/osc.h>
28 #include <ardour/audioengine.h>
29
30 #include "ardour_ui.h"
31 #include "actions.h"
32 #include "gui_thread.h"
33
34 #include "i18n.h"
35
36 using namespace Gtk;
37 using namespace Gtkmm2ext;
38 using namespace ARDOUR;
39 using namespace PBD;
40 using namespace sigc;
41
42 void
43 ARDOUR_UI::toggle_time_master ()
44 {
45         ActionManager::toggle_config_state ("Transport", "ToggleTimeMaster", &Configuration::set_jack_time_master, &Configuration::get_jack_time_master);
46 }
47
48 void
49 ARDOUR_UI::toggle_send_mtc ()
50 {
51         ActionManager::toggle_config_state ("options", "SendMTC", &Configuration::set_send_mtc, &Configuration::get_send_mtc);
52 }
53
54 void
55 ARDOUR_UI::toggle_send_mmc ()
56 {
57         ActionManager::toggle_config_state ("options", "SendMMC", &Configuration::set_send_mmc, &Configuration::get_send_mmc);
58 }
59
60 void
61 ARDOUR_UI::toggle_use_mmc ()
62 {
63         ActionManager::toggle_config_state ("options", "UseMMC", &Configuration::set_mmc_control, &Configuration::get_mmc_control);
64 }
65
66 void
67 ARDOUR_UI::toggle_use_osc ()
68 {
69         ActionManager::toggle_config_state ("options", "UseOSC", &Configuration::set_use_osc, &Configuration::get_use_osc);
70 }
71
72 void
73 ARDOUR_UI::toggle_send_midi_feedback ()
74 {
75         ActionManager::toggle_config_state ("options", "SendMIDIfeedback", &Configuration::set_midi_feedback, &Configuration::get_midi_feedback);
76 }
77
78 void
79 ARDOUR_UI::toggle_denormal_protection ()
80 {
81         ActionManager::toggle_config_state ("options", "DenormalProtection", &Configuration::set_denormal_protection, &Configuration::get_denormal_protection);
82 }
83
84 void
85 ARDOUR_UI::set_native_file_header_format (HeaderFormat hf)
86 {
87         const char *action = 0;
88
89         switch (hf) {
90         case BWF:
91                 action = X_("FileHeaderFormatBWF");
92                 break;
93         case WAVE:
94                 action = X_("FileHeaderFormatWAVE");
95                 break;
96         case WAVE64:
97                 action = X_("FileHeaderFormatWAVE64");
98                 break;
99         case iXML:
100                 action = X_("FileHeaderFormatiXML");
101                 break;
102         case RF64:
103                 action = X_("FileHeaderFormatRF64");
104                 break;
105         case CAF:
106                 action = X_("FileHeaderFormatCAF");
107                 break;
108         case AIFF:
109                 action = X_("FileHeaderFormatAIFF");
110                 break;
111         default:
112                 fatal << string_compose (_("programming error: %1"), "illegal file header format in ::set_native_file_header_format") << endmsg;
113                 /*NOTREACHED*/  
114         }
115
116         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
117
118         if (act) {
119                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
120                 if (ract && ract->get_active() && Config->get_native_file_header_format() != hf) {
121                         Config->set_native_file_header_format (hf);
122                 }
123         }
124 }
125
126 void
127 ARDOUR_UI::set_native_file_data_format (SampleFormat sf)
128 {
129         const char* action = 0;
130
131         switch (sf) {
132         case FormatFloat:
133                 action = X_("FileDataFormatFloat");
134                 break;
135         case FormatInt24:
136                 action = X_("FileDataFormat24bit");
137                 break;
138         case FormatInt16:
139                 action = X_("FileDataFormat16bit");
140                 break;
141         default:
142                 fatal << string_compose (_("programming error: %1"), "illegal file data format in ::set_native_file_data_format") << endmsg;
143                 /*NOTREACHED*/
144         }
145
146         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
147
148         if (act) {
149                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
150                 if (ract && ract->get_active() && Config->get_native_file_data_format() != sf) {
151                         Config->set_native_file_data_format (sf);
152                 }
153         }
154 }
155
156 void
157 ARDOUR_UI::set_input_auto_connect (AutoConnectOption option)
158 {
159         const char* action;
160         
161         switch (option) {
162         case AutoConnectPhysical:
163                 action = X_("InputAutoConnectPhysical");
164                 break;
165         default:
166                 action = X_("InputAutoConnectManual");
167         }
168
169         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
170
171         if (act) {
172                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
173
174                 if (ract && ract->get_active() && Config->get_input_auto_connect() != option) {
175                         Config->set_input_auto_connect (option);
176                 }
177         }
178 }
179
180 void
181 ARDOUR_UI::set_output_auto_connect (AutoConnectOption option)
182 {
183         const char* action;
184         
185         switch (option) {
186         case AutoConnectPhysical:
187                 action = X_("OutputAutoConnectPhysical");
188                 break;
189         case AutoConnectMaster:
190                 action = X_("OutputAutoConnectMaster");
191                 break;
192         default:
193                 action = X_("OutputAutoConnectManual");
194         }
195
196         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
197
198         if (act) {
199                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
200
201                 if (ract && ract->get_active() && Config->get_output_auto_connect() != option) {
202                         Config->set_output_auto_connect (option);
203                 }
204         }
205 }
206
207 void
208 ARDOUR_UI::set_solo_model (SoloModel model)
209 {
210         const char* action = 0;
211
212         switch (model) {
213         case SoloBus:
214                 action = X_("SoloViaBus");
215                 break;
216                 
217         case InverseMute:
218                 action = X_("SoloInPlace");
219                 break;
220         default:
221                 fatal << string_compose (_("programming error: unknown solo model in ARDOUR_UI::set_solo_model: %1"), model) << endmsg;
222                 /*NOTREACHED*/
223         }
224
225         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
226
227         if (act) {
228                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
229
230                 if (ract && ract->get_active() && Config->get_solo_model() != model) {
231                         Config->set_solo_model (model);
232                 }
233         }
234
235 }
236
237 void
238 ARDOUR_UI::set_remote_model (RemoteModel model)
239 {
240         const char* action = 0;
241
242         switch (model) {
243         case UserOrdered:
244                 action = X_("RemoteUserDefined");
245                 break;
246         case MixerOrdered:
247                 action = X_("RemoteMixerDefined");
248                 break;
249         case EditorOrdered:
250                 action = X_("RemoteEditorDefined");
251                 break;
252
253         default:
254                 fatal << string_compose (_("programming error: unknown remote model in ARDOUR_UI::set_remote_model: %1"), model) << endmsg;
255                 /*NOTREACHED*/
256         }
257
258         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
259
260         if (act) {
261                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
262
263                 if (ract && ract->get_active() && Config->get_remote_model() != model) {
264                         Config->set_remote_model (model);
265                 }
266         }
267
268 }
269
270 void
271 ARDOUR_UI::set_monitor_model (MonitorModel model)
272 {
273         const char* action = 0;
274
275         switch (model) {
276         case HardwareMonitoring:
277                 action = X_("UseHardwareMonitoring");
278                 break;
279                 
280         case SoftwareMonitoring:
281                 action = X_("UseSoftwareMonitoring");
282                 break;
283         case ExternalMonitoring:
284                 action = X_("UseExternalMonitoring");
285                 break;
286
287         default:
288                 fatal << string_compose (_("programming error: unknown monitor model in ARDOUR_UI::set_monitor_model: %1"), model) << endmsg;
289                 /*NOTREACHED*/
290         }
291
292         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
293
294         if (act) {
295                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
296
297                 if (ract && ract->get_active() && Config->get_monitoring_model() != model) {
298                         Config->set_monitoring_model (model);
299                 }
300         }
301
302 }
303
304 void
305 ARDOUR_UI::set_denormal_model (DenormalModel model)
306 {
307         const char* action = 0;
308
309         switch (model) {
310         case DenormalNone:
311                 action = X_("DenormalNone");
312                 break;
313
314         case DenormalFTZ:
315                 action = X_("DenormalFTZ");
316                 break;
317                 
318         case DenormalDAZ:
319                 action = X_("DenormalDAZ");
320                 break;
321
322         case DenormalFTZDAZ:
323                 action = X_("DenormalFTZDAZ");
324                 break;
325
326         default:
327                 fatal << string_compose (_("programming error: unknown denormal model in ARDOUR_UI::set_denormal_model: %1"), model) << endmsg;
328                 /*NOTREACHED*/
329         }
330
331         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
332
333         if (act) {
334                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
335
336                 if (ract && ract->get_active() && Config->get_denormal_model() != model) {
337                         Config->set_denormal_model (model);
338                 }
339         }
340
341 }
342
343 void
344 ARDOUR_UI::toggle_auto_input ()
345 {
346         ActionManager::toggle_config_state ("Transport", "ToggleAutoInput", &Configuration::set_auto_input, &Configuration::get_auto_input);
347 }
348
349 void
350 ARDOUR_UI::toggle_auto_play ()
351 {
352         ActionManager::toggle_config_state ("Transport", "ToggleAutoPlay", &Configuration::set_auto_play, &Configuration::get_auto_play);
353 }
354
355 void
356 ARDOUR_UI::toggle_auto_return ()
357 {
358         ActionManager::toggle_config_state ("Transport", "ToggleAutoReturn", &Configuration::set_auto_return, &Configuration::get_auto_return);
359 }
360
361 void
362 ARDOUR_UI::toggle_click ()
363 {
364         ActionManager::toggle_config_state ("Transport", "ToggleClick", &Configuration::set_clicking, &Configuration::get_clicking);
365 }
366
367 void
368 ARDOUR_UI::toggle_session_auto_loop ()
369 {
370         if (session) {
371                 if (session->get_play_loop()) {
372                         if (session->transport_rolling()) {
373                                 transport_roll();
374                         } else {
375                                 session->request_play_loop (false);
376                         }
377                 } else {
378                         session->request_play_loop (true);
379                 }
380         }
381 }
382
383 void
384 ARDOUR_UI::toggle_punch_in ()
385 {
386         ActionManager::toggle_config_state ("Transport", "TogglePunchIn", &Configuration::set_punch_in, &Configuration::get_punch_in);
387 }
388
389 void
390 ARDOUR_UI::toggle_punch_out ()
391 {
392         ActionManager::toggle_config_state ("Transport", "TogglePunchOut", &Configuration::set_punch_out, &Configuration::get_punch_out);
393 }
394
395 void
396 ARDOUR_UI::toggle_video_sync()
397 {
398         Glib::RefPtr<Action> act = ActionManager::get_action ("Transport", "ToggleVideoSync");
399         if (act) {
400                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
401                 Config->set_use_video_sync (tact->get_active());
402         }
403 }
404
405 void
406 ARDOUR_UI::toggle_editing_space()
407 {
408         Glib::RefPtr<Action> act = ActionManager::get_action ("Common", "ToggleMaximalEditor");
409         if (act) {
410                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
411                 if (tact->get_active()) {
412                         maximise_editing_space ();
413                 } else {
414                         restore_editing_space ();
415                 }
416         }
417 }
418
419 void
420 ARDOUR_UI::toggle_StopPluginsWithTransport()
421 {
422         ActionManager::toggle_config_state ("options", "StopPluginsWithTransport", &Configuration::set_plugins_stop_with_transport, &Configuration::get_plugins_stop_with_transport);
423 }
424
425 void
426 ARDOUR_UI::toggle_LatchedRecordEnable()
427 {
428         ActionManager::toggle_config_state ("options", "LatchedRecordEnable", &Configuration::set_latched_record_enable, &Configuration::get_latched_record_enable);
429 }
430
431 void
432 ARDOUR_UI::toggle_RegionEquivalentsOverlap()
433 {
434         ActionManager::toggle_config_state ("options", "RegionEquivalentsOverlap", &Configuration::set_use_overlap_equivalency, &Configuration::get_use_overlap_equivalency);
435 }
436
437 void
438 ARDOUR_UI::toggle_DoNotRunPluginsWhileRecording()
439 {
440         ActionManager::toggle_config_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::set_do_not_record_plugins, &Configuration::get_do_not_record_plugins);
441 }
442
443 void
444 ARDOUR_UI::toggle_VerifyRemoveLastCapture()
445 {
446         ActionManager::toggle_config_state ("options", "VerifyRemoveLastCapture", &Configuration::set_verify_remove_last_capture, &Configuration::get_verify_remove_last_capture);
447 }
448
449 void
450 ARDOUR_UI::toggle_PeriodicSafetyBackups()
451 {
452         ActionManager::toggle_config_state ("options", "PeriodicSafetyBackups", &Configuration::set_periodic_safety_backups, &Configuration::get_periodic_safety_backups);
453 }
454
455 void
456 ARDOUR_UI::toggle_StopRecordingOnXrun()
457 {
458         ActionManager::toggle_config_state ("options", "StopRecordingOnXrun", &Configuration::set_stop_recording_on_xrun, &Configuration::get_stop_recording_on_xrun);
459 }
460
461 void
462 ARDOUR_UI::toggle_StopTransportAtEndOfSession()
463 {
464         ActionManager::toggle_config_state ("options", "StopTransportAtEndOfSession", &Configuration::set_stop_at_session_end, &Configuration::get_stop_at_session_end);
465 }
466
467 void
468 ARDOUR_UI::toggle_GainReduceFastTransport()
469 {
470         ActionManager::toggle_config_state ("options", "GainReduceFastTransport", &Configuration::set_quieten_at_speed, &Configuration::get_quieten_at_speed);
471 }
472
473 void
474 ARDOUR_UI::toggle_LatchedSolo()
475 {
476         ActionManager::toggle_config_state ("options", "LatchedSolo", &Configuration::set_solo_latched, &Configuration::get_solo_latched);
477 }
478
479 void
480 ARDOUR_UI::toggle_ShowSoloMutes()
481 {
482         ActionManager::toggle_config_state ("options", "ShowSoloMutes", &Configuration::set_show_solo_mutes, &Configuration::get_show_solo_mutes);
483 }
484
485 void
486 ARDOUR_UI::toggle_PrimaryClockDeltaEditCursor()
487 {
488         ActionManager::toggle_config_state ("options", "PrimaryClockDeltaEditCursor", &Configuration::set_primary_clock_delta_edit_cursor, &Configuration::get_primary_clock_delta_edit_cursor);
489 }
490
491 void
492 ARDOUR_UI::toggle_SecondaryClockDeltaEditCursor()
493 {
494         ActionManager::toggle_config_state ("options", "SecondaryClockDeltaEditCursor", &Configuration::set_secondary_clock_delta_edit_cursor, &Configuration::get_secondary_clock_delta_edit_cursor);
495 }
496
497 void
498 ARDOUR_UI::mtc_port_changed ()
499 {
500         bool have_mtc;
501
502         if (session) {
503                 if (session->mtc_port()) {
504                         have_mtc = true;
505                 } else {
506                         have_mtc = false;
507                 }
508         } else {
509                 have_mtc = false;
510         }
511
512         positional_sync_strings.clear ();
513         positional_sync_strings.push_back (slave_source_to_string (None));
514         if (have_mtc) {
515                 positional_sync_strings.push_back (slave_source_to_string (MTC));
516         }
517         positional_sync_strings.push_back (slave_source_to_string (JACK));
518
519         set_popdown_strings (sync_option_combo, positional_sync_strings);
520 }
521
522 void
523 ARDOUR_UI::setup_session_options ()
524 {
525         mtc_port_changed ();
526
527         Config->ParameterChanged.connect (mem_fun (*this, &ARDOUR_UI::parameter_changed));
528 }
529
530
531 void
532 ARDOUR_UI::map_solo_model ()
533 {
534         const char* on;
535
536         if (Config->get_solo_model() == InverseMute) {
537                 on = X_("SoloInPlace");
538         } else {
539                 on = X_("SoloViaBus");
540         }
541
542         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
543         if (act) {
544                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
545
546                 if (tact && !tact->get_active()) {
547                         tact->set_active (true);
548                 }
549         }
550 }
551
552 void
553 ARDOUR_UI::map_monitor_model ()
554 {
555         const char* on = 0;
556
557         switch (Config->get_monitoring_model()) {
558         case HardwareMonitoring:
559                 on = X_("UseHardwareMonitoring");
560                 break;
561         case SoftwareMonitoring:
562                 on = X_("UseSoftwareMonitoring");
563                 break;
564         case ExternalMonitoring:
565                 on = X_("UseExternalMonitoring");
566                 break;
567         }
568
569         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
570         if (act) {
571                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
572
573                 if (tact && !tact->get_active()) {
574                         tact->set_active (true);
575                 }
576         }
577 }
578
579 void
580 ARDOUR_UI::map_denormal_protection ()
581 {
582         Glib::RefPtr<Action> act = ActionManager::get_action ("options", X_("DenormalProtection"));
583         if (act) {
584                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
585
586                 if (tact && !tact->get_active()) {
587                         tact->set_active (Config->get_denormal_protection());
588                 }
589         }
590 }
591
592 void
593 ARDOUR_UI::map_denormal_model ()
594 {
595         const char* on = 0;
596
597         switch (Config->get_denormal_model()) {
598         case DenormalNone:
599                 on = X_("DenormalNone");
600                 break;
601         case DenormalFTZ:
602                 on = X_("DenormalFTZ");
603                 break;
604         case DenormalDAZ:
605                 on = X_("DenormalDAZ");
606                 break;
607         case DenormalFTZDAZ:
608                 on = X_("DenormalFTZDAZ");
609                 break;
610         }
611
612         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
613         if (act) {
614                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
615
616                 if (tact && !tact->get_active()) {
617                         tact->set_active (true);
618                 }
619         }
620 }
621
622 void
623 ARDOUR_UI::map_remote_model ()
624 {
625         const char* on = 0;
626
627         switch (Config->get_remote_model()) {
628         case UserOrdered:
629                 on = X_("RemoteUserDefined");
630                 break;
631         case MixerOrdered:
632                 on = X_("RemoteMixerDefined");
633                 break;
634         case EditorOrdered:
635                 on = X_("RemoteEditorDefined");
636                 break;
637         }
638
639         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
640         if (act) {
641                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
642
643                 if (tact && !tact->get_active()) {
644                         tact->set_active (true);
645                 }
646         }
647 }
648
649 void
650 ARDOUR_UI::map_file_header_format ()
651 {
652         const char* action = 0;
653
654         switch (Config->get_native_file_header_format()) {
655         case BWF:
656                 action = X_("FileHeaderFormatBWF");
657                 break;
658
659         case WAVE:
660                 action = X_("FileHeaderFormatWAVE");
661                 break;
662
663         case WAVE64:
664                 action = X_("FileHeaderFormatWAVE64");
665                 break;
666
667         case iXML:
668                 action = X_("FileHeaderFormatiXML");
669                 break;
670
671         case RF64:
672                 action = X_("FileHeaderFormatRF64");
673                 break;
674
675         case CAF:
676                 action = X_("FileHeaderFormatCAF");
677                 break;
678
679         default:
680                 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"), 
681                                          Config->get_native_file_header_format()) << endmsg;
682                 /*NOTREACHED*/
683         }
684
685
686         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
687
688         if (act) {
689                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
690
691                 if (tact && !tact->get_active()) {
692                         tact->set_active (true);
693                 }
694         }
695 }
696
697 void
698 ARDOUR_UI::map_file_data_format ()
699 {
700         const char* action = 0;
701
702         switch (Config->get_native_file_data_format()) {
703         case FormatFloat:
704                 action = X_("FileDataFormatFloat");
705                 break;
706
707         case FormatInt24:
708                 action = X_("FileDataFormat24bit");
709                 break;
710
711         case FormatInt16:
712                 action = X_("FileDataFormat16bit");
713                 break;
714
715         default:
716                 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"), 
717                                          Config->get_native_file_data_format()) << endmsg;
718                 /*NOTREACHED*/
719         }
720
721
722         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
723
724         if (act) {
725                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
726
727                 if (tact && !tact->get_active()) {
728                         tact->set_active (true);
729                 }
730         }
731 }
732
733 void
734 ARDOUR_UI::map_input_auto_connect ()
735 {
736         const char* on;
737
738         if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
739                 on = "InputAutoConnectManual";
740         } else {
741                 on = "InputAutoConnectPhysical";
742         }
743
744         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
745         if (act) {
746                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
747
748                 if (tact && !tact->get_active()) {
749                         tact->set_active (true);
750                 }
751         }
752 }
753
754 void
755 ARDOUR_UI::map_output_auto_connect ()
756 {
757         const char* on;
758
759         if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
760                 on = "OutputAutoConnectManual";
761         } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
762                 on = "OutputAutoConnectPhysical";
763         } else {
764                 on = "OutputAutoConnectMaster";
765         }
766
767         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
768         if (act) {
769                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
770                 
771                 if (tact && !tact->get_active()) {
772                         tact->set_active (true);
773                 }
774         }
775 }
776
777 void
778 ARDOUR_UI::map_meter_falloff ()
779 {
780         const char* action = X_("MeterFalloffMedium");
781
782         float val = Config->get_meter_falloff ();
783         MeterFalloff code = meter_falloff_from_float(val);
784
785         switch (code) {
786         case MeterFalloffOff:
787                 action = X_("MeterFalloffOff");
788                 break;
789         case MeterFalloffSlowest:
790                 action = X_("MeterFalloffSlowest");
791                 break;
792         case MeterFalloffSlow:
793                 action = X_("MeterFalloffSlow");
794                 break;
795         case MeterFalloffMedium:
796                 action = X_("MeterFalloffMedium");
797                 break;
798         case MeterFalloffFast:
799                 action = X_("MeterFalloffFast");
800                 break;
801         case MeterFalloffFaster:
802                 action = X_("MeterFalloffFaster");
803                 break;
804         case MeterFalloffFastest:
805                 action = X_("MeterFalloffFastest");
806                 break;
807         }
808
809         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
810
811         if (act) {
812                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
813                 if (ract && !ract->get_active()) {
814                         ract->set_active (true);
815                 }
816         }
817 }
818
819 void
820 ARDOUR_UI::map_meter_hold ()
821 {
822         const char* action = X_("MeterHoldMedium");
823
824         /* XXX hack alert. Fix this. Please */
825
826         float val = Config->get_meter_hold ();
827         MeterHold code = (MeterHold) (int) (floor (val));
828
829         switch (code) {
830         case MeterHoldOff:
831                 action = X_("MeterHoldOff");
832                 break;
833         case MeterHoldShort:
834                 action = X_("MeterHoldShort");
835                 break;
836         case MeterHoldMedium:
837                 action = X_("MeterHoldMedium");
838                 break;
839         case MeterHoldLong:
840                 action = X_("MeterHoldLong");
841                 break;
842         }
843
844         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
845
846         if (act) {
847                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
848                 if (ract && !ract->get_active()) {
849                         ract->set_active (true);
850                 }
851         }
852 }
853
854 void 
855 ARDOUR_UI::set_meter_hold (MeterHold val)
856 {
857         const char* action = 0;
858         float fval;
859
860         fval = meter_hold_to_float (val);
861
862         switch (val) {
863         case MeterHoldOff:
864                 action = X_("MeterHoldOff");
865                 break;
866         case MeterHoldShort:
867                 action = X_("MeterHoldShort");
868                 break;
869         case MeterHoldMedium:
870                 action = X_("MeterHoldMedium");
871                 break;
872         case MeterHoldLong:
873                 action = X_("MeterHoldLong");
874                 break;
875         }
876
877         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
878         
879         if (act) {
880                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
881                 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
882                         Config->set_meter_hold (fval);
883                 }
884         }
885 }
886
887 void
888 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
889 {
890         const char* action = 0;
891         float fval;
892
893         fval = meter_falloff_to_float (val);
894
895         switch (val) {
896         case MeterFalloffOff:
897                 action = X_("MeterFalloffOff");
898                 break;
899         case MeterFalloffSlowest:
900                 action = X_("MeterFalloffSlowest");
901                 break;
902         case MeterFalloffSlow:
903                 action = X_("MeterFalloffSlow");
904                 break;
905         case MeterFalloffMedium:
906                 action = X_("MeterFalloffMedium");
907                 break;
908         case MeterFalloffFast:
909                 action = X_("MeterFalloffFast");
910                 break;
911         case MeterFalloffFaster:
912                 action = X_("MeterFalloffFaster");
913                 break;
914         case MeterFalloffFastest:
915                 action = X_("MeterFalloffFastest");
916                 break;
917         }
918
919         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
920
921         if (act) {
922                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
923                 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
924                         Config->set_meter_falloff (fval);
925                 }
926         }
927 }
928
929 void
930 ARDOUR_UI::parameter_changed (const char* parameter_name)
931 {
932         ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), parameter_name));
933
934 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
935         
936         if (PARAM_IS ("slave-source")) {
937
938                 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
939                 
940                 switch (Config->get_slave_source()) {
941                 case None:
942                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
943                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
944                         break;
945
946                 default:
947                         /* XXX need to make auto-play is off as well as insensitive */
948                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
949                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
950                         break;
951                 }
952
953         } else if (PARAM_IS ("send-mtc")) {
954
955                 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
956
957         } else if (PARAM_IS ("send-mmc")) {
958
959                 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
960
961         } else if (PARAM_IS ("use-osc")) {
962
963 #ifdef HAVE_LIBLO
964                 if (Config->get_use_osc()) {
965                         osc->start ();
966                 } else {
967                         osc->stop ();
968                 }
969 #endif
970
971                 ActionManager::map_some_state ("options", "UseOSC", &Configuration::get_use_osc);
972                 
973         } else if (PARAM_IS ("mmc-control")) {
974                 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
975         } else if (PARAM_IS ("midi-feedback")) {
976                 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
977         } else if (PARAM_IS ("do-not-record-plugins")) {
978                 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
979         } else if (PARAM_IS ("latched-record-enable")) {
980                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
981         } else if (PARAM_IS ("solo-latched")) {
982                 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
983         } else if (PARAM_IS ("show-solo-mutes")) {
984                 ActionManager::map_some_state ("options", "ShowSoloMutes", &Configuration::get_show_solo_mutes);
985         } else if (PARAM_IS ("solo-model")) {
986                 map_solo_model ();
987         } else if (PARAM_IS ("auto-play")) {
988                 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
989         } else if (PARAM_IS ("auto-return")) {
990                 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
991         } else if (PARAM_IS ("auto-input")) {
992                 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
993         } else if (PARAM_IS ("punch-out")) {
994                 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
995         } else if (PARAM_IS ("punch-in")) {
996                 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
997         } else if (PARAM_IS ("clicking")) {
998                 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
999         } else if (PARAM_IS ("jack-time-master")) {
1000                 ActionManager::map_some_state ("Transport",  "ToggleTimeMaster", &Configuration::get_jack_time_master);
1001         } else if (PARAM_IS ("plugins-stop-with-transport")) {
1002                 ActionManager::map_some_state ("options",  "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
1003         } else if (PARAM_IS ("latched-record-enable")) {
1004                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
1005         } else if (PARAM_IS ("verify-remove-last-capture")) {
1006                 ActionManager::map_some_state ("options",  "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
1007         } else if (PARAM_IS ("periodic-safety-backups")) {
1008                 ActionManager::map_some_state ("options",  "PeriodicSafetyBackups", &Configuration::get_periodic_safety_backups);
1009         } else if (PARAM_IS ("stop-recording-on-xrun")) {
1010                 ActionManager::map_some_state ("options",  "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
1011         } else if (PARAM_IS ("stop-at-session-end")) {
1012                 ActionManager::map_some_state ("options",  "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
1013         } else if (PARAM_IS ("monitoring-model")) {
1014                 map_monitor_model ();
1015         } else if (PARAM_IS ("denormal-model")) {
1016                 map_denormal_model ();
1017         } else if (PARAM_IS ("denormal-protection")) {
1018                 map_denormal_protection ();
1019         } else if (PARAM_IS ("remote-model")) {
1020                 map_remote_model ();
1021         } else if (PARAM_IS ("use-video-sync")) {
1022                 ActionManager::map_some_state ("Transport",  "ToggleVideoSync", &Configuration::get_use_video_sync);
1023         } else if (PARAM_IS ("quieten-at-speed")) {
1024                 ActionManager::map_some_state ("options",  "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
1025         } else if (PARAM_IS ("shuttle-behaviour")) {
1026
1027                 switch (Config->get_shuttle_behaviour ()) {
1028                 case Sprung:
1029                         shuttle_style_button.set_active_text (_("sprung"));
1030                         shuttle_fract = 0.0;
1031                         shuttle_box.queue_draw ();
1032                         if (session) {
1033                                 if (session->transport_rolling()) {
1034                                         shuttle_fract = SHUTTLE_FRACT_SPEED1;
1035                                         session->request_transport_speed (1.0);
1036                                 }
1037                         }
1038                         break;
1039                 case Wheel:
1040                         shuttle_style_button.set_active_text (_("wheel"));
1041                         break;
1042                 }
1043
1044         } else if (PARAM_IS ("shuttle-units")) {
1045                 
1046                 switch (Config->get_shuttle_units()) {
1047                 case Percentage:
1048                         shuttle_units_button.set_label("% ");
1049                         break;
1050                 case Semitones:
1051                         shuttle_units_button.set_label(_("ST"));
1052                         break;
1053                 }
1054         } else if (PARAM_IS ("input-auto-connect")) {
1055                 map_input_auto_connect ();
1056         } else if (PARAM_IS ("output-auto-connect")) {
1057                 map_output_auto_connect ();
1058         } else if (PARAM_IS ("native-file-header-format")) {
1059                 map_file_header_format ();
1060         } else if (PARAM_IS ("native-file-data-format")) {
1061                 map_file_data_format ();
1062         } else if (PARAM_IS ("meter-hold")) {
1063                 map_meter_hold ();
1064         } else if (PARAM_IS ("meter-falloff")) {
1065                 map_meter_falloff ();
1066         } else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
1067                 if (session) {
1068                         primary_clock.set (session->audible_frame(), true);
1069                         secondary_clock.set (session->audible_frame(), true);
1070                 } else {
1071                         primary_clock.set (0, true);
1072                         secondary_clock.set (0, true);
1073                 }
1074         } else if (PARAM_IS ("use-overlap-equivalency")) {
1075                 ActionManager::map_some_state ("options", "RegionEquivalentsOverlap", &Configuration::get_use_overlap_equivalency);
1076         } else if (PARAM_IS ("primary-clock-delta-edit-cursor")) {
1077                 ActionManager::map_some_state ("options",  "PrimaryClockDeltaEditCursor", &Configuration::get_primary_clock_delta_edit_cursor);
1078         } else if (PARAM_IS ("secondary-clock-delta-edit-cursor")) {
1079                 ActionManager::map_some_state ("options",  "SecondaryClockDeltaEditCursor", &Configuration::get_secondary_clock_delta_edit_cursor);
1080         } 
1081                            
1082
1083 #undef PARAM_IS
1084 }