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