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