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