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