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