4a6bef6b5f33be338561089f80568ba8f2c4ef0c
[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_model ()
581 {
582         const char* on = 0;
583
584         switch (Config->get_denormal_model()) {
585         case DenormalNone:
586                 on = X_("DenormalNone");
587                 break;
588         case DenormalFTZ:
589                 on = X_("DenormalFTZ");
590                 break;
591         case DenormalDAZ:
592                 on = X_("DenormalDAZ");
593                 break;
594         case DenormalFTZDAZ:
595                 on = X_("DenormalFTZDAZ");
596                 break;
597         }
598
599         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
600         if (act) {
601                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
602
603                 if (tact && !tact->get_active()) {
604                         tact->set_active (true);
605                 }
606         }
607 }
608
609 void
610 ARDOUR_UI::map_remote_model ()
611 {
612         const char* on = 0;
613
614         switch (Config->get_remote_model()) {
615         case UserOrdered:
616                 on = X_("RemoteUserDefined");
617                 break;
618         case MixerOrdered:
619                 on = X_("RemoteMixerDefined");
620                 break;
621         case EditorOrdered:
622                 on = X_("RemoteEditorDefined");
623                 break;
624         }
625
626         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
627         if (act) {
628                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
629
630                 if (tact && !tact->get_active()) {
631                         tact->set_active (true);
632                 }
633         }
634 }
635
636 void
637 ARDOUR_UI::map_file_header_format ()
638 {
639         const char* action = 0;
640
641         switch (Config->get_native_file_header_format()) {
642         case BWF:
643                 action = X_("FileHeaderFormatBWF");
644                 break;
645
646         case WAVE:
647                 action = X_("FileHeaderFormatWAVE");
648                 break;
649
650         case WAVE64:
651                 action = X_("FileHeaderFormatWAVE64");
652                 break;
653
654         case iXML:
655                 action = X_("FileHeaderFormatiXML");
656                 break;
657
658         case RF64:
659                 action = X_("FileHeaderFormatRF64");
660                 break;
661
662         case CAF:
663                 action = X_("FileHeaderFormatCAF");
664                 break;
665
666         default:
667                 fatal << string_compose (_("programming error: unknown file header format passed to ARDOUR_UI::map_file_data_format: %1"), 
668                                          Config->get_native_file_header_format()) << endmsg;
669                 /*NOTREACHED*/
670         }
671
672
673         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
674
675         if (act) {
676                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
677
678                 if (tact && !tact->get_active()) {
679                         tact->set_active (true);
680                 }
681         }
682 }
683
684 void
685 ARDOUR_UI::map_file_data_format ()
686 {
687         const char* action = 0;
688
689         switch (Config->get_native_file_data_format()) {
690         case FormatFloat:
691                 action = X_("FileDataFormatFloat");
692                 break;
693
694         case FormatInt24:
695                 action = X_("FileDataFormat24bit");
696                 break;
697
698         case FormatInt16:
699                 action = X_("FileDataFormat16bit");
700                 break;
701
702         default:
703                 fatal << string_compose (_("programming error: unknown file data format passed to ARDOUR_UI::map_file_data_format: %1"), 
704                                          Config->get_native_file_data_format()) << endmsg;
705                 /*NOTREACHED*/
706         }
707
708
709         Glib::RefPtr<Action> act = ActionManager::get_action ("options", action);
710
711         if (act) {
712                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
713
714                 if (tact && !tact->get_active()) {
715                         tact->set_active (true);
716                 }
717         }
718 }
719
720 void
721 ARDOUR_UI::map_input_auto_connect ()
722 {
723         const char* on;
724
725         if (Config->get_input_auto_connect() == (AutoConnectOption) 0) {
726                 on = "InputAutoConnectManual";
727         } else {
728                 on = "InputAutoConnectPhysical";
729         }
730
731         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
732         if (act) {
733                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
734
735                 if (tact && !tact->get_active()) {
736                         tact->set_active (true);
737                 }
738         }
739 }
740
741 void
742 ARDOUR_UI::map_output_auto_connect ()
743 {
744         const char* on;
745
746         if (Config->get_output_auto_connect() == (AutoConnectOption) 0) {
747                 on = "OutputAutoConnectManual";
748         } else if (Config->get_output_auto_connect() == AutoConnectPhysical) {
749                 on = "OutputAutoConnectPhysical";
750         } else {
751                 on = "OutputAutoConnectMaster";
752         }
753
754         Glib::RefPtr<Action> act = ActionManager::get_action ("options", on);
755         if (act) {
756                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
757                 
758                 if (tact && !tact->get_active()) {
759                         tact->set_active (true);
760                 }
761         }
762 }
763
764 void
765 ARDOUR_UI::map_meter_falloff ()
766 {
767         const char* action = X_("MeterFalloffMedium");
768
769         float val = Config->get_meter_falloff ();
770         MeterFalloff code = meter_falloff_from_float(val);
771
772         switch (code) {
773         case MeterFalloffOff:
774                 action = X_("MeterFalloffOff");
775                 break;
776         case MeterFalloffSlowest:
777                 action = X_("MeterFalloffSlowest");
778                 break;
779         case MeterFalloffSlow:
780                 action = X_("MeterFalloffSlow");
781                 break;
782         case MeterFalloffMedium:
783                 action = X_("MeterFalloffMedium");
784                 break;
785         case MeterFalloffFast:
786                 action = X_("MeterFalloffFast");
787                 break;
788         case MeterFalloffFaster:
789                 action = X_("MeterFalloffFaster");
790                 break;
791         case MeterFalloffFastest:
792                 action = X_("MeterFalloffFastest");
793                 break;
794         }
795
796         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
797
798         if (act) {
799                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
800                 if (ract && !ract->get_active()) {
801                         ract->set_active (true);
802                 }
803         }
804 }
805
806 void
807 ARDOUR_UI::map_meter_hold ()
808 {
809         const char* action = X_("MeterHoldMedium");
810
811         /* XXX hack alert. Fix this. Please */
812
813         float val = Config->get_meter_hold ();
814         MeterHold code = (MeterHold) (int) (floor (val));
815
816         switch (code) {
817         case MeterHoldOff:
818                 action = X_("MeterHoldOff");
819                 break;
820         case MeterHoldShort:
821                 action = X_("MeterHoldShort");
822                 break;
823         case MeterHoldMedium:
824                 action = X_("MeterHoldMedium");
825                 break;
826         case MeterHoldLong:
827                 action = X_("MeterHoldLong");
828                 break;
829         }
830
831         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
832
833         if (act) {
834                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
835                 if (ract && !ract->get_active()) {
836                         ract->set_active (true);
837                 }
838         }
839 }
840
841 void 
842 ARDOUR_UI::set_meter_hold (MeterHold val)
843 {
844         const char* action = 0;
845         float fval;
846
847         fval = meter_hold_to_float (val);
848
849         switch (val) {
850         case MeterHoldOff:
851                 action = X_("MeterHoldOff");
852                 break;
853         case MeterHoldShort:
854                 action = X_("MeterHoldShort");
855                 break;
856         case MeterHoldMedium:
857                 action = X_("MeterHoldMedium");
858                 break;
859         case MeterHoldLong:
860                 action = X_("MeterHoldLong");
861                 break;
862         }
863
864         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
865         
866         if (act) {
867                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
868                 if (ract && ract->get_active() && Config->get_meter_hold() != fval) {
869                         Config->set_meter_hold (fval);
870                 }
871         }
872 }
873
874 void
875 ARDOUR_UI::set_meter_falloff (MeterFalloff val)
876 {
877         const char* action = 0;
878         float fval;
879
880         fval = meter_falloff_to_float (val);
881
882         switch (val) {
883         case MeterFalloffOff:
884                 action = X_("MeterFalloffOff");
885                 break;
886         case MeterFalloffSlowest:
887                 action = X_("MeterFalloffSlowest");
888                 break;
889         case MeterFalloffSlow:
890                 action = X_("MeterFalloffSlow");
891                 break;
892         case MeterFalloffMedium:
893                 action = X_("MeterFalloffMedium");
894                 break;
895         case MeterFalloffFast:
896                 action = X_("MeterFalloffFast");
897                 break;
898         case MeterFalloffFaster:
899                 action = X_("MeterFalloffFaster");
900                 break;
901         case MeterFalloffFastest:
902                 action = X_("MeterFalloffFastest");
903                 break;
904         }
905
906         Glib::RefPtr<Action> act = ActionManager::get_action (X_("options"), action);
907
908         if (act) {
909                 Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic(act);
910                 if (ract && ract->get_active() && Config->get_meter_falloff () != fval) {
911                         Config->set_meter_falloff (fval);
912                 }
913         }
914 }
915
916 void
917 ARDOUR_UI::parameter_changed (const char* parameter_name)
918 {
919         ENSURE_GUI_THREAD (bind (mem_fun (*this, &ARDOUR_UI::parameter_changed), parameter_name));
920
921 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
922         
923         if (PARAM_IS ("slave-source")) {
924
925                 sync_option_combo.set_active_text (slave_source_to_string (Config->get_slave_source()));
926                 
927                 switch (Config->get_slave_source()) {
928                 case None:
929                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (true);
930                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (true);
931                         break;
932
933                 default:
934                         /* XXX need to make auto-play is off as well as insensitive */
935                         ActionManager::get_action ("Transport", "ToggleAutoPlay")->set_sensitive (false);
936                         ActionManager::get_action ("Transport", "ToggleAutoReturn")->set_sensitive (false);
937                         break;
938                 }
939
940         } else if (PARAM_IS ("send-mtc")) {
941
942                 ActionManager::map_some_state ("options", "SendMTC", &Configuration::get_send_mtc);
943
944         } else if (PARAM_IS ("send-mmc")) {
945
946                 ActionManager::map_some_state ("options", "SendMMC", &Configuration::get_send_mmc);
947
948         } else if (PARAM_IS ("use-osc")) {
949
950 #ifdef HAVE_LIBLO
951                 if (Config->get_use_osc()) {
952                         osc->start ();
953                 } else {
954                         osc->stop ();
955                 }
956 #endif
957
958                 ActionManager::map_some_state ("options", "UseOSC", &Configuration::get_use_osc);
959                 
960         } else if (PARAM_IS ("mmc-control")) {
961                 ActionManager::map_some_state ("options", "UseMMC", &Configuration::get_mmc_control);
962         } else if (PARAM_IS ("midi-feedback")) {
963                 ActionManager::map_some_state ("options", "SendMIDIfeedback", &Configuration::get_midi_feedback);
964         } else if (PARAM_IS ("do-not-record-plugins")) {
965                 ActionManager::map_some_state ("options", "DoNotRunPluginsWhileRecording", &Configuration::get_do_not_record_plugins);
966         } else if (PARAM_IS ("latched-record-enable")) {
967                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
968         } else if (PARAM_IS ("solo-latched")) {
969                 ActionManager::map_some_state ("options", "LatchedSolo", &Configuration::get_solo_latched);
970         } else if (PARAM_IS ("show-solo-mutes")) {
971                 ActionManager::map_some_state ("options", "ShowSoloMutes", &Configuration::get_show_solo_mutes);
972         } else if (PARAM_IS ("solo-model")) {
973                 map_solo_model ();
974         } else if (PARAM_IS ("auto-play")) {
975                 ActionManager::map_some_state ("Transport", "ToggleAutoPlay", &Configuration::get_auto_play);
976         } else if (PARAM_IS ("auto-return")) {
977                 ActionManager::map_some_state ("Transport", "ToggleAutoReturn", &Configuration::get_auto_return);
978         } else if (PARAM_IS ("auto-input")) {
979                 ActionManager::map_some_state ("Transport", "ToggleAutoInput", &Configuration::get_auto_input);
980         } else if (PARAM_IS ("punch-out")) {
981                 ActionManager::map_some_state ("Transport", "TogglePunchOut", &Configuration::get_punch_out);
982         } else if (PARAM_IS ("punch-in")) {
983                 ActionManager::map_some_state ("Transport", "TogglePunchIn", &Configuration::get_punch_in);
984         } else if (PARAM_IS ("clicking")) {
985                 ActionManager::map_some_state ("Transport", "ToggleClick", &Configuration::get_clicking);
986         } else if (PARAM_IS ("jack-time-master")) {
987                 ActionManager::map_some_state ("Transport",  "ToggleTimeMaster", &Configuration::get_jack_time_master);
988         } else if (PARAM_IS ("plugins-stop-with-transport")) {
989                 ActionManager::map_some_state ("options",  "StopPluginsWithTransport", &Configuration::get_plugins_stop_with_transport);
990         } else if (PARAM_IS ("latched-record-enable")) {
991                 ActionManager::map_some_state ("options", "LatchedRecordEnable", &Configuration::get_latched_record_enable);
992         } else if (PARAM_IS ("verify-remove-last-capture")) {
993                 ActionManager::map_some_state ("options",  "VerifyRemoveLastCapture", &Configuration::get_verify_remove_last_capture);
994         } else if (PARAM_IS ("periodic-safety-backups")) {
995                 ActionManager::map_some_state ("options",  "PeriodicSafetyBackups", &Configuration::get_periodic_safety_backups);
996         } else if (PARAM_IS ("stop-recording-on-xrun")) {
997                 ActionManager::map_some_state ("options",  "StopRecordingOnXrun", &Configuration::get_stop_recording_on_xrun);
998         } else if (PARAM_IS ("stop-at-session-end")) {
999                 ActionManager::map_some_state ("options",  "StopTransportAtEndOfSession", &Configuration::get_stop_at_session_end);
1000         } else if (PARAM_IS ("monitoring-model")) {
1001                 map_monitor_model ();
1002         } else if (PARAM_IS ("denormal-model")) {
1003                 map_denormal_model ();
1004         } else if (PARAM_IS ("remote-model")) {
1005                 map_remote_model ();
1006         } else if (PARAM_IS ("use-video-sync")) {
1007                 ActionManager::map_some_state ("Transport",  "ToggleVideoSync", &Configuration::get_use_video_sync);
1008         } else if (PARAM_IS ("quieten-at-speed")) {
1009                 ActionManager::map_some_state ("options",  "GainReduceFastTransport", &Configuration::get_quieten_at_speed);
1010         } else if (PARAM_IS ("shuttle-behaviour")) {
1011
1012                 switch (Config->get_shuttle_behaviour ()) {
1013                 case Sprung:
1014                         shuttle_style_button.set_active_text (_("sprung"));
1015                         shuttle_fract = 0.0;
1016                         shuttle_box.queue_draw ();
1017                         if (session) {
1018                                 if (session->transport_rolling()) {
1019                                         shuttle_fract = SHUTTLE_FRACT_SPEED1;
1020                                         session->request_transport_speed (1.0);
1021                                 }
1022                         }
1023                         break;
1024                 case Wheel:
1025                         shuttle_style_button.set_active_text (_("wheel"));
1026                         break;
1027                 }
1028
1029         } else if (PARAM_IS ("shuttle-units")) {
1030                 
1031                 switch (Config->get_shuttle_units()) {
1032                 case Percentage:
1033                         shuttle_units_button.set_label("% ");
1034                         break;
1035                 case Semitones:
1036                         shuttle_units_button.set_label(_("ST"));
1037                         break;
1038                 }
1039         } else if (PARAM_IS ("input-auto-connect")) {
1040                 map_input_auto_connect ();
1041         } else if (PARAM_IS ("output-auto-connect")) {
1042                 map_output_auto_connect ();
1043         } else if (PARAM_IS ("native-file-header-format")) {
1044                 map_file_header_format ();
1045         } else if (PARAM_IS ("native-file-data-format")) {
1046                 map_file_data_format ();
1047         } else if (PARAM_IS ("meter-hold")) {
1048                 map_meter_hold ();
1049         } else if (PARAM_IS ("meter-falloff")) {
1050                 map_meter_falloff ();
1051         } else if (PARAM_IS ("video-pullup") || PARAM_IS ("smpte-format")) {
1052                 if (session) {
1053                         primary_clock.set (session->audible_frame(), true);
1054                         secondary_clock.set (session->audible_frame(), true);
1055                 } else {
1056                         primary_clock.set (0, true);
1057                         secondary_clock.set (0, true);
1058                 }
1059         } else if (PARAM_IS ("use-overlap-equivalency")) {
1060                 ActionManager::map_some_state ("options", "RegionEquivalentsOverlap", &Configuration::get_use_overlap_equivalency);
1061         } else if (PARAM_IS ("primary-clock-delta-edit-cursor")) {
1062                 ActionManager::map_some_state ("options",  "PrimaryClockDeltaEditCursor", &Configuration::get_primary_clock_delta_edit_cursor);
1063         } else if (PARAM_IS ("secondary-clock-delta-edit-cursor")) {
1064                 ActionManager::map_some_state ("options",  "SecondaryClockDeltaEditCursor", &Configuration::get_secondary_clock_delta_edit_cursor);
1065         } 
1066                            
1067
1068 #undef PARAM_IS
1069 }