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