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