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