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