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