a55aee62327b11442d130837454291cb84ab28bb
[ardour.git] / gtk2_ardour / editor_actions.cc
1 #include <ardour/ardour.h>
2
3 #include "utils.h"
4 #include "editor.h"
5 #include "editing.h"
6 #include "actions.h"
7 #include "ardour_ui.h"
8 #include "gui_thread.h"
9 #include "i18n.h"
10
11 using namespace Gtk;
12 using namespace Glib;
13 using namespace std;
14 using namespace sigc;
15 using namespace ARDOUR;
16 using namespace PBD;
17 using namespace Editing;
18
19 void
20 Editor::register_actions ()
21 {
22         RefPtr<Action> act;
23
24         editor_actions = ActionGroup::create (X_("Editor"));
25         
26         /* non-operative menu items for menu bar */
27
28         ActionManager::register_action (editor_actions, X_("Edit"), _("Edit"));
29         ActionManager::register_action (editor_actions, X_("EditSelectRegionOptions"), _("Select regions"));
30         ActionManager::register_action (editor_actions, X_("EditSelectRangeOptions"), _("Select range operations"));
31         ActionManager::register_action (editor_actions, X_("EditCursorMovementOptions"), _("Move edit cursor"));
32         ActionManager::register_action (editor_actions, X_("RegionEditOps"), _("Region operations"));
33         ActionManager::register_action (editor_actions, X_("Tools"), _("Tools"));
34         ActionManager::register_action (editor_actions, X_("View"), _("View"));
35         ActionManager::register_action (editor_actions, X_("ZoomFocus"), _("ZoomFocus"));
36         ActionManager::register_action (editor_actions, X_("MeterHold"), _("Meter hold"));
37         ActionManager::register_action (editor_actions, X_("MeterFalloff"), _("Meter falloff"));
38         ActionManager::register_action (editor_actions, X_("Solo"), _("Solo"));
39         ActionManager::register_action (editor_actions, X_("Crossfades"), _("Crossfades"));
40         ActionManager::register_action (editor_actions, X_("Monitoring"), _("Monitoring"));
41         ActionManager::register_action (editor_actions, X_("Autoconnect"), _("Autoconnect"));
42         ActionManager::register_action (editor_actions, X_("Layering"), _("Layering"));
43         ActionManager::register_action (editor_actions, X_("Timecode"), _("Timecode fps"));
44         ActionManager::register_action (editor_actions, X_("Pullup"), _("Pullup / Pulldown"));
45         ActionManager::register_action (editor_actions, X_("addExistingAudioFiles"), _("Add Existing Audio"));
46
47         /* add named actions for the editor */
48
49
50         act = ActionManager::register_toggle_action (editor_actions, "show-editor-mixer", _("Show Editor Mixer"), mem_fun (*this, &Editor::editor_mixer_button_toggled));
51         ActionManager::session_sensitive_actions.push_back (act);
52
53         RadioAction::Group crossfade_model_group;
54
55         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesFull", _("Span Entire Overlap"), bind (mem_fun(*this, &Editor::set_crossfade_model), FullCrossfade));
56         ActionManager::session_sensitive_actions.push_back (act);
57         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesShort", _("Short"), bind (mem_fun(*this, &Editor::set_crossfade_model), ShortCrossfade));
58         ActionManager::session_sensitive_actions.push_back (act);
59
60         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-active", _("Active"), mem_fun(*this, &Editor::toggle_xfades_active));
61         ActionManager::session_sensitive_actions.push_back (act);
62         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-visible", _("Visible"), mem_fun(*this, &Editor::toggle_xfade_visibility));
63         ActionManager::session_sensitive_actions.push_back (act);
64         act = ActionManager::register_toggle_action (editor_actions, "toggle-auto-xfades", _("Created Automatically"), mem_fun(*this, &Editor::toggle_auto_xfade));
65         ActionManager::session_sensitive_actions.push_back (act);
66
67         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-start", _("Playhead to Next Region Start"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (Start)));
68         ActionManager::session_sensitive_actions.push_back (act);
69         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-end", _("Playhead to Next Region End"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (End)));
70         ActionManager::session_sensitive_actions.push_back (act);
71         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-sync", _("Playhead to Next Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (SyncPoint)));
72         ActionManager::session_sensitive_actions.push_back (act);
73
74         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-start", _("Playhead to Previous Region Start"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (Start)));
75         ActionManager::session_sensitive_actions.push_back (act);
76         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-end", _("Playhead to Previous Region End"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (End)));
77         ActionManager::session_sensitive_actions.push_back (act);
78         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-sync", _("Playhead to Previous Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (SyncPoint)));
79         ActionManager::session_sensitive_actions.push_back (act);
80
81         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-start", _("Edit Cursor to Next Region Start"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), edit_cursor, RegionPoint (Start)));
82         ActionManager::session_sensitive_actions.push_back (act);
83         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-end", _("Edit Cursor to Next Region End"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), edit_cursor, RegionPoint (End)));
84         ActionManager::session_sensitive_actions.push_back (act);
85         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-sync", _("Edit Cursor to Next Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), edit_cursor, RegionPoint (SyncPoint)));
86         ActionManager::session_sensitive_actions.push_back (act);
87
88         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-start", _("Edit Cursor to Previous Region Start"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), edit_cursor, RegionPoint (Start)));
89         ActionManager::session_sensitive_actions.push_back (act);
90         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-end", _("Edit Cursor to Previous Region End"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), edit_cursor, RegionPoint (End)));
91         ActionManager::session_sensitive_actions.push_back (act);
92         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-sync", _("Edit Cursor to Previous Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), edit_cursor, RegionPoint (SyncPoint)));
93         ActionManager::session_sensitive_actions.push_back (act);
94
95         act = ActionManager::register_action (editor_actions, "playhead-to-range-start", _("Playhead to Range Start"), bind (mem_fun(*this, &Editor::cursor_to_selection_start), playhead_cursor));
96         ActionManager::session_sensitive_actions.push_back (act);
97         act = ActionManager::register_action (editor_actions, "playhead-to-range-end", _("Playhead to Range End"), bind (mem_fun(*this, &Editor::cursor_to_selection_end), playhead_cursor));
98         ActionManager::session_sensitive_actions.push_back (act);
99
100         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-start", _("Edit Cursor to Range Start"), bind (mem_fun(*this, &Editor::cursor_to_selection_start), edit_cursor));
101         ActionManager::session_sensitive_actions.push_back (act);
102         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-end", _("Edit Cursor to Range End"), bind (mem_fun(*this, &Editor::cursor_to_selection_end), edit_cursor));
103         ActionManager::session_sensitive_actions.push_back (act);
104
105         act = ActionManager::register_action (editor_actions, "select-all", _("select all"), bind (mem_fun(*this, &Editor::select_all), Selection::Set));
106         ActionManager::session_sensitive_actions.push_back (act);
107         act = ActionManager::register_action (editor_actions, "select-all-after-edit-cursor", _("Select All After Edit Cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true));
108         ActionManager::session_sensitive_actions.push_back (act);
109         act = ActionManager::register_action (editor_actions, "select-all-before-edit-cursor", _("Select All Before Edit Cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false));
110         ActionManager::session_sensitive_actions.push_back (act);
111
112         act = ActionManager::register_action (editor_actions, "select-all-after-playhead", _("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true));
113         ActionManager::session_sensitive_actions.push_back (act);
114         act = ActionManager::register_action (editor_actions, "select-all-before-playhead", _("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false));
115         ActionManager::session_sensitive_actions.push_back (act);
116         act = ActionManager::register_action (editor_actions, "select-all-between-cursors", _("Select All Between Cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor));
117         ActionManager::session_sensitive_actions.push_back (act);
118
119         act = ActionManager::register_action (editor_actions, "select-all-in-punch-range", _("Select All in Punch Range"), mem_fun(*this, &Editor::select_all_selectables_using_punch));
120         ActionManager::session_sensitive_actions.push_back (act);
121         act = ActionManager::register_action (editor_actions, "select-all-in-loop-range", _("Select All in Loop Range"), mem_fun(*this, &Editor::select_all_selectables_using_loop));
122         ActionManager::session_sensitive_actions.push_back (act);
123
124         act = ActionManager::register_action (editor_actions, "jump-forward-to-mark", _("Jump Forward to Mark"), mem_fun(*this, &Editor::jump_forward_to_mark));
125         ActionManager::session_sensitive_actions.push_back (act);
126         act = ActionManager::register_action (editor_actions, "jump-backward-to-mark", _("Jump Backward to Mark"), mem_fun(*this, &Editor::jump_backward_to_mark));
127         ActionManager::session_sensitive_actions.push_back (act);
128         act = ActionManager::register_action (editor_actions, "add-location-from-playhead", _("Add Location from Playhead"), mem_fun(*this, &Editor::add_location_from_playhead_cursor));
129         ActionManager::session_sensitive_actions.push_back (act);
130
131         act = ActionManager::register_action (editor_actions, "nudge-forward", _("Nudge Forward"), bind (mem_fun(*this, &Editor::nudge_forward), false));
132         ActionManager::session_sensitive_actions.push_back (act);
133         act = ActionManager::register_action (editor_actions, "nudge-next-forward", _("Nudge Next Forward"), bind (mem_fun(*this, &Editor::nudge_forward), true));
134         ActionManager::session_sensitive_actions.push_back (act);
135         act = ActionManager::register_action (editor_actions, "nudge-backward", _("Nudge Backward"), bind (mem_fun(*this, &Editor::nudge_backward), false));
136         ActionManager::session_sensitive_actions.push_back (act);
137         act = ActionManager::register_action (editor_actions, "nudge-next-backward", _("Nudge Next Backward"), bind (mem_fun(*this, &Editor::nudge_backward), true));
138         ActionManager::session_sensitive_actions.push_back (act);
139
140         act = ActionManager::register_action (editor_actions, "temporal-zoom-out", _("Zoom Out"), bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
141         ActionManager::session_sensitive_actions.push_back (act);
142         act = ActionManager::register_action (editor_actions, "temporal-zoom-in", _("Zoom In"), bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
143         ActionManager::session_sensitive_actions.push_back (act);
144         act = ActionManager::register_action (editor_actions, "zoom-to-session", _("Zoom to Session"), mem_fun(*this, &Editor::temporal_zoom_session));
145         ActionManager::session_sensitive_actions.push_back (act);
146
147         act = ActionManager::register_action (editor_actions, "scroll-tracks-up", _("Scroll Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up));
148         ActionManager::session_sensitive_actions.push_back (act);
149         act = ActionManager::register_action (editor_actions, "scroll-tracks-down", _("Scroll Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down));
150         ActionManager::session_sensitive_actions.push_back (act);
151         act = ActionManager::register_action (editor_actions, "step-tracks-up", _("Step Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up_line));
152         ActionManager::session_sensitive_actions.push_back (act);
153         act = ActionManager::register_action (editor_actions, "step-tracks-down", _("Step Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down_line));
154         ActionManager::session_sensitive_actions.push_back (act);
155
156         act = ActionManager::register_action (editor_actions, "scroll-backward", _("Scroll Backward"), bind (mem_fun(*this, &Editor::scroll_backward), 0.8f));
157         ActionManager::session_sensitive_actions.push_back (act);
158         act = ActionManager::register_action (editor_actions, "scroll-forward", _("Scroll Forward"), bind (mem_fun(*this, &Editor::scroll_forward), 0.8f));
159         ActionManager::session_sensitive_actions.push_back (act);
160         act = ActionManager::register_action (editor_actions, "goto", _("goto"), mem_fun(*this, &Editor::goto_frame));
161         ActionManager::session_sensitive_actions.push_back (act);
162         act = ActionManager::register_action (editor_actions, "center-playhead", _("Center Playhead"), mem_fun(*this, &Editor::center_playhead));
163         ActionManager::session_sensitive_actions.push_back (act);
164         act = ActionManager::register_action (editor_actions, "center-edit-cursor", _("Center Edit Cursor"), mem_fun(*this, &Editor::center_edit_cursor));
165         ActionManager::session_sensitive_actions.push_back (act);
166         act = ActionManager::register_action (editor_actions, "playhead-forward", _("Playhead Forward"), mem_fun(*this, &Editor::playhead_forward));
167         ActionManager::session_sensitive_actions.push_back (act);
168         act = ActionManager::register_action (editor_actions, "playhead-backward", _("Playhead Backward"), mem_fun(*this, &Editor::playhead_backward));
169         ActionManager::session_sensitive_actions.push_back (act);
170         act = ActionManager::register_action (editor_actions, "playhead-to-edit", _("Playhead to Edit"), bind (mem_fun(*this, &Editor::cursor_align), true));
171         ActionManager::session_sensitive_actions.push_back (act);
172         act = ActionManager::register_action (editor_actions, "edit-to-playhead", _("Edit to Playhead"), bind (mem_fun(*this, &Editor::cursor_align), false));
173         ActionManager::session_sensitive_actions.push_back (act);
174
175         act = ActionManager::register_action (editor_actions, "align-regions-start", _("Align Regions Start"), bind (mem_fun(*this, &Editor::align), ARDOUR::Start));
176         ActionManager::session_sensitive_actions.push_back (act);
177         act = ActionManager::register_action (editor_actions, "align-regions-start-relative", _("Align Regions Start Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::Start));
178         ActionManager::session_sensitive_actions.push_back (act);
179         act = ActionManager::register_action (editor_actions, "align-regions-end", _("Align Regions End"), bind (mem_fun(*this, &Editor::align), ARDOUR::End));
180         ActionManager::session_sensitive_actions.push_back (act);
181         act = ActionManager::register_action (editor_actions, "align-regions-end-relative", _("Align Regions End Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::End));
182         ActionManager::session_sensitive_actions.push_back (act);
183
184         act = ActionManager::register_action (editor_actions, "align-regions-sync", _("Align Regions Sync"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint));
185         ActionManager::session_sensitive_actions.push_back (act);
186         act = ActionManager::register_action (editor_actions, "align-regions-sync-relative", _("Align Regions Sync Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint));
187         ActionManager::session_sensitive_actions.push_back (act);
188         
189         act = ActionManager::register_action (editor_actions, "audition-at-mouse", _("Audition at Mouse"), mem_fun(*this, &Editor::kbd_audition));
190         ActionManager::session_sensitive_actions.push_back (act);
191         act = ActionManager::register_action (editor_actions, "brush-at-mouse", _("Brush at Mouse"), mem_fun(*this, &Editor::kbd_brush));
192         ActionManager::session_sensitive_actions.push_back (act);
193         act = ActionManager::register_action (editor_actions, "set-edit-cursor", _("Set Edit Cursor"), mem_fun(*this, &Editor::kbd_set_edit_cursor));
194         ActionManager::session_sensitive_actions.push_back (act);
195         act = ActionManager::register_action (editor_actions, "mute-unmute-region", _("Mute/Unmute Region"), mem_fun(*this, &Editor::kbd_mute_unmute_region));
196         ActionManager::session_sensitive_actions.push_back (act);
197         act = ActionManager::register_action (editor_actions, "set-playhead", _("Set Playhead"), mem_fun(*this, &Editor::kbd_set_playhead_cursor));
198         ActionManager::session_sensitive_actions.push_back (act);
199         act = ActionManager::register_action (editor_actions, "split-region", _("Split Region"), mem_fun(*this, &Editor::kbd_split));
200         ActionManager::session_sensitive_actions.push_back (act);
201         act = ActionManager::register_action (editor_actions, "set-region-sync-position", _("Set Region Sync Position"), mem_fun(*this, &Editor::kbd_set_sync_position));
202         ActionManager::session_sensitive_actions.push_back (act);
203
204         undo_action = act = ActionManager::register_action (editor_actions, "undo", _("Undo"), bind (mem_fun(*this, &Editor::undo), 1U));
205         ActionManager::session_sensitive_actions.push_back (act);
206         redo_action = act = ActionManager::register_action (editor_actions, "redo", _("Redo"), bind (mem_fun(*this, &Editor::redo), 1U));
207         ActionManager::session_sensitive_actions.push_back (act);
208
209         act = ActionManager::register_action (editor_actions, "export-session", _("Export Session"), mem_fun(*this, &Editor::export_session));
210         ActionManager::session_sensitive_actions.push_back (act);
211         act = ActionManager::register_action (editor_actions, "export-range", _("Export Range"), mem_fun(*this, &Editor::export_selection));
212         ActionManager::session_sensitive_actions.push_back (act);
213
214         act = ActionManager::register_action (editor_actions, "editor-cut", _("Cut"), mem_fun(*this, &Editor::cut));
215         ActionManager::session_sensitive_actions.push_back (act);
216         /* Note: for now, editor-delete does the exact same thing as editor-cut */
217         act = ActionManager::register_action (editor_actions, "editor-delete", _("Delete"), mem_fun(*this, &Editor::cut));
218         ActionManager::session_sensitive_actions.push_back (act);
219         act = ActionManager::register_action (editor_actions, "editor-copy", _("Copy"), mem_fun(*this, &Editor::copy));
220         ActionManager::session_sensitive_actions.push_back (act);
221         act = ActionManager::register_action (editor_actions, "editor-paste", _("Paste"), mem_fun(*this, &Editor::keyboard_paste));
222         ActionManager::session_sensitive_actions.push_back (act);
223         act = ActionManager::register_action (editor_actions, "duplicate-region", _("Duplicate Region"), mem_fun(*this, &Editor::keyboard_duplicate_region));
224         ActionManager::session_sensitive_actions.push_back (act);
225         act = ActionManager::register_action (editor_actions, "duplicate-range", _("Duplicate Range"), mem_fun(*this, &Editor::keyboard_duplicate_selection));
226         ActionManager::session_sensitive_actions.push_back (act);
227         act = ActionManager::register_action (editor_actions, "insert-region", _("Insert Region"), mem_fun(*this, &Editor::keyboard_insert_region_list_selection));
228         ActionManager::session_sensitive_actions.push_back (act);
229         act = ActionManager::register_action (editor_actions, "reverse-region", _("Reverse Region"), mem_fun(*this, &Editor::reverse_region));
230         ActionManager::session_sensitive_actions.push_back (act);
231         act = ActionManager::register_action (editor_actions, "normalize-region", _("Normalize Region"), mem_fun(*this, &Editor::normalize_region));
232         ActionManager::session_sensitive_actions.push_back (act);
233         act = ActionManager::register_action (editor_actions, "crop", _("crop"), mem_fun(*this, &Editor::crop_region_to_selection));
234         ActionManager::session_sensitive_actions.push_back (act);
235         act = ActionManager::register_action (editor_actions, "insert-chunk", _("Insert Chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f));
236         ActionManager::session_sensitive_actions.push_back (act);
237
238         act = ActionManager::register_action (editor_actions, "split-at-edit-cursor", _("Split at edit cursor"), mem_fun(*this, &Editor::split_region));
239         ActionManager::edit_cursor_in_region_sensitive_actions.push_back (act);
240
241         act = ActionManager::register_action (editor_actions, "start-range", _("Start Range"), mem_fun(*this, &Editor::keyboard_selection_begin));
242         ActionManager::session_sensitive_actions.push_back (act);
243         act = ActionManager::register_action (editor_actions, "finish-range", _("Finish Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), false));
244         ActionManager::session_sensitive_actions.push_back (act);
245         act = ActionManager::register_action (editor_actions, "finish-add-range", _("Finish add Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), true));
246         ActionManager::session_sensitive_actions.push_back (act);
247
248         act = ActionManager::register_action (editor_actions, "extend-range-to-end-of-region", _("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false));
249         ActionManager::session_sensitive_actions.push_back (act);
250         act = ActionManager::register_action (editor_actions, "extend-range-to-start-of-region", _("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false));
251         ActionManager::session_sensitive_actions.push_back (act);
252
253         act = ActionManager::register_toggle_action (editor_actions, "toggle-follow-playhead", _("Follow Playhead"), (mem_fun(*this, &Editor::toggle_follow_playhead)));
254         ActionManager::session_sensitive_actions.push_back (act);
255         act = ActionManager::register_action (editor_actions, "remove-last-capture", _("Remove Last Capture"), (mem_fun(*this, &Editor::remove_last_capture)));
256         ActionManager::session_sensitive_actions.push_back (act);
257
258         Glib::RefPtr<ActionGroup> zoom_actions = ActionGroup::create (X_("Zoom"));
259         RadioAction::Group zoom_group;
260
261         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-left", _("Zoom Focus Left"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusLeft));
262         ActionManager::session_sensitive_actions.push_back (act);
263         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-right", _("Zoom Focus Right"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusRight));
264         ActionManager::session_sensitive_actions.push_back (act);
265         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-center", _("Zoom Focus Center"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusCenter));
266         ActionManager::session_sensitive_actions.push_back (act);
267         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-playhead", _("Zoom Focus Playhead"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusPlayhead));
268         ActionManager::session_sensitive_actions.push_back (act);
269         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-edit", _("Zoom Focus Edit"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusEdit));
270         ActionManager::session_sensitive_actions.push_back (act);
271
272         Glib::RefPtr<ActionGroup> mouse_mode_actions = ActionGroup::create (X_("MouseMode"));
273         RadioAction::Group mouse_mode_group;
274
275         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-object", _("Object Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseObject, false));
276         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-range", _("Range Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseRange, false));
277         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-gain", _("Gain Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseGain, false));
278         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-zoom", _("Zoom Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseZoom, false));
279         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-timefx", _("Timefx Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseTimeFX, false));
280
281         ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap To"));
282         ActionManager::register_action (editor_actions, X_("SnapMode"), _("Snap Mode"));
283
284         RadioAction::Group snap_mode_group;
285         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-normal"), _("Normal"), (bind (mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapNormal)));
286         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-magnetic"), _("Magnetic"), (bind (mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapMagnetic)));
287
288         Glib::RefPtr<ActionGroup> snap_actions = ActionGroup::create (X_("Snap"));
289         RadioAction::Group snap_choice_group;
290
291         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-frame"), _("Snap to frame"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToFrame)));
292         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-cd-frame"), _("Snap to cd frame"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToCDFrame)));
293         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-frame"), _("Snap to SMPTE frame"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSMPTEFrame)));
294         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-seconds"), _("Snap to SMPTE seconds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSMPTESeconds)));
295         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-minutes"), _("Snap to SMPTE minutes"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSMPTEMinutes)));
296         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-seconds"), _("Snap to seconds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSeconds)));
297         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-minutes"), _("Snap to minutes"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToMinutes)));
298         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirtyseconds"), _("Snap to thirtyseconds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAThirtysecondBeat)));
299         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-asixteenthbeat"), _("Snap to asixteenthbeat"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToASixteenthBeat)));
300         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-eighths"), _("Snap to eighths"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAEighthBeat)));
301         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-quarters"), _("Snap to quarters"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAQuarterBeat)));
302         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirds"), _("Snap to thirds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAThirdBeat)));
303         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-beat"), _("Snap to beat"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeat)));
304         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-bar"), _("Snap to bar"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBar)));
305         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-mark"), _("Snap to mark"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToMark)));
306         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-edit-cursor"), _("Snap to edit cursor"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToEditCursor)));
307         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-start"), _("Snap to region start"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionStart)));
308         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-end"), _("Snap to region end"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionEnd)));
309         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-sync"), _("Snap to region sync"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionSync)));
310         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-boundary"), _("Snap to region boundary"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionBoundary)));
311
312         /* REGION LIST */
313
314         Glib::RefPtr<ActionGroup> rl_actions = ActionGroup::create (X_("RegionList"));
315         RadioAction::Group sort_type_group;
316         RadioAction::Group sort_order_group;
317
318         /* the region list popup menu */
319         ActionManager::register_action (rl_actions, X_("RegionListSort"), _("Sort"));
320
321         act = ActionManager::register_action (rl_actions, X_("rlAudition"), _("Audition"), mem_fun(*this, &Editor::audition_region_from_region_list));
322         ActionManager::region_list_selection_sensitive_actions.push_back (act);
323         act = ActionManager::register_action (rl_actions, X_("rlHide"), _("Hide"), mem_fun(*this, &Editor::hide_region_from_region_list));
324         ActionManager::region_list_selection_sensitive_actions.push_back (act);
325         act = ActionManager::register_action (rl_actions, X_("rlRemove"), _("Remove"), mem_fun (*this, &Editor::remove_region_from_region_list));
326         ActionManager::region_list_selection_sensitive_actions.push_back (act);
327         ActionManager::register_toggle_action (rl_actions, X_("rlShowAll"), _("Show all"), mem_fun(*this, &Editor::toggle_full_region_list));
328         ActionManager::register_toggle_action (rl_actions, X_("rlShowAuto"), _("Show automatic regions"), mem_fun(*this, &Editor::toggle_show_auto_regions));
329
330         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortAscending"),  _("Ascending"),
331                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), true));
332         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortDescending"),   _("Descending"),
333                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), false));
334         
335         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionName"),  _("By Region Name"),
336                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByName));
337         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionLength"),  _("By Region Length"),
338                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByLength));
339         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionPosition"),  _("By Region Position"),
340                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByPosition));
341         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionTimestamp"),  _("By Region Timestamp"),
342                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByTimestamp));
343         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionStartinFile"),  _("By Region Start in File"),
344                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByStartInFile));
345         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionEndinFile"),  _("By Region End in File"),
346                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByEndInFile));
347         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileName"),  _("By Source File Name"),
348                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileName));
349         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileLength"),  _("By Source File Length"),
350                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileLength));
351         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileCreationDate"),  _("By Source File Creation Date"),
352                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileCreationDate));
353         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFilesystem"),  _("By Source Filesystem"),
354                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileFS));
355
356
357         /* the next two are duplicate items with different names for use in two different contexts */
358
359         act = ActionManager::register_action (editor_actions, X_("addExternalAudioToRegionList"), _("Add External Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion));
360         ActionManager::session_sensitive_actions.push_back (act);
361         act = ActionManager::register_action (editor_actions, X_("addExternalAudioAsRegion"), _("as Region(s)"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion));
362         ActionManager::session_sensitive_actions.push_back (act);
363         act = ActionManager::register_action (editor_actions, X_("addExternalAudioAsTrack"), _("as Tracks"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsTrack));
364         ActionManager::session_sensitive_actions.push_back (act);
365         act = ActionManager::register_action (editor_actions, X_("addExternalAudioAsTapeTrack"), _("as Tape Tracks"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsTapeTrack));
366         ActionManager::session_sensitive_actions.push_back (act);
367         act = ActionManager::register_action (editor_actions, X_("addExternalAudioToTrack"), _("to Tracks"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack));
368         ActionManager::session_sensitive_actions.push_back (act);
369
370         ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformVisibility"), _("Show Waveforms"), mem_fun (*this, &Editor::toggle_waveform_visibility));
371         ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformsWhileRecording"), _("Show Waveforms While Recording"), mem_fun (*this, &Editor::toggle_waveforms_while_recording));
372         act = ActionManager::register_toggle_action (editor_actions, X_("ToggleMeasureVisibility"), _("Show Measures"), mem_fun (*this, &Editor::toggle_measure_visibility));
373         
374         RadioAction::Group layer_model_group;
375
376         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerLaterHigher"), _("Later is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), LaterHigher));
377         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerMoveAddHigher"), _("Most Recently Moved/Added is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), MoveAddHigher));
378         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerAddHigher"), _("Most Recently Added is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), AddHigher));
379
380         RadioAction::Group smpte_group;
381
382         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte23976"), _("23.976"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_23976));
383         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte24"), _("24"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_24));
384         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte24976"), _("24.976"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_24976));
385         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte25"), _("25"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_25));
386         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte2997"), _("29.97"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_2997));
387         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte2997drop"), _("29.97 drop"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_2997drop));
388         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte30"), _("30"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_30));
389         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte30drop"), _("30 drop"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_30drop));
390         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte5994"), _("59.94"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_5994));
391         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte60"), _("60"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), Session::smpte_60));
392
393         RadioAction::Group pullup_group;
394
395         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4Plus1"), _("+4.1667% + 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4Plus1));
396         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4"), _("+4.1667%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4));
397         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4Minus1"), _("+4.1667% - 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4Minus1));
398         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus1"), _("+ 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus1));
399         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupNone"), _("None"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_None));
400         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus1"), _("- 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus1));
401         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4Plus1"), _("-4.1667% + 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4Plus1));
402         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4"), _("-4.1667%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4));
403         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4Minus1"), _("-4.1667% - 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4Minus1));
404
405         ActionManager::add_action_group (rl_actions);
406         ActionManager::add_action_group (zoom_actions);
407         ActionManager::add_action_group (mouse_mode_actions);
408         ActionManager::add_action_group (snap_actions);
409         ActionManager::add_action_group (editor_actions);
410 }
411
412 void
413 Editor::toggle_waveform_visibility ()
414 {
415         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
416         if (act) {
417                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
418                 set_show_waveforms (tact->get_active());
419         }
420 }
421
422 void
423 Editor::toggle_waveforms_while_recording ()
424 {
425         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
426         if (act) {
427                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
428                 set_show_waveforms_recording (tact->get_active());
429         }
430 }
431
432 void
433 Editor::toggle_measure_visibility ()
434 {
435         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
436         if (act) {
437                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
438                 set_show_measures (tact->get_active());
439         }
440 }
441
442 void
443 Editor::set_crossfade_model (CrossfadeModel model)
444 {
445         RefPtr<Action> act;
446
447         /* this is driven by a toggle on a radio group, and so is invoked twice,
448            once for the item that became inactive and once for the one that became
449            active.
450         */
451
452         switch (model) {
453         case FullCrossfade:
454                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
455                 break;
456         case ShortCrossfade:
457                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
458                 break;
459         }
460         
461         if (act) {
462                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
463                 if (ract && ract->get_active()) {
464                         Config->set_xfade_model (model);
465                 }
466         }
467 }
468
469 void
470 Editor::update_crossfade_model ()
471 {
472         RefPtr<Action> act;
473
474         switch (Config->get_xfade_model()) {
475         case FullCrossfade:
476                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
477                 break;
478         case ShortCrossfade:
479                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
480                 break;
481         }
482
483         if (act) {
484                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
485                 if (ract && !ract->get_active()) {
486                         ract->set_active (true);
487                 }
488         }
489 }
490
491 void
492 Editor::update_smpte_mode ()
493 {
494         ENSURE_GUI_THREAD(mem_fun(*this, &Editor::update_smpte_mode));
495
496         RefPtr<Action> act;
497         const char* action = 0;
498
499         float frames = Config->get_smpte_frames_per_second();
500         bool drop = Config->get_smpte_drop_frames();
501
502         if ((frames < 23.976 * 1.0005) && !drop)
503                 action = X_("Smpte23976");
504         else if ((frames < 24 * 1.0005) && !drop)
505                 action = X_("Smpte24");
506         else if ((frames < 24.976 * 1.0005) && !drop)
507                 action = X_("Smpte24976");
508         else if ((frames < 25 * 1.0005) && !drop)
509                 action = X_("Smpte25");
510         else if ((frames < 29.97 * 1.0005) && !drop)
511                 action = X_("Smpte2997");
512         else if ((frames < 29.97 * 1.0005) && drop)
513                 action = X_("Smpte2997drop");
514         else if ((frames < 30 * 1.0005) && !drop)
515                 action = X_("Smpte30");
516         else if ((frames < 30 * 1.0005) && drop)
517                 action = X_("Smpte30drop");
518         else if ((frames < 59.94 * 1.0005) && !drop)
519                 action = X_("Smpte5994");
520         else if ((frames < 60 * 1.0005) && !drop)
521                 action = X_("Smpte60");
522         else {
523                 fatal << string_compose (_("programming error: Unexpected SMPTE value (%1, drop = %2) in update_smpte_mode.  Menu is probably wrong."),
524                                          frames, drop) << endmsg;
525                 /*NOTREACHED*/
526         }
527
528         act = ActionManager::get_action (X_("Editor"), action);
529
530         if (act) {
531                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
532                 if (ract && !ract->get_active()) {
533                         ract->set_active (true);
534                 }
535         }
536 }
537
538 void
539 Editor::update_video_pullup ()
540 {
541         ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_video_pullup));
542
543         RefPtr<Action> act;
544         const char* action = 0;
545
546         float pullup = Config->get_video_pullup();
547
548         if ( pullup < (-4.1667 - 0.1) * 0.99) {
549                 action = X_("PullupMinus4Minus1");
550         } else if ( pullup < (-4.1667) * 0.99 ) {
551                 action = X_("PullupMinus4");
552         } else if ( pullup < (-4.1667 + 0.1) * 0.99 ) {
553                 action = X_("PullupMinus4Plus1");
554         } else if ( pullup < (-0.1) * 0.99 ) {
555                 action = X_("PullupMinus1");
556         } else if (pullup > (4.1667 + 0.1) * 0.99 ) {
557                 action = X_("PullupPlus4Plus1");
558         } else if ( pullup > (4.1667) * 0.99 ) {
559                 action = X_("PullupPlus4");
560         } else if ( pullup > (4.1667 - 0.1) * 0.99) {
561                 action = X_("PullupPlus4Minus1");
562         } else if ( pullup > (0.1) * 0.99 ) {
563                 action = X_("PullupPlus1");
564         } else {
565                 action = X_("PullupNone");
566         }
567
568         act = ActionManager::get_action (X_("Editor"), action);
569
570         if (act) {
571                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
572                 if (ract && !ract->get_active()) {
573                         ract->set_active (true);
574                 }
575         }
576 }
577
578 void
579 Editor::update_layering_model ()
580 {
581         RefPtr<Action> act;
582
583         switch (Config->get_layer_model()) {
584         case LaterHigher:
585                 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
586                 break;
587         case MoveAddHigher:
588                 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
589                 break;
590         case AddHigher:
591                 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
592                 break;
593         }
594
595         if (act) {
596                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
597                 if (ract && !ract->get_active()) {
598                         ract->set_active (true);
599                 }
600         }
601 }
602
603 void
604 Editor::set_layer_model (LayerModel model)
605 {
606         /* this is driven by a toggle on a radio group, and so is invoked twice,
607            once for the item that became inactive and once for the one that became
608            active.
609         */
610
611         RefPtr<Action> act;
612
613         switch (model) {
614         case LaterHigher:
615                 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
616                 break;
617         case MoveAddHigher:
618                 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
619                 break;
620         case AddHigher:
621                 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
622                 break;
623         }
624         
625         if (act) {
626                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
627                 if (ract && ract->get_active() && Config->get_layer_model() != model) {
628                         Config->set_layer_model (model);
629                 }
630         }
631 }
632
633 RefPtr<RadioAction>
634 Editor::snap_type_action (SnapType type)
635 {
636
637         const char* action = 0;
638         RefPtr<Action> act;
639         
640         switch (type) {
641         case Editing::SnapToFrame:
642                 action = "snap-to-frame";
643                 break;
644         case Editing::SnapToCDFrame:
645                 action = "snap-to-cd-frame";
646                 break;
647         case Editing::SnapToSMPTEFrame:
648                 action = "snap-to-smpte-frame";
649                 break;
650         case Editing::SnapToSMPTESeconds:
651                 action = "snap-to-smpte-seconds";
652                 break;
653         case Editing::SnapToSMPTEMinutes:
654                 action = "snap-to-smpte-minutes";
655                 break;
656         case Editing::SnapToSeconds:
657                 action = "snap-to-seconds";
658                 break;
659         case Editing::SnapToMinutes:
660                 action = "snap-to-minutes";
661                 break;
662         case Editing::SnapToAThirtysecondBeat:
663                 action = "snap-to-thirtyseconds";
664                 break;
665         case Editing::SnapToASixteenthBeat:
666                 action = "snap-to-asixteenthbeat";
667                 break;
668         case Editing::SnapToAEighthBeat:
669                 action = "snap-to-eighths";
670                 break;
671         case Editing::SnapToAQuarterBeat:
672                 action = "snap-to-quarters";
673                 break;
674         case Editing::SnapToAThirdBeat:
675                 action = "snap-to-thirds";
676                 break;
677         case Editing::SnapToBeat:
678                 action = "snap-to-beat";
679                 break;
680         case Editing::SnapToBar:
681                 action = "snap-to-bar";
682                 break;
683         case Editing::SnapToMark:
684                 action = "snap-to-mark";
685                 break;
686         case Editing::SnapToEditCursor:
687                 action = "snap-to-edit-cursor";
688                 break;
689         case Editing::SnapToRegionStart:
690                 action = "snap-to-region-start";
691                 break;
692         case Editing::SnapToRegionEnd:
693                 action = "snap-to-region-end";
694                 break;
695         case Editing::SnapToRegionSync:
696                 action = "snap-to-region-sync";
697                 break;
698         case Editing::SnapToRegionBoundary:
699                 action = "snap-to-region-boundary";
700                 break;
701         default:
702                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap-to type", (int) type) << endmsg;
703                 /*NOTREACHED*/
704         }
705
706         act = ActionManager::get_action (X_("Snap"), action);
707
708         if (act) {
709                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
710                 return ract;
711
712         } else  {
713                 error << string_compose (_("programming error: %1"), "Editor::snap_type_chosen could not find action to match type.") << endmsg;
714                 return RefPtr<RadioAction>();
715         }
716 }
717
718 void
719 Editor::snap_type_chosen (SnapType type)
720 {
721         /* this is driven by a toggle on a radio group, and so is invoked twice,
722            once for the item that became inactive and once for the one that became
723            active.
724         */
725
726         RefPtr<RadioAction> ract = snap_type_action (type);
727
728         if (ract && ract->get_active()) {
729                 set_snap_to (type);
730         }
731 }
732
733 RefPtr<RadioAction>
734 Editor::snap_mode_action (SnapMode mode)
735 {
736         const char* action = 0;
737         RefPtr<Action> act;
738         
739         switch (mode) {
740         case Editing::SnapNormal:
741                 action = X_("snap-normal");
742                 break;
743         case Editing::SnapMagnetic:
744                 action = X_("snap-magnetic");
745                 break;
746         default:
747                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap mode type", (int) mode) << endmsg;
748                 /*NOTREACHED*/
749         }
750         
751         act = ActionManager::get_action (X_("Editor"), action);
752         
753         if (act) {
754                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
755                 return ract;
756                 
757         } else  {
758                 error << string_compose (_("programming error: %1: %2"), "Editor::snap_mode_chosen could not find action to match mode.", action) << endmsg;
759                 return RefPtr<RadioAction> ();
760         }
761 }
762
763 void
764 Editor::snap_mode_chosen (SnapMode mode)
765 {
766         /* this is driven by a toggle on a radio group, and so is invoked twice,
767            once for the item that became inactive and once for the one that became
768            active.
769         */
770
771         RefPtr<RadioAction> ract = snap_mode_action (mode);
772
773         if (ract && ract->get_active()) {
774                 set_snap_mode (mode);
775         }
776 }
777
778
779 RefPtr<RadioAction>
780 Editor::zoom_focus_action (ZoomFocus focus)
781 {
782         const char* action = 0;
783         RefPtr<Action> act;
784         
785         switch (focus) {
786         case ZoomFocusLeft:
787                 action = X_("zoom-focus-left");
788                 break;
789         case ZoomFocusRight:
790                 action = X_("zoom-focus-right");
791                 break;
792         case ZoomFocusCenter:
793                 action = X_("zoom-focus-center");
794                 break;
795         case ZoomFocusPlayhead:
796                 action = X_("zoom-focus-playhead");
797                 break;
798         case ZoomFocusEdit:
799                 action = X_("zoom-focus-edit");
800                 break;
801         default:
802                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible focus type", (int) focus) << endmsg;
803                 /*NOTREACHED*/
804         }
805         
806         act = ActionManager::get_action (X_("Zoom"), action);
807         
808         if (act) {
809                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
810                 return ract;
811         } else {
812                 error << string_compose (_("programming error: %1: %2"), "Editor::zoom_focus_action could not find action to match focus.", action) << endmsg;
813         }
814
815         return RefPtr<RadioAction> ();
816 }
817
818 void
819 Editor::zoom_focus_chosen (ZoomFocus focus)
820 {
821         /* this is driven by a toggle on a radio group, and so is invoked twice,
822            once for the item that became inactive and once for the one that became
823            active.
824         */
825
826         RefPtr<RadioAction> ract = zoom_focus_action (focus);
827
828         if (ract && ract->get_active()) {
829                 set_zoom_focus (focus);
830         }
831 }
832
833 void
834 Editor::smpte_fps_chosen (Session::SmpteFormat format)
835 {
836         /* this is driven by a toggle on a radio group, and so is invoked twice,
837            once for the item that became inactive and once for the one that became
838            active.
839         */
840
841         if (session) {
842
843                 float fps = 10;
844                 bool drop = false;
845
846                 RefPtr<Action> act;
847
848                 switch (format) {
849                         case Session::smpte_23976: {
850                                 fps=23.976;
851                                 drop = false;
852                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte23976"));
853                         } break;
854                         case Session::smpte_24: {
855                                 fps=24;
856                                 drop = false;
857                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte24"));
858                         } break;
859                         case Session::smpte_24976: {
860                                 fps=24.976;
861                                 drop = false;
862                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte24976"));
863                         } break;
864                         case Session::smpte_25: {
865                                 fps=25;
866                                 drop = false;
867                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte25"));
868                         } break;
869                         case Session::smpte_2997: {
870                                 fps=29.97;
871                                 drop = false;
872                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte2997"));
873                         } break;
874                         case Session::smpte_2997drop: {
875                                 fps=29.97;
876                                 drop = true;
877                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte2997drop"));
878                         } break;
879                         case Session::smpte_30: {
880                                 fps=30;
881                                 drop = false;
882                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte30"));
883                         } break;
884                         case Session::smpte_30drop: {
885                                 fps=30;
886                                 drop = true;
887                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte30drop"));
888                         } break;
889                         case Session::smpte_5994: {
890                                 fps=59.94;
891                                 drop = false;
892                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte5994"));
893                         } break;
894                         case Session::smpte_60: {
895                                 fps=60;
896                                 drop = false;
897                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte60"));
898                         } break;
899                         default:
900                                 cerr << "Editor received unexpected smpte type" << endl;
901                 }
902
903                 if (act) {
904                         RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
905                         if (ract && ract->get_active()) {
906                                 session->set_smpte_type (fps, drop);
907                         }
908                 }
909         }
910 }
911
912 void
913 Editor::video_pullup_chosen (Session::PullupFormat pullup)
914 {
915         /* this is driven by a toggle on a radio group, and so is invoked twice,
916            once for the item that became inactive and once for the one that became
917            active.
918         */
919
920         const char* action = 0;
921
922         RefPtr<Action> act;
923         
924         float pull = 0.0;
925         
926         switch (pullup) {
927         case Session::pullup_Plus4Plus1:
928                 pull = 4.1667 + 0.1;
929                 action = X_("PullupPlus4Plus1");
930                 break;
931         case Session::pullup_Plus4:
932                 pull = 4.1667;
933                 action = X_("PullupPlus4");
934                 break;
935         case Session::pullup_Plus4Minus1:
936                 pull = 4.1667 - 0.1;
937                 action = X_("PullupPlus4Minus1");
938                 break;
939         case Session::pullup_Plus1:
940                 pull = 0.1;
941                 action = X_("PullupPlus1");
942                 break;
943         case Session::pullup_None:
944                 pull = 0.0;
945                 action = X_("PullupNone");
946                 break;
947         case Session::pullup_Minus1:
948                 pull = -0.1;
949                 action = X_("PullupMinus1");
950                 break;
951         case Session::pullup_Minus4Plus1:
952                 pull = -4.1667 + 0.1;
953                 action = X_("PullupMinus4Plus1");
954                 break;
955         case Session::pullup_Minus4:
956                 pull = -4.1667;
957                 action = X_("PullupMinus4");
958                 break;
959         case Session::pullup_Minus4Minus1:
960                 pull = -4.1667 - 0.1;
961                 action = X_("PullupMinus4Minus1");
962                 break;
963         default:
964                 fatal << string_compose (_("programming error: %1"), "Session received unexpected pullup type") << endmsg;
965                 /*NOTREACHED*/
966         }
967         
968         act = ActionManager::get_action (X_("Editor"), action);
969         
970         if (act) {
971                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
972                 if (ract && ract->get_active()) {
973                         Config->set_video_pullup ( pull );
974                 }
975                 
976         } else  {
977                 error << string_compose (_("programming error: %1"), "Editor::video_pullup_chosen could not find action to match pullup.") << endmsg;
978         }
979 }
980
981 void
982 Editor::toggle_auto_xfade ()
983 {
984         ActionManager::toggle_config_state ("Editor", "toggle-auto-xfades", &Configuration::set_auto_xfade, &Configuration::get_auto_xfade);
985 }
986
987 void
988 Editor::toggle_xfades_active ()
989 {
990         ActionManager::toggle_config_state ("Editor", "toggle-xfades-active", &Configuration::set_xfades_active, &Configuration::get_xfades_active);
991 }
992
993 void
994 Editor::toggle_xfade_visibility ()
995 {
996         ActionManager::toggle_config_state ("Editor", "toggle-xfades-visibility", &Configuration::set_xfades_visible, &Configuration::get_xfades_visible);
997 }
998
999 void
1000 Editor::parameter_changed (const char* parameter_name)
1001 {
1002 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
1003
1004         ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::parameter_changed), parameter_name));
1005
1006         if (PARAM_IS ("auto-loop")) {
1007                 update_loop_range_view (true);
1008         } else if (PARAM_IS ("punch-in")) {
1009                 update_punch_range_view (true);
1010         } else if (PARAM_IS ("punch-out")) {
1011                 update_punch_range_view (true);
1012         } else if (PARAM_IS ("layer-model")) {
1013                 update_layering_model ();
1014         } else if (PARAM_IS ("smpte-frames-per-second") || PARAM_IS ("smpte-drop-frames")) {
1015                 update_smpte_mode ();
1016                 update_just_smpte ();
1017         } else if (PARAM_IS ("video-pullup")) {
1018                 update_video_pullup ();
1019         } else if (PARAM_IS ("xfades-active")) {
1020                 ActionManager::map_some_state ("Editor", "toggle-xfades-active", &Configuration::get_xfades_active);
1021         } else if (PARAM_IS ("xfades-visible")) {
1022                 ActionManager::map_some_state ("Editor", "toggle-xfades-visible", &Configuration::get_xfades_visible);
1023         } else if (PARAM_IS ("auto-xfade")) {
1024                 ActionManager::map_some_state ("Editor", "toggle-auto-xfades", &Configuration::get_auto_xfade);
1025         } else if (PARAM_IS ("xfade-model")) {
1026                 update_crossfade_model ();
1027         } else if (PARAM_IS ("edit-mode")) {
1028                 edit_mode_selector.set_active_text (edit_mode_to_string (Config->get_edit_mode()));
1029         }
1030
1031 #undef PARAM_IS
1032 }