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