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