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