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