fix problems with undo/redo and region dragging; fix dragging in lock edit mode
[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 #include <ardour/profile.h>
22
23 #include "utils.h"
24 #include "editor.h"
25 #include "editing.h"
26 #include "actions.h"
27 #include "ardour_ui.h"
28 #include "gui_thread.h"
29 #include "i18n.h"
30
31 using namespace Gtk;
32 using namespace Glib;
33 using namespace std;
34 using namespace sigc;
35 using namespace ARDOUR;
36 using namespace PBD;
37 using namespace Editing;
38
39 void
40 Editor::register_actions ()
41 {
42         RefPtr<Action> act;
43
44         editor_actions = ActionGroup::create (X_("Editor"));
45         
46         /* non-operative menu items for menu bar */
47
48         ActionManager::register_action (editor_actions, X_("AlignMenu"), _("Align"));
49         ActionManager::register_action (editor_actions, X_("Autoconnect"), _("Autoconnect"));
50         ActionManager::register_action (editor_actions, X_("Crossfades"), _("Crossfades"));
51         ActionManager::register_action (editor_actions, X_("Edit"), _("Edit"));
52         ActionManager::register_action (editor_actions, X_("EditCursorMovementOptions"), _("Move Selected Marker"));
53         ActionManager::register_action (editor_actions, X_("EditSelectRangeOptions"), _("Select Range Operations"));
54         ActionManager::register_action (editor_actions, X_("EditSelectRegionOptions"), _("Select Regions"));
55         ActionManager::register_action (editor_actions, X_("EditPointMenu"), _("Edit Point"));
56         ActionManager::register_action (editor_actions, X_("FadeMenu"), _("Fade"));
57         ActionManager::register_action (editor_actions, X_("LatchMenu"), _("Latch"));
58         ActionManager::register_action (editor_actions, X_("Layering"), _("Layering"));
59         ActionManager::register_action (editor_actions, X_("Link"), _("Link"));
60         ActionManager::register_action (editor_actions, X_("LocateToMarker"), _("Locate To Markers"));
61         ActionManager::register_action (editor_actions, X_("MarkerMenu"), _("Markers"));
62         ActionManager::register_action (editor_actions, X_("MeterFalloff"), _("Meter falloff"));
63         ActionManager::register_action (editor_actions, X_("MeterHold"), _("Meter hold"));
64         ActionManager::register_action (editor_actions, X_("MiscOptions"), _("Misc Options"));
65         ActionManager::register_action (editor_actions, X_("Monitoring"), _("Monitoring"));
66         ActionManager::register_action (editor_actions, X_("MoveActiveMarkMenu"), _("Active Mark"));
67         ActionManager::register_action (editor_actions, X_("MovePlayHeadMenu"), _("Playhead"));
68         ActionManager::register_action (editor_actions, X_("NudgeRegionMenu"), _("Nudge"));
69         ActionManager::register_action (editor_actions, X_("PlayMenu"), _("Play"));
70         ActionManager::register_action (editor_actions, X_("PrimaryClockMenu"), _("Primary Clock"));
71         ActionManager::register_action (editor_actions, X_("Pullup"), _("Pullup / Pulldown"));
72         ActionManager::register_action (editor_actions, X_("RegionMenu"), _("Region"));
73         ActionManager::register_action (editor_actions, X_("RegionEditOps"), _("Region operations"));
74         ActionManager::register_action (editor_actions, X_("RegionGainMenu"), _("Gain"));
75         ActionManager::register_action (editor_actions, X_("RulerMenu"), _("Rulers"));
76         ActionManager::register_action (editor_actions, X_("ScrollMenu"), _("Scroll"));
77         ActionManager::register_action (editor_actions, X_("SecondaryClockMenu"), _("Secondary Clock"));
78         ActionManager::register_action (editor_actions, X_("Select"), _("Select"));
79         ActionManager::register_action (editor_actions, X_("SelectMenu"), _("Select"));
80         ActionManager::register_action (editor_actions, X_("SeparateMenu"), _("Separate"));
81         ActionManager::register_action (editor_actions, X_("SetLoopMenu"), _("Loop"));
82         ActionManager::register_action (editor_actions, X_("SetPunchMenu"), _("Punch"));
83         ActionManager::register_action (editor_actions, X_("Solo"), _("Solo"));
84         ActionManager::register_action (editor_actions, X_("Subframes"), _("Subframes"));
85         ActionManager::register_action (editor_actions, X_("SyncMenu"), _("Sync"));
86         ActionManager::register_action (editor_actions, X_("TempoMenu"), _("Tempo"));
87         ActionManager::register_action (editor_actions, X_("Timecode"), _("Timecode fps"));
88         ActionManager::register_action (editor_actions, X_("TrackHeightMenu"), _("Height"));
89         ActionManager::register_action (editor_actions, X_("TrackMenu"), _("Track"));
90         ActionManager::register_action (editor_actions, X_("Tools"), _("Tools"));
91         ActionManager::register_action (editor_actions, X_("TrimMenu"), _("Trim"));
92         ActionManager::register_action (editor_actions, X_("View"), _("View"));
93         ActionManager::register_action (editor_actions, X_("WaveformMenu"), _("Waveforms"));
94         ActionManager::register_action (editor_actions, X_("ZoomFocus"), _("Zoom"));
95         ActionManager::register_action (editor_actions, X_("ZoomMenu"), _("Zoom"));
96         ActionManager::register_action (editor_actions, X_("ZoomFocusMenu"), _("Zoom Focus"));
97
98         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));
99         ActionManager::register_action (editor_actions, "break-drag", _("Break drag"), mem_fun (*this, &Editor::break_drag));
100
101         act = ActionManager::register_toggle_action (editor_actions, "show-editor-mixer", _("Show Editor Mixer"), mem_fun (*this, &Editor::editor_mixer_button_toggled));
102         ActionManager::session_sensitive_actions.push_back (act);
103
104         RadioAction::Group crossfade_model_group;
105
106         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesFull", _("Span Entire Overlap"), bind (mem_fun(*this, &Editor::set_crossfade_model), FullCrossfade));
107         ActionManager::session_sensitive_actions.push_back (act);
108         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesShort", _("Short"), bind (mem_fun(*this, &Editor::set_crossfade_model), ShortCrossfade));
109         ActionManager::session_sensitive_actions.push_back (act);
110
111         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-active", _("Active"), mem_fun(*this, &Editor::toggle_xfades_active));
112         ActionManager::session_sensitive_actions.push_back (act);
113         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-visible", _("Show"), mem_fun(*this, &Editor::toggle_xfade_visibility));
114         ActionManager::session_sensitive_actions.push_back (act);
115         act = ActionManager::register_toggle_action (editor_actions, "toggle-auto-xfades", _("Created Automatically"), mem_fun(*this, &Editor::toggle_auto_xfade));
116         ActionManager::session_sensitive_actions.push_back (act);
117
118         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));
119         ActionManager::session_sensitive_actions.push_back (act);
120         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));
121         ActionManager::session_sensitive_actions.push_back (act);
122
123         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)));
124         ActionManager::session_sensitive_actions.push_back (act);
125         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)));
126         ActionManager::session_sensitive_actions.push_back (act);
127         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)));
128         ActionManager::session_sensitive_actions.push_back (act);
129
130         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)));
131         ActionManager::session_sensitive_actions.push_back (act);
132         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)));
133         ActionManager::session_sensitive_actions.push_back (act);
134         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)));
135         ActionManager::session_sensitive_actions.push_back (act);
136
137         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));
138         ActionManager::session_sensitive_actions.push_back (act);
139         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));
140         ActionManager::session_sensitive_actions.push_back (act);
141
142         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)));
143         ActionManager::session_sensitive_actions.push_back (act);
144         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)));
145         ActionManager::session_sensitive_actions.push_back (act);
146         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)));
147         ActionManager::session_sensitive_actions.push_back (act);
148
149         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)));
150         ActionManager::session_sensitive_actions.push_back (act);
151         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)));
152         ActionManager::session_sensitive_actions.push_back (act);
153         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)));
154         ActionManager::session_sensitive_actions.push_back (act);
155
156         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-start", _("to Range Start"), mem_fun(*this, &Editor::selected_marker_to_selection_start));
157         ActionManager::session_sensitive_actions.push_back (act);
158         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-end", _("to Range End"), mem_fun(*this, &Editor::selected_marker_to_selection_end));
159         ActionManager::session_sensitive_actions.push_back (act);
160
161         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));
162         ActionManager::session_sensitive_actions.push_back (act);
163         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));
164         ActionManager::session_sensitive_actions.push_back (act);
165
166         act = ActionManager::register_action (editor_actions, "select-all", _("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set));
167         ActionManager::session_sensitive_actions.push_back (act);
168         act = ActionManager::register_action (editor_actions, "deselect-all", _("Deselect All"), mem_fun(*this, &Editor::deselect_all));
169         ActionManager::session_sensitive_actions.push_back (act);
170         act = ActionManager::register_action (editor_actions, "invert-selection", _("Invert Selection"), mem_fun(*this, &Editor::invert_selection));
171         ActionManager::session_sensitive_actions.push_back (act);
172         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));
173         ActionManager::session_sensitive_actions.push_back (act);
174         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));
175         ActionManager::session_sensitive_actions.push_back (act);
176
177         act = ActionManager::register_action (editor_actions, "select-all-between-cursors", _("Select All Overlapping Edit Range"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false));
178         ActionManager::session_sensitive_actions.push_back (act);
179         act = ActionManager::register_action (editor_actions, "select-all-within-cursors", _("Select All Inside Edit Range"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true));
180         ActionManager::session_sensitive_actions.push_back (act);
181
182         act = ActionManager::register_action (editor_actions, "select-range-between-cursors", _("Select Edit Range"), mem_fun(*this, &Editor::select_range_between));
183         ActionManager::session_sensitive_actions.push_back (act);
184
185         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));
186         ActionManager::session_sensitive_actions.push_back (act);
187         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));
188         ActionManager::session_sensitive_actions.push_back (act);
189         
190         act = ActionManager::register_action (editor_actions, "select-next-route", _("Select Next Track/Bus"), mem_fun(*this, &Editor::select_next_route));
191         ActionManager::session_sensitive_actions.push_back (act);
192         act = ActionManager::register_action (editor_actions, "select-prev-route", _("Select Previous Track/Bus"), mem_fun(*this, &Editor::select_prev_route));
193         ActionManager::session_sensitive_actions.push_back (act);
194         
195
196         act = ActionManager::register_action (editor_actions, "goto-mark-1", _("Locate to Mark 1"), bind (mem_fun (*this, &Editor::goto_nth_marker), 0));
197         ActionManager::session_sensitive_actions.push_back (act);
198         act = ActionManager::register_action (editor_actions, "goto-mark-2", _("Locate to Mark 2"), bind (mem_fun (*this, &Editor::goto_nth_marker), 1));
199         ActionManager::session_sensitive_actions.push_back (act);
200         act = ActionManager::register_action (editor_actions, "goto-mark-3", _("Locate to Mark 3"), bind (mem_fun (*this, &Editor::goto_nth_marker), 2));
201         ActionManager::session_sensitive_actions.push_back (act);
202         act = ActionManager::register_action (editor_actions, "goto-mark-4", _("Locate to Mark 4"), bind (mem_fun (*this, &Editor::goto_nth_marker), 3));
203         ActionManager::session_sensitive_actions.push_back (act);
204         act = ActionManager::register_action (editor_actions, "goto-mark-5", _("Locate to Mark 5"), bind (mem_fun (*this, &Editor::goto_nth_marker), 4));
205         ActionManager::session_sensitive_actions.push_back (act);
206         act = ActionManager::register_action (editor_actions, "goto-mark-6", _("Locate to Mark 6"), bind (mem_fun (*this, &Editor::goto_nth_marker), 5));
207         ActionManager::session_sensitive_actions.push_back (act);
208         act = ActionManager::register_action (editor_actions, "goto-mark-7", _("Locate to Mark 7"), bind (mem_fun (*this, &Editor::goto_nth_marker), 6));
209         ActionManager::session_sensitive_actions.push_back (act);
210         act = ActionManager::register_action (editor_actions, "goto-mark-8", _("Locate to Mark 8"), bind (mem_fun (*this, &Editor::goto_nth_marker), 7));
211         ActionManager::session_sensitive_actions.push_back (act);
212         act = ActionManager::register_action (editor_actions, "goto-mark-9", _("Locate to Mark 9"), bind (mem_fun (*this, &Editor::goto_nth_marker), 8));
213         ActionManager::session_sensitive_actions.push_back (act);
214
215         act = ActionManager::register_action (editor_actions, "jump-forward-to-mark", _("Jump Forward to Mark"), mem_fun(*this, &Editor::jump_forward_to_mark));
216         ActionManager::session_sensitive_actions.push_back (act);
217         act = ActionManager::register_action (editor_actions, "jump-backward-to-mark", _("Jump Backward to Mark"), mem_fun(*this, &Editor::jump_backward_to_mark));
218         ActionManager::session_sensitive_actions.push_back (act);
219         act = ActionManager::register_action (editor_actions, "add-location-from-playhead", _("Add Mark from Playhead"), mem_fun(*this, &Editor::add_location_from_playhead_cursor));
220         ActionManager::session_sensitive_actions.push_back (act);
221
222         act = ActionManager::register_action (editor_actions, "nudge-forward", _("Nudge Forward"), bind (mem_fun(*this, &Editor::nudge_forward), false, false));
223         ActionManager::session_sensitive_actions.push_back (act);
224         act = ActionManager::register_action (editor_actions, "nudge-next-forward", _("Nudge Next Forward"), bind (mem_fun(*this, &Editor::nudge_forward), true, false));
225         ActionManager::session_sensitive_actions.push_back (act);
226         act = ActionManager::register_action (editor_actions, "nudge-backward", _("Nudge Backward"), bind (mem_fun(*this, &Editor::nudge_backward), false, false));
227         ActionManager::session_sensitive_actions.push_back (act);
228         act = ActionManager::register_action (editor_actions, "nudge-next-backward", _("Nudge Next Backward"), bind (mem_fun(*this, &Editor::nudge_backward), true, false));
229         ActionManager::session_sensitive_actions.push_back (act);
230
231         act = ActionManager::register_action (editor_actions, "nudge-playhead-forward", _("Nudge Playhead Forward"), bind (mem_fun(*this, &Editor::nudge_forward), false, true));
232         ActionManager::session_sensitive_actions.push_back (act);
233         act = ActionManager::register_action (editor_actions, "nudge-playhead-backward", _("Nudge Playhead Backward"), bind (mem_fun(*this, &Editor::nudge_backward), false, true));
234         ActionManager::session_sensitive_actions.push_back (act);
235         act = ActionManager::register_action (editor_actions, "playhead-forward-to-grid", _("Forward To Grid"), mem_fun(*this, &Editor::playhead_forward_to_grid));
236         ActionManager::session_sensitive_actions.push_back (act);
237         act = ActionManager::register_action (editor_actions, "playhead-backward-to-grid", _("Backward To Grid"), mem_fun(*this, &Editor::playhead_backward_to_grid));
238         ActionManager::session_sensitive_actions.push_back (act);
239
240
241         act = ActionManager::register_action (editor_actions, "temporal-zoom-out", _("Zoom Out"), bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
242         ActionManager::session_sensitive_actions.push_back (act);
243         act = ActionManager::register_action (editor_actions, "temporal-zoom-in", _("Zoom In"), bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
244         ActionManager::session_sensitive_actions.push_back (act);
245         act = ActionManager::register_action (editor_actions, "zoom-to-session", _("Zoom to Session"), mem_fun(*this, &Editor::temporal_zoom_session));
246         ActionManager::session_sensitive_actions.push_back (act);
247         act = ActionManager::register_action (editor_actions, "zoom-to-region", _("Zoom to Region"), mem_fun(*this, &Editor::toggle_zoom_region));
248         ActionManager::session_sensitive_actions.push_back (act);
249         act = ActionManager::register_action (editor_actions, "toggle-zoom", _("Toggle Zoom State"), mem_fun(*this, &Editor::swap_visual_state));
250         ActionManager::session_sensitive_actions.push_back (act);
251
252         act = ActionManager::register_action (editor_actions, "scroll-tracks-up", _("Scroll Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up));
253         ActionManager::session_sensitive_actions.push_back (act);
254         act = ActionManager::register_action (editor_actions, "scroll-tracks-down", _("Scroll Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down));
255         ActionManager::session_sensitive_actions.push_back (act);
256         act = ActionManager::register_action (editor_actions, "step-tracks-up", _("Step Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up_line));
257         ActionManager::session_sensitive_actions.push_back (act);
258         act = ActionManager::register_action (editor_actions, "step-tracks-down", _("Step Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down_line));
259         ActionManager::session_sensitive_actions.push_back (act);
260
261         act = ActionManager::register_action (editor_actions, "scroll-backward", _("Scroll Backward"), bind (mem_fun(*this, &Editor::scroll_backward), 0.8f));
262         ActionManager::session_sensitive_actions.push_back (act);
263         act = ActionManager::register_action (editor_actions, "scroll-forward", _("Scroll Forward"), bind (mem_fun(*this, &Editor::scroll_forward), 0.8f));
264         ActionManager::session_sensitive_actions.push_back (act);
265         act = ActionManager::register_action (editor_actions, "goto", _("goto"), mem_fun(*this, &Editor::goto_frame));
266         ActionManager::session_sensitive_actions.push_back (act);
267         act = ActionManager::register_action (editor_actions, "center-playhead", _("Center Playhead"), mem_fun(*this, &Editor::center_playhead));
268         ActionManager::session_sensitive_actions.push_back (act);
269         act = ActionManager::register_action (editor_actions, "center-edit-cursor", _("Center Active Marker"), mem_fun(*this, &Editor::center_edit_point));
270         ActionManager::session_sensitive_actions.push_back (act);
271
272         act = ActionManager::register_action (editor_actions, "scroll-playhead-forward", _("Playhead Forward"), bind (mem_fun(*this, &Editor::scroll_playhead), true));;
273         ActionManager::session_sensitive_actions.push_back (act);
274         act = ActionManager::register_action (editor_actions, "scroll-playhead-backward", _("Playhead Backward"), bind (mem_fun(*this, &Editor::scroll_playhead), false));
275         ActionManager::session_sensitive_actions.push_back (act);
276
277         act = ActionManager::register_action (editor_actions, "playhead-to-edit", _("Playhead To Active Mark"), bind (mem_fun(*this, &Editor::cursor_align), true));
278         ActionManager::session_sensitive_actions.push_back (act);
279         act = ActionManager::register_action (editor_actions, "edit-to-playhead", _("Active Mark To Playhead"), bind (mem_fun(*this, &Editor::cursor_align), false));
280         ActionManager::session_sensitive_actions.push_back (act);
281
282         act = ActionManager::register_action (editor_actions, "trim-front", _("Trim Start At Edit Point"), mem_fun(*this, &Editor::trim_region_front));
283         ActionManager::session_sensitive_actions.push_back (act);
284         ActionManager::region_selection_sensitive_actions.push_back (act);
285         act = ActionManager::register_action (editor_actions, "trim-back", _("Trim End At Edit Point"), mem_fun(*this, &Editor::trim_region_back));
286         ActionManager::session_sensitive_actions.push_back (act);
287         ActionManager::region_selection_sensitive_actions.push_back (act);
288
289         act = ActionManager::register_action (editor_actions, "trim-from-start", _("Start To Edit Point"), mem_fun(*this, &Editor::trim_region_from_edit_point));
290         ActionManager::session_sensitive_actions.push_back (act);
291         ActionManager::region_selection_sensitive_actions.push_back (act);
292         act = ActionManager::register_action (editor_actions, "trim-to-end", _("Edit Point To End"), mem_fun(*this, &Editor::trim_region_to_edit_point));
293         ActionManager::session_sensitive_actions.push_back (act);
294         ActionManager::region_selection_sensitive_actions.push_back (act);
295         act = ActionManager::register_action (editor_actions, "trim-region-to-loop", _("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop));
296         ActionManager::session_sensitive_actions.push_back (act);
297         ActionManager::region_selection_sensitive_actions.push_back (act);
298         act = ActionManager::register_action (editor_actions, "trim-region-to-punch", _("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch));
299         ActionManager::session_sensitive_actions.push_back (act);
300         ActionManager::region_selection_sensitive_actions.push_back (act);
301
302         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));
303         ActionManager::session_sensitive_actions.push_back (act);
304         act = ActionManager::register_action (editor_actions, "set-loop-from-region", _("Set Loop From Region"), bind (mem_fun(*this, &Editor::set_loop_from_region), false));
305         ActionManager::session_sensitive_actions.push_back (act);
306         ActionManager::region_selection_sensitive_actions.push_back (act);
307         act = ActionManager::register_action (editor_actions, "loop-region", _("Loop Region"), bind (mem_fun(*this, &Editor::set_loop_from_region), true));
308         ActionManager::session_sensitive_actions.push_back (act);
309         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));
310         ActionManager::session_sensitive_actions.push_back (act);
311         act = ActionManager::register_action (editor_actions, "set-punch-from-region", _("Set Punch From Region"), mem_fun(*this, &Editor::set_punch_from_region));
312         ActionManager::session_sensitive_actions.push_back (act);
313         ActionManager::region_selection_sensitive_actions.push_back (act);
314         act = ActionManager::register_action (editor_actions, "pitch-shift-region", _("Transpose"), mem_fun(*this, &Editor::pitch_shift_regions));
315         ActionManager::session_sensitive_actions.push_back (act);
316         ActionManager::region_selection_sensitive_actions.push_back (act);
317         
318         act = ActionManager::register_action (editor_actions, "set-fade-in-length", _("Set Fade In Length"), bind (mem_fun(*this, &Editor::set_fade_length), true));
319         ActionManager::session_sensitive_actions.push_back (act);
320         act = ActionManager::register_action (editor_actions, "toggle-fade-in-active", _("Toggle Fade In Active"), bind (mem_fun(*this, &Editor::toggle_fade_active), true));
321         ActionManager::session_sensitive_actions.push_back (act);
322         act = ActionManager::register_action (editor_actions, "set-fade-out-length", _("Set Fade Out Length"), bind (mem_fun(*this, &Editor::set_fade_length), false));
323         ActionManager::session_sensitive_actions.push_back (act);
324         act = ActionManager::register_action (editor_actions, "toggle-fade-out-active", _("Toggle Fade Out Active"), bind (mem_fun(*this, &Editor::toggle_fade_active), false));
325         ActionManager::session_sensitive_actions.push_back (act);
326
327         act = ActionManager::register_action (editor_actions, "align-regions-start", _("Align Regions Start"), bind (mem_fun(*this, &Editor::align), ARDOUR::Start));
328         ActionManager::session_sensitive_actions.push_back (act);
329         ActionManager::region_selection_sensitive_actions.push_back (act);
330         act = ActionManager::register_action (editor_actions, "align-regions-start-relative", _("Align Regions Start Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::Start));
331         ActionManager::session_sensitive_actions.push_back (act);
332         ActionManager::region_selection_sensitive_actions.push_back (act);
333         act = ActionManager::register_action (editor_actions, "align-regions-end", _("Align Regions End"), bind (mem_fun(*this, &Editor::align), ARDOUR::End));
334         ActionManager::session_sensitive_actions.push_back (act);
335         ActionManager::region_selection_sensitive_actions.push_back (act);
336         act = ActionManager::register_action (editor_actions, "align-regions-end-relative", _("Align Regions End Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::End));
337         ActionManager::session_sensitive_actions.push_back (act);
338         ActionManager::region_selection_sensitive_actions.push_back (act);
339
340         act = ActionManager::register_action (editor_actions, "align-regions-sync", _("Align Regions Sync"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint));
341         ActionManager::session_sensitive_actions.push_back (act);
342         ActionManager::region_selection_sensitive_actions.push_back (act);
343         act = ActionManager::register_action (editor_actions, "align-regions-sync-relative", _("Align Regions Sync Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint));
344         ActionManager::session_sensitive_actions.push_back (act);
345         ActionManager::region_selection_sensitive_actions.push_back (act);
346
347         act = ActionManager::register_action (editor_actions, "play-from-edit-point", _("Play From Edit Point"), mem_fun(*this, &Editor::play_from_edit_point));
348         ActionManager::session_sensitive_actions.push_back (act);
349         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));
350         ActionManager::session_sensitive_actions.push_back (act);
351
352         act = ActionManager::register_action (editor_actions, "play-edit-range", _("Play Edit Range"), mem_fun(*this, &Editor::play_edit_range));
353         act = ActionManager::register_action (editor_actions, "play-selected-regions", _("Play Selected Region(s)"), mem_fun(*this, &Editor::play_selected_region));
354         ActionManager::session_sensitive_actions.push_back (act);
355         ActionManager::region_selection_sensitive_actions.push_back (act);
356         act = ActionManager::register_action (editor_actions, "brush-at-mouse", _("Brush at Mouse"), mem_fun(*this, &Editor::kbd_brush));
357         ActionManager::session_sensitive_actions.push_back (act);
358
359         act = ActionManager::register_action (editor_actions, "set-playhead", _("Playhead to Mouse"), mem_fun(*this, &Editor::set_playhead_cursor));
360         ActionManager::session_sensitive_actions.push_back (act);
361         act = ActionManager::register_action (editor_actions, "set-edit-point", _("Active Marker to Mouse"), mem_fun(*this, &Editor::set_edit_point));
362         ActionManager::session_sensitive_actions.push_back (act);
363
364         act = ActionManager::register_action (editor_actions, "duplicate-region", _("Duplicate Region"), bind (mem_fun(*this, &Editor::duplicate_dialog), false));
365         ActionManager::session_sensitive_actions.push_back (act);
366         ActionManager::region_selection_sensitive_actions.push_back (act);
367         act = ActionManager::register_action (editor_actions, "multi-duplicate-region", _("Multi-Duplicate Region"), bind (mem_fun(*this, &Editor::duplicate_dialog), true));
368         ActionManager::session_sensitive_actions.push_back (act);
369         ActionManager::region_selection_sensitive_actions.push_back (act);
370         act = ActionManager::register_action (editor_actions, "duplicate-range", _("Duplicate Range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false));
371         ActionManager::session_sensitive_actions.push_back (act);
372         ActionManager::region_selection_sensitive_actions.push_back (act);
373         act = ActionManager::register_action (editor_actions, "insert-region", _("Insert Region"), mem_fun(*this, &Editor::keyboard_insert_region_list_selection));
374         ActionManager::session_sensitive_actions.push_back (act);
375         ActionManager::region_selection_sensitive_actions.push_back (act);
376         act = ActionManager::register_action (editor_actions, "normalize-region", _("Normalize Region"), mem_fun(*this, &Editor::normalize_region));
377         ActionManager::session_sensitive_actions.push_back (act);
378         ActionManager::region_selection_sensitive_actions.push_back (act);
379         act = ActionManager::register_action (editor_actions, "rename-region", _("Rename"), mem_fun(*this, &Editor::rename_region));
380         ActionManager::session_sensitive_actions.push_back (act);
381         ActionManager::region_selection_sensitive_actions.push_back (act);
382         act = ActionManager::register_action (editor_actions, "auto-rename-region", _("Auto-Rename"), mem_fun(*this, &Editor::rename_region));
383         ActionManager::session_sensitive_actions.push_back (act);
384         ActionManager::region_selection_sensitive_actions.push_back (act);
385         act = ActionManager::register_action (editor_actions, "boost-region-gain", _("Boost Region Gain"), bind (mem_fun(*this, &Editor::adjust_region_scale_amplitude), true));
386         ActionManager::session_sensitive_actions.push_back (act);
387         ActionManager::region_selection_sensitive_actions.push_back (act);
388         act = ActionManager::register_action (editor_actions, "cut-region-gain", _("Cut Region Gain"), bind (mem_fun(*this, &Editor::adjust_region_scale_amplitude), false));
389         ActionManager::session_sensitive_actions.push_back (act);
390         ActionManager::region_selection_sensitive_actions.push_back (act);
391         act = ActionManager::register_action (editor_actions, "split-region", _("Split Region"), mem_fun(*this, &Editor::split));
392         ActionManager::session_sensitive_actions.push_back (act);
393         ActionManager::region_selection_sensitive_actions.push_back (act);
394         act = ActionManager::register_action (editor_actions, "set-region-sync-position", _("Set Region Sync Position"), mem_fun(*this, &Editor::set_region_sync_from_edit_point));
395         ActionManager::session_sensitive_actions.push_back (act);
396         ActionManager::region_selection_sensitive_actions.push_back (act);
397         act = ActionManager::register_action (editor_actions, "remove-region-sync", _("Remove Region Sync"), mem_fun(*this, &Editor::remove_region_sync));
398         ActionManager::session_sensitive_actions.push_back (act);
399         ActionManager::region_selection_sensitive_actions.push_back (act);
400         act = ActionManager::register_action (editor_actions, "raise-region", _("Raise Region"), mem_fun(*this, &Editor::raise_region));
401         ActionManager::session_sensitive_actions.push_back (act);
402         ActionManager::region_selection_sensitive_actions.push_back (act);
403         act = ActionManager::register_action (editor_actions, "lower-region", _("Lower Region"), mem_fun(*this, &Editor::lower_region));
404         ActionManager::session_sensitive_actions.push_back (act);
405         ActionManager::region_selection_sensitive_actions.push_back (act);
406         act = ActionManager::register_action (editor_actions, "export-region", _("Export Region"), mem_fun(*this, &Editor::export_region));
407         ActionManager::session_sensitive_actions.push_back (act);
408         ActionManager::region_selection_sensitive_actions.push_back (act);
409         act = ActionManager::register_toggle_action (editor_actions, "lock-region", _("Lock Region"), mem_fun(*this, &Editor::toggle_region_lock));
410         ActionManager::session_sensitive_actions.push_back (act);
411         ActionManager::region_selection_sensitive_actions.push_back (act);
412         act = ActionManager::register_toggle_action (editor_actions, "glue-region", _("Glue Region To Bars&Beats"), bind (mem_fun (*this, &Editor::set_region_lock_style), Region::MusicTime));
413         ActionManager::session_sensitive_actions.push_back (act);
414         ActionManager::region_selection_sensitive_actions.push_back (act);
415         act = ActionManager::register_action (editor_actions, "naturalize-region", _("Move To Original Position"), mem_fun (*this, &Editor::naturalize));
416         ActionManager::session_sensitive_actions.push_back (act);
417         ActionManager::region_selection_sensitive_actions.push_back (act);
418         act = ActionManager::register_action (editor_actions, "reverse-region", _("Reverse"), mem_fun (*this, &Editor::reverse_region));
419         ActionManager::session_sensitive_actions.push_back (act);
420         ActionManager::region_selection_sensitive_actions.push_back (act);
421         act = ActionManager::register_action (editor_actions, "monoize-region", _("Make mono regions"), (mem_fun(*this, &Editor::split_multichannel_region)));
422         ActionManager::session_sensitive_actions.push_back (act);
423         ActionManager::region_selection_sensitive_actions.push_back (act);
424         act = ActionManager::register_action (editor_actions, "region-fill-track", _("Fill Track"), (mem_fun(*this, &Editor::region_fill_track)));
425         ActionManager::session_sensitive_actions.push_back (act);
426         ActionManager::region_selection_sensitive_actions.push_back (act);
427         act = ActionManager::register_action (editor_actions, "mute-unmute-region", _("Mute/Unmute Region"), mem_fun(*this, &Editor::kbd_mute_unmute_region));
428         ActionManager::session_sensitive_actions.push_back (act);
429         ActionManager::region_selection_sensitive_actions.push_back (act);
430
431         undo_action = act = ActionManager::register_action (editor_actions, "undo", _("Undo"), bind (mem_fun(*this, &Editor::undo), 1U));
432         ActionManager::session_sensitive_actions.push_back (act);
433         redo_action = act = ActionManager::register_action (editor_actions, "redo", _("Redo"), bind (mem_fun(*this, &Editor::redo), 1U));
434         ActionManager::session_sensitive_actions.push_back (act);
435
436         act = ActionManager::register_action (editor_actions, "export-session", _("Export Session"), mem_fun(*this, &Editor::export_session));
437         ActionManager::session_sensitive_actions.push_back (act);
438         act = ActionManager::register_action (editor_actions, "export-range", _("Export Range"), mem_fun(*this, &Editor::export_selection));
439         ActionManager::session_sensitive_actions.push_back (act);
440
441         act = ActionManager::register_action (editor_actions, "editor-separate", _("Separate"), mem_fun(*this, &Editor::separate_region_from_selection));
442         ActionManager::session_sensitive_actions.push_back (act);
443         ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
444         act = ActionManager::register_action (editor_actions, "separate-from-punch", _("Separate Using Punch Range"), mem_fun(*this, &Editor::separate_region_from_punch));
445         ActionManager::session_sensitive_actions.push_back (act);
446         ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
447         act = ActionManager::register_action (editor_actions, "separate-from-loop", _("Separate Using Loop Range"), mem_fun(*this, &Editor::separate_region_from_loop));
448         ActionManager::session_sensitive_actions.push_back (act);
449         ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
450         act = ActionManager::register_action (editor_actions, "editor-crop", _("Crop"), mem_fun(*this, &Editor::crop_region_to_selection));
451         ActionManager::session_sensitive_actions.push_back (act);
452         ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
453         act = ActionManager::register_action (editor_actions, "editor-cut", _("Cut"), mem_fun(*this, &Editor::cut));
454         ActionManager::session_sensitive_actions.push_back (act);
455         /* Note: for now, editor-delete does the exact same thing as editor-cut */
456         act = ActionManager::register_action (editor_actions, "editor-delete", _("Delete"), mem_fun(*this, &Editor::cut));
457         ActionManager::session_sensitive_actions.push_back (act);
458         act = ActionManager::register_action (editor_actions, "editor-copy", _("Copy"), mem_fun(*this, &Editor::copy));
459         ActionManager::session_sensitive_actions.push_back (act);
460         act = ActionManager::register_action (editor_actions, "editor-paste", _("Paste"), mem_fun(*this, &Editor::keyboard_paste));
461         ActionManager::session_sensitive_actions.push_back (act);
462
463         act = ActionManager::register_action (editor_actions, "set-tempo-from-region", _("Set Tempo from Region=Bar"), mem_fun(*this, &Editor::use_region_as_bar));
464         ActionManager::session_sensitive_actions.push_back (act);
465         ActionManager::region_selection_sensitive_actions.push_back (act);
466         act = ActionManager::register_action (editor_actions, "set-tempo-from-edit-range", _("Set Tempo from Edit Range=Bar"), mem_fun(*this, &Editor::use_range_as_bar));
467         ActionManager::session_sensitive_actions.push_back (act);
468
469         act = ActionManager::register_action (editor_actions, "split-region-at-transients", _("Split Regions At Percussion Onsets"), mem_fun(*this, &Editor::split_region_at_transients));
470         ActionManager::session_sensitive_actions.push_back (act);
471         ActionManager::region_selection_sensitive_actions.push_back (act);
472         act = ActionManager::register_action (editor_actions, "toggle-rhythm-ferret", _("Rhythm Ferret"), mem_fun(*this, &Editor::show_rhythm_ferret));
473         ActionManager::session_sensitive_actions.push_back (act);
474
475         act = ActionManager::register_action (editor_actions, "tab-to-transient-forwards", _("Move Forward to Transient"), bind (mem_fun(*this, &Editor::tab_to_transient), true));
476         ActionManager::session_sensitive_actions.push_back (act);
477         act = ActionManager::register_action (editor_actions, "tab-to-transient-backwards", _("Move Backwards to Transient"), bind (mem_fun(*this, &Editor::tab_to_transient), false));
478         ActionManager::session_sensitive_actions.push_back (act);
479
480         act = ActionManager::register_action (editor_actions, "crop", _("Crop"), mem_fun(*this, &Editor::crop_region_to_selection));
481         ActionManager::session_sensitive_actions.push_back (act);
482         act = ActionManager::register_action (editor_actions, "insert-chunk", _("Insert Chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f));
483         ActionManager::session_sensitive_actions.push_back (act);
484
485         act = ActionManager::register_action (editor_actions, "split-at-edit-cursor", _("Split At Edit Point"), mem_fun(*this, &Editor::split_region));
486         ActionManager::edit_point_in_region_sensitive_actions.push_back (act);
487
488         act = ActionManager::register_action (editor_actions, "start-range", _("Start Range"), mem_fun(*this, &Editor::keyboard_selection_begin));
489         ActionManager::session_sensitive_actions.push_back (act);
490         act = ActionManager::register_action (editor_actions, "finish-range", _("Finish Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), false));
491         ActionManager::session_sensitive_actions.push_back (act);
492         act = ActionManager::register_action (editor_actions, "finish-add-range", _("Finish add Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), true));
493         ActionManager::session_sensitive_actions.push_back (act);
494
495         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));
496         ActionManager::session_sensitive_actions.push_back (act);
497         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));
498         ActionManager::session_sensitive_actions.push_back (act);
499
500         act = ActionManager::register_toggle_action (editor_actions, "toggle-follow-playhead", _("Follow Playhead"), (mem_fun(*this, &Editor::toggle_follow_playhead)));
501         ActionManager::session_sensitive_actions.push_back (act);
502         act = ActionManager::register_action (editor_actions, "remove-last-capture", _("Remove Last Capture"), (mem_fun(*this, &Editor::remove_last_capture)));
503         ActionManager::session_sensitive_actions.push_back (act);
504
505         act = ActionManager::register_action (editor_actions, "insert-time", _("Insert Time"), (mem_fun(*this, &Editor::do_insert_time)));
506         ActionManager::session_sensitive_actions.push_back (act);
507         ActionManager::track_selection_sensitive_actions.push_back (act);
508
509         act = ActionManager::register_action (editor_actions, "toggle-track-active", _("Toggle Active"), (mem_fun(*this, &Editor::toggle_tracks_active)));
510         ActionManager::session_sensitive_actions.push_back (act);
511         ActionManager::track_selection_sensitive_actions.push_back (act);
512         act = ActionManager::register_action (editor_actions, "remove-track", _("Remove"), (mem_fun(*this, &Editor::remove_tracks)));
513         ActionManager::session_sensitive_actions.push_back (act);
514         ActionManager::track_selection_sensitive_actions.push_back (act);
515
516         act = ActionManager::register_action (editor_actions, "track-height-largest", _("Largest"), (mem_fun(*this, &Editor::set_track_height_largest)));
517         ActionManager::session_sensitive_actions.push_back (act);
518         ActionManager::track_selection_sensitive_actions.push_back (act);
519         act = ActionManager::register_action (editor_actions, "track-height-larger", _("Larger"), (mem_fun(*this, &Editor::set_track_height_larger)));
520         ActionManager::session_sensitive_actions.push_back (act);
521         ActionManager::track_selection_sensitive_actions.push_back (act);
522         act = ActionManager::register_action (editor_actions, "track-height-large", _("Large"), (mem_fun(*this, &Editor::set_track_height_large)));
523         ActionManager::session_sensitive_actions.push_back (act);
524         ActionManager::track_selection_sensitive_actions.push_back (act);
525         act = ActionManager::register_action (editor_actions, "track-height-normal", _("Normal"), (mem_fun(*this, &Editor::set_track_height_normal)));
526         ActionManager::session_sensitive_actions.push_back (act);
527         ActionManager::track_selection_sensitive_actions.push_back (act);
528         act = ActionManager::register_action (editor_actions, "track-height-small", _("Small"), (mem_fun(*this, &Editor::set_track_height_small)));
529         ActionManager::track_selection_sensitive_actions.push_back (act);
530         ActionManager::session_sensitive_actions.push_back (act);
531         ActionManager::track_selection_sensitive_actions.push_back (act);
532         act = ActionManager::register_action (editor_actions, "track-height-smaller", _("Smaller"), (mem_fun(*this, &Editor::set_track_height_smaller)));
533         ActionManager::session_sensitive_actions.push_back (act);
534         ActionManager::track_selection_sensitive_actions.push_back (act);
535
536         Glib::RefPtr<ActionGroup> zoom_actions = ActionGroup::create (X_("Zoom"));
537         RadioAction::Group zoom_group;
538
539         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-left", _("Zoom Focus Left"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusLeft));
540         ActionManager::session_sensitive_actions.push_back (act);
541         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-right", _("Zoom Focus Right"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusRight));
542         ActionManager::session_sensitive_actions.push_back (act);
543         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-center", _("Zoom Focus Center"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusCenter));
544         ActionManager::session_sensitive_actions.push_back (act);
545         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-playhead", _("Zoom Focus Playhead"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusPlayhead));
546         ActionManager::session_sensitive_actions.push_back (act);
547         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-mouse", _("Zoom Focus Mouse"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusMouse));
548         ActionManager::session_sensitive_actions.push_back (act);
549         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-edit", _("Zoom Focus Edit"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusEdit));
550         ActionManager::session_sensitive_actions.push_back (act);
551
552         Glib::RefPtr<ActionGroup> mouse_mode_actions = ActionGroup::create (X_("MouseMode"));
553         RadioAction::Group mouse_mode_group;
554
555         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));
556         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));
557         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));
558         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));
559         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));
560
561         RadioAction::Group edit_point_group;
562         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-playhead"), _("Playhead"), (bind (mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
563         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-mouse"), _("Mouse"), (bind (mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
564         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)));
565
566         ActionManager::register_action (editor_actions, "cycle-edit-point", _("Change edit point"), bind (mem_fun (*this, &Editor::cycle_edit_point), false));
567         ActionManager::register_action (editor_actions, "cycle-edit-point-with-marker", _("Change edit point (w/Marker)"), bind (mem_fun (*this, &Editor::cycle_edit_point), true));
568
569         ActionManager::register_action (editor_actions, "set-edit-splice", _("Splice"), bind (mem_fun (*this, &Editor::set_edit_mode), Splice));
570         ActionManager::register_action (editor_actions, "set-edit-slide", _("Slide"), bind (mem_fun (*this, &Editor::set_edit_mode), Slide));
571         ActionManager::register_action (editor_actions, "set-edit-lock", _("Lock"), bind (mem_fun (*this, &Editor::set_edit_mode), Lock));
572         ActionManager::register_action (editor_actions, "toggle-edit-mode", _("Toggle Edit Mode"), mem_fun (*this, &Editor::cycle_edit_mode));
573
574         ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap To"));
575         ActionManager::register_action (editor_actions, X_("SnapMode"), _("Snap Mode"));
576
577         RadioAction::Group snap_mode_group;
578         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-off"), _("No Grid"), (bind (mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapOff)));
579         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-normal"), _("Grid"), (bind (mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapNormal)));
580         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-magnetic"), _("Magnetic"), (bind (mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapMagnetic)));
581
582         ActionManager::register_action (editor_actions, X_("cycle-snap-mode"), _("Next Snap Mode"), mem_fun (*this, &Editor::cycle_snap_mode));
583         ActionManager::register_action (editor_actions, X_("cycle-snap-choice"), _("Next Snap Choice"), mem_fun (*this, &Editor::cycle_snap_choice));
584
585         Glib::RefPtr<ActionGroup> snap_actions = ActionGroup::create (X_("Snap"));
586         RadioAction::Group snap_choice_group;
587
588         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)));
589         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)));
590         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)));
591         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)));
592         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)));
593         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)));
594         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)));
595         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)));
596         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)));
597         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)));
598         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)));
599         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)));
600         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)));
601         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)));
602         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)));
603         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)));
604         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)));
605         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)));
606
607         /* RULERS */
608         
609         Glib::RefPtr<ActionGroup> ruler_actions = ActionGroup::create (X_("Rulers"));
610         ruler_tempo_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-tempo-ruler"), _("Tempo"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_tempo)));
611         ruler_meter_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-meter-ruler"), _("Meter"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_meter)));
612         ruler_range_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-range-ruler"), _("Ranges"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_range_marker)));
613         ruler_marker_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-marker-ruler"), _("Markers"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_marker)));
614         ruler_cd_marker_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-cd-marker-ruler"), _("CD Markers"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_cd_marker)));
615         ruler_loop_punch_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-loop-punch-ruler"), _("Loop/Punch"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_transport_marker)));
616         ruler_bbt_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-bbt-ruler"), _("Bars & Beats"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_frames)));
617         ruler_samples_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-samples-ruler"), _("Samples"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_bbt)));
618         ruler_timecode_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-timecode-ruler"), _("Timecode"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_smpte)));
619         ruler_minsec_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-minsec-ruler"), _("Min:Sec"), bind (mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_minsec)));
620
621         /* set defaults here */
622
623         no_ruler_shown_update = true;
624         ruler_meter_action->set_active (true);
625         ruler_tempo_action->set_active (true);
626         ruler_marker_action->set_active (true);
627         ruler_range_action->set_active (true);
628         if (Profile->get_sae()) {
629                 ruler_cd_marker_action->set_active (false);
630                 ruler_timecode_action->set_active (false);
631                 ruler_minsec_action->set_active (true);
632         } else {
633                 ruler_cd_marker_action->set_active (true);
634                 ruler_timecode_action->set_active (true);
635                 ruler_minsec_action->set_active (false);
636         }
637         ruler_samples_action->set_active (false);
638         no_ruler_shown_update = false;
639         
640         /* REGION LIST */
641
642         Glib::RefPtr<ActionGroup> rl_actions = ActionGroup::create (X_("RegionList"));
643         RadioAction::Group sort_type_group;
644         RadioAction::Group sort_order_group;
645
646         /* the region list popup menu */
647         ActionManager::register_action (rl_actions, X_("RegionListSort"), _("Sort"));
648
649         act = ActionManager::register_action (rl_actions, X_("rlAudition"), _("Audition"), mem_fun(*this, &Editor::audition_region_from_region_list));
650         ActionManager::region_list_selection_sensitive_actions.push_back (act);
651         act = ActionManager::register_action (rl_actions, X_("rlHide"), _("Hide"), mem_fun(*this, &Editor::hide_region_from_region_list));
652         ActionManager::region_list_selection_sensitive_actions.push_back (act);
653         act = ActionManager::register_action (rl_actions, X_("rlRemove"), _("Remove"), mem_fun (*this, &Editor::remove_region_from_region_list));
654         ActionManager::region_list_selection_sensitive_actions.push_back (act);
655         ActionManager::register_toggle_action (rl_actions, X_("rlShowAll"), _("Show all"), mem_fun(*this, &Editor::toggle_full_region_list));
656         ActionManager::register_toggle_action (rl_actions, X_("rlShowAuto"), _("Show automatic regions"), mem_fun(*this, &Editor::toggle_show_auto_regions));
657
658         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortAscending"),  _("Ascending"),
659                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), true));
660         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortDescending"),   _("Descending"),
661                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), false));
662         
663         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionName"),  _("By Region Name"),
664                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByName));
665         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionLength"),  _("By Region Length"),
666                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByLength));
667         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionPosition"),  _("By Region Position"),
668                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByPosition));
669         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionTimestamp"),  _("By Region Timestamp"),
670                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByTimestamp));
671         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionStartinFile"),  _("By Region Start in File"),
672                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByStartInFile));
673         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionEndinFile"),  _("By Region End in File"),
674                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByEndInFile));
675         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileName"),  _("By Source File Name"),
676                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileName));
677         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileLength"),  _("By Source File Length"),
678                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileLength));
679         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileCreationDate"),  _("By Source File Creation Date"),
680                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileCreationDate));
681         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFilesystem"),  _("By Source Filesystem"),
682                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileFS));
683
684
685         /* the next two are duplicate items with different names for use in two different contexts */
686
687         ActionManager::register_action (editor_actions, X_("addExistingAudioFiles"), _("Import"), mem_fun (*this, &Editor::external_audio_dialog));
688
689         act = ActionManager::register_action (editor_actions, X_("addExternalAudioToRegionList"), _("Import to Region List"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion));
690         ActionManager::session_sensitive_actions.push_back (act);
691
692         ActionManager::register_toggle_action (editor_actions, X_("toggle-waveform-visible"), _("Show Waveforms"), mem_fun (*this, &Editor::toggle_waveform_visibility));
693         ActionManager::track_selection_sensitive_actions.push_back (act);
694         ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformsWhileRecording"), _("Show Waveforms While Recording"), mem_fun (*this, &Editor::toggle_waveforms_while_recording));
695         ActionManager::register_toggle_action (editor_actions, X_("ToggleMeasureVisibility"), _("Show Measures"), mem_fun (*this, &Editor::toggle_measure_visibility));
696
697
698         RadioAction::Group waveform_scale_group;
699         act = ActionManager::register_radio_action (editor_actions, waveform_scale_group, X_("linear-waveforms"), _("Linear"), bind (mem_fun (*this, &Editor::waveform_scale_chosen), Editing::LinearWaveform));
700         ActionManager::track_selection_sensitive_actions.push_back (act);
701         act = ActionManager::register_radio_action (editor_actions, waveform_scale_group, X_("logarithmic-waveforms"), _("Logarithmic"), bind (mem_fun (*this, &Editor::waveform_scale_chosen), Editing::LogWaveform));
702         ActionManager::track_selection_sensitive_actions.push_back (act);
703
704         /* if there is a logo in the editor canvas, its always visible at startup */
705
706         act = ActionManager::register_toggle_action (editor_actions, X_("ToggleLogoVisibility"), _("Show Logo"), mem_fun (*this, &Editor::toggle_logo_visibility));
707         Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
708         tact->set_active (true);
709         
710         RadioAction::Group layer_model_group;
711
712         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerLaterHigher"), _("Later is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), LaterHigher));
713         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));
714         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));
715
716         RadioAction::Group smpte_group;
717
718         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte23976"), _("23.976"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_23976));
719         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte24"), _("24"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_24));
720         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte24976"), _("24.976"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_24976));
721         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte25"), _("25"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_25));
722         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte2997"), _("29.97"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_2997));
723         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte2997drop"), _("29.97 drop"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_2997drop));
724         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte30"), _("30"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_30));
725         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte30drop"), _("30 drop"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_30drop));
726         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte5994"), _("59.94"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_5994));
727         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte60"), _("60"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_60));
728
729         RadioAction::Group pullup_group;
730
731         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));
732         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4"), _("+4.1667%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4));
733         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));
734         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus1"), _("+ 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus1));
735         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupNone"), _("None"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_None));
736         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus1"), _("- 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus1));
737         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));
738         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4"), _("-4.1667%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4));
739         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));
740
741         RadioAction::Group subframe_group;
742
743         ActionManager::register_radio_action (editor_actions, subframe_group,  X_("Subframes80"), _("80 per frame"), bind (mem_fun (*this, 
744 &Editor::subframes_per_frame_chosen), 80));
745         ActionManager::register_radio_action (editor_actions, subframe_group,  X_("Subframes100"), _("100 per frame"), bind (mem_fun (*this, 
746 &Editor::subframes_per_frame_chosen), 100));
747
748         ActionManager::add_action_group (rl_actions);
749         ActionManager::add_action_group (ruler_actions);
750         ActionManager::add_action_group (zoom_actions);
751         ActionManager::add_action_group (mouse_mode_actions);
752         ActionManager::add_action_group (snap_actions);
753         ActionManager::add_action_group (editor_actions);
754 }
755
756 void
757 Editor::toggle_ruler_visibility (RulerType rt)
758 {
759         const char* action = 0;
760
761         if (no_ruler_shown_update) {
762                 return;
763         }
764
765         switch (rt) {
766         case ruler_metric_smpte:
767                 action = "toggle-timecode-ruler";
768                 break;
769         case ruler_metric_bbt:
770                 action = "toggle-bbt-ruler";
771                 break;
772         case ruler_metric_frames:
773                 action = "toggle-samples-ruler";
774                 break;
775         case ruler_metric_minsec:
776                 action = "toggle-minsec-ruler";
777                 break;
778         case ruler_time_tempo:
779                 action = "toggle-tempo-ruler";
780                 break;
781         case ruler_time_meter:
782                 action = "toggle-meter-ruler";
783                 break;
784         case ruler_time_marker:
785                 action = "toggle-marker-ruler";
786                 break;
787         case ruler_time_range_marker:
788                 action = "toggle-range-ruler";
789                 break;
790         case ruler_time_transport_marker:
791                 action = "toggle-loop-punch-ruler";
792                 break;
793         case ruler_time_cd_marker:
794                 action = "toggle-cd-marker-ruler";
795                 break;
796         }
797
798         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), action);
799         if (act) {
800                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
801                 update_ruler_visibility ();
802                 store_ruler_visibility ();
803         }
804 }
805
806 void
807 Editor::toggle_waveform_visibility ()
808 {
809         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-waveform-visible"));
810         if (act) {
811                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
812                 set_show_waveforms (tact->get_active());
813         }
814 }
815
816 void
817 Editor::toggle_waveforms_while_recording ()
818 {
819         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
820         if (act) {
821                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
822                 set_show_waveforms_recording (tact->get_active());
823         }
824 }
825
826 void
827 Editor::toggle_measure_visibility ()
828 {
829         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
830         if (act) {
831                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
832                 set_show_measures (tact->get_active());
833         }
834 }
835
836 void
837 Editor::toggle_logo_visibility ()
838 {
839         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleLogoVisibility"));
840
841         if (act) {
842                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
843                 if (logo_item) {
844                         if (tact->get_active()) {
845                                 logo_item->show ();
846                         } else {
847                                 logo_item->hide ();
848                         }
849                 }
850         }
851 }
852
853 void
854 Editor::waveform_scale_chosen (Editing::WaveformScale ws)
855 {
856         RefPtr<Action> act;
857
858         /* this is driven by a toggle on a radio group, and so is invoked twice,
859            once for the item that became inactive and once for the one that became
860            active.
861         */
862
863         switch (ws) {
864         case LinearWaveform:
865                 act = ActionManager::get_action (X_("Editor"), X_("linear-waveforms"));
866                 break;
867         case LogWaveform:
868                 act = ActionManager::get_action (X_("Editor"), X_("logarithmic-waveforms"));
869                 break;
870         }
871         
872         if (act) {
873                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
874                 if (ract && ract->get_active()) {
875                         set_waveform_scale (ws);
876                 }
877         }
878 }
879
880 void
881 Editor::set_crossfade_model (CrossfadeModel model)
882 {
883         RefPtr<Action> act;
884
885         /* this is driven by a toggle on a radio group, and so is invoked twice,
886            once for the item that became inactive and once for the one that became
887            active.
888         */
889
890         switch (model) {
891         case FullCrossfade:
892                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
893                 break;
894         case ShortCrossfade:
895                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
896                 break;
897         }
898         
899         if (act) {
900                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
901                 if (ract && ract->get_active()) {
902                         Config->set_xfade_model (model);
903                 }
904         }
905 }
906
907 void
908 Editor::update_crossfade_model ()
909 {
910         RefPtr<Action> act;
911
912         switch (Config->get_xfade_model()) {
913         case FullCrossfade:
914                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
915                 break;
916         case ShortCrossfade:
917                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
918                 break;
919         }
920
921         if (act) {
922                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
923                 if (ract && !ract->get_active()) {
924                         ract->set_active (true);
925                 }
926         }
927 }
928
929
930 void
931 Editor::update_smpte_mode ()
932 {
933         ENSURE_GUI_THREAD(mem_fun(*this, &Editor::update_smpte_mode));
934
935         RefPtr<Action> act;
936         const char* action = 0;
937
938         switch (Config->get_smpte_format()) {
939         case smpte_23976:
940                 action = X_("Smpte23976");
941                 break;
942         case smpte_24:
943                 action = X_("Smpte24");
944                 break;
945         case smpte_24976:
946                 action = X_("Smpte24976");
947                 break;
948         case smpte_25:
949                 action = X_("Smpte25");
950                 break;
951         case smpte_2997:
952                 action = X_("Smpte2997");
953                 break;
954         case smpte_2997drop:
955                 action = X_("Smpte2997drop");
956                 break;
957         case smpte_30:
958                 action = X_("Smpte30");
959                 break;
960         case smpte_30drop:
961                 action = X_("Smpte30drop");
962                 break;
963         case smpte_5994:
964                 action = X_("Smpte5994");
965                 break;
966         case smpte_60:
967                 action = X_("Smpte60");
968                 break;
969         }
970
971         act = ActionManager::get_action (X_("Editor"), action);
972
973         if (act) {
974                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
975                 if (ract && !ract->get_active()) {
976                         ract->set_active (true);
977                 }
978         }
979 }
980
981 void
982 Editor::update_video_pullup ()
983 {
984         ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_video_pullup));
985
986         RefPtr<Action> act;
987         const char* action = 0;
988
989         float pullup = Config->get_video_pullup();
990
991         if ( pullup < (-4.1667 - 0.1) * 0.99) {
992                 action = X_("PullupMinus4Minus1");
993         } else if ( pullup < (-4.1667) * 0.99 ) {
994                 action = X_("PullupMinus4");
995         } else if ( pullup < (-4.1667 + 0.1) * 0.99 ) {
996                 action = X_("PullupMinus4Plus1");
997         } else if ( pullup < (-0.1) * 0.99 ) {
998                 action = X_("PullupMinus1");
999         } else if (pullup > (4.1667 + 0.1) * 0.99 ) {
1000                 action = X_("PullupPlus4Plus1");
1001         } else if ( pullup > (4.1667) * 0.99 ) {
1002                 action = X_("PullupPlus4");
1003         } else if ( pullup > (4.1667 - 0.1) * 0.99) {
1004                 action = X_("PullupPlus4Minus1");
1005         } else if ( pullup > (0.1) * 0.99 ) {
1006                 action = X_("PullupPlus1");
1007         } else {
1008                 action = X_("PullupNone");
1009         }
1010
1011         act = ActionManager::get_action (X_("Editor"), action);
1012
1013         if (act) {
1014                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1015                 if (ract && !ract->get_active()) {
1016                         ract->set_active (true);
1017                 }
1018         }
1019 }
1020
1021 void
1022 Editor::update_layering_model ()
1023 {
1024         RefPtr<Action> act;
1025
1026         switch (Config->get_layer_model()) {
1027         case LaterHigher:
1028                 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
1029                 break;
1030         case MoveAddHigher:
1031                 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
1032                 break;
1033         case AddHigher:
1034                 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
1035                 break;
1036         }
1037
1038         if (act) {
1039                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1040                 if (ract && !ract->get_active()) {
1041                         ract->set_active (true);
1042                 }
1043         }
1044 }
1045
1046 void
1047 Editor::set_layer_model (LayerModel model)
1048 {
1049         /* this is driven by a toggle on a radio group, and so is invoked twice,
1050            once for the item that became inactive and once for the one that became
1051            active.
1052         */
1053
1054         RefPtr<Action> act;
1055
1056         switch (model) {
1057         case LaterHigher:
1058                 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
1059                 break;
1060         case MoveAddHigher:
1061                 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
1062                 break;
1063         case AddHigher:
1064                 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
1065                 break;
1066         }
1067         
1068         if (act) {
1069                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1070                 if (ract && ract->get_active() && Config->get_layer_model() != model) {
1071                         Config->set_layer_model (model);
1072                 }
1073         }
1074 }
1075
1076 RefPtr<RadioAction>
1077 Editor::snap_type_action (SnapType type)
1078 {
1079
1080         const char* action = 0;
1081         RefPtr<Action> act;
1082         
1083         switch (type) {
1084         case Editing::SnapToCDFrame:
1085                 action = "snap-to-cd-frame";
1086                 break;
1087         case Editing::SnapToSMPTEFrame:
1088                 action = "snap-to-smpte-frame";
1089                 break;
1090         case Editing::SnapToSMPTESeconds:
1091                 action = "snap-to-smpte-seconds";
1092                 break;
1093         case Editing::SnapToSMPTEMinutes:
1094                 action = "snap-to-smpte-minutes";
1095                 break;
1096         case Editing::SnapToSeconds:
1097                 action = "snap-to-seconds";
1098                 break;
1099         case Editing::SnapToMinutes:
1100                 action = "snap-to-minutes";
1101                 break;
1102         case Editing::SnapToAThirtysecondBeat:
1103                 action = "snap-to-thirtyseconds";
1104                 break;
1105         case Editing::SnapToASixteenthBeat:
1106                 action = "snap-to-asixteenthbeat";
1107                 break;
1108         case Editing::SnapToAEighthBeat:
1109                 action = "snap-to-eighths";
1110                 break;
1111         case Editing::SnapToAQuarterBeat:
1112                 action = "snap-to-quarters";
1113                 break;
1114         case Editing::SnapToAThirdBeat:
1115                 action = "snap-to-thirds";
1116                 break;
1117         case Editing::SnapToBeat:
1118                 action = "snap-to-beat";
1119                 break;
1120         case Editing::SnapToBar:
1121                 action = "snap-to-bar";
1122                 break;
1123         case Editing::SnapToMark:
1124                 action = "snap-to-mark";
1125                 break;
1126         case Editing::SnapToRegionStart:
1127                 action = "snap-to-region-start";
1128                 break;
1129         case Editing::SnapToRegionEnd:
1130                 action = "snap-to-region-end";
1131                 break;
1132         case Editing::SnapToRegionSync:
1133                 action = "snap-to-region-sync";
1134                 break;
1135         case Editing::SnapToRegionBoundary:
1136                 action = "snap-to-region-boundary";
1137                 break;
1138         default:
1139                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap-to type", (int) type) << endmsg;
1140                 /*NOTREACHED*/
1141         }
1142
1143         act = ActionManager::get_action (X_("Snap"), action);
1144
1145         if (act) {
1146                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1147                 return ract;
1148
1149         } else  {
1150                 error << string_compose (_("programming error: %1"), "Editor::snap_type_chosen could not find action to match type.") << endmsg;
1151                 return RefPtr<RadioAction>();
1152         }
1153 }
1154
1155 void
1156 Editor::cycle_snap_choice()
1157 {
1158         switch (snap_type) {
1159         case Editing::SnapToCDFrame:
1160                 set_snap_to (Editing::SnapToSMPTEFrame);
1161                 break;
1162         case Editing::SnapToSMPTEFrame:
1163                 set_snap_to (Editing::SnapToSMPTESeconds);
1164                 break;
1165         case Editing::SnapToSMPTESeconds:
1166                 set_snap_to (Editing::SnapToSMPTEMinutes);
1167                 break;
1168         case Editing::SnapToSMPTEMinutes:
1169                 set_snap_to (Editing::SnapToSeconds);
1170                 break;
1171         case Editing::SnapToSeconds:
1172                 set_snap_to (Editing::SnapToMinutes);
1173                 break;
1174         case Editing::SnapToMinutes:
1175                 set_snap_to (Editing::SnapToAThirtysecondBeat);
1176                 break;
1177         case Editing::SnapToAThirtysecondBeat:
1178                 set_snap_to (Editing::SnapToASixteenthBeat);
1179                 break;
1180         case Editing::SnapToASixteenthBeat:
1181                 set_snap_to (Editing::SnapToAEighthBeat);
1182                 break;
1183         case Editing::SnapToAEighthBeat:
1184                 set_snap_to (Editing::SnapToAQuarterBeat);
1185                 break;
1186         case Editing::SnapToAQuarterBeat:
1187                 set_snap_to (Editing::SnapToAThirdBeat);
1188                 break;
1189         case Editing::SnapToAThirdBeat:
1190                 set_snap_to (Editing::SnapToBeat);
1191                 break;
1192         case Editing::SnapToBeat:
1193                 set_snap_to (Editing::SnapToBar);
1194                 break;
1195         case Editing::SnapToBar:
1196                 set_snap_to (Editing::SnapToMark);
1197                 break;
1198         case Editing::SnapToMark:
1199                 set_snap_to (Editing::SnapToRegionStart);
1200                 break;
1201         case Editing::SnapToRegionStart:
1202                 set_snap_to (Editing::SnapToRegionEnd);
1203                 break;
1204         case Editing::SnapToRegionEnd:
1205                 set_snap_to (Editing::SnapToRegionSync);
1206                 break;
1207         case Editing::SnapToRegionSync:
1208                 set_snap_to (Editing::SnapToRegionBoundary);
1209                 break;
1210         case Editing::SnapToRegionBoundary:
1211                 set_snap_to (Editing::SnapToCDFrame);
1212                 break;
1213         }
1214 }
1215
1216 void
1217 Editor::snap_type_chosen (SnapType type)
1218 {
1219         /* this is driven by a toggle on a radio group, and so is invoked twice,
1220            once for the item that became inactive and once for the one that became
1221            active.
1222         */
1223
1224         RefPtr<RadioAction> ract = snap_type_action (type);
1225
1226         if (ract && ract->get_active()) {
1227                 set_snap_to (type);
1228         }
1229 }
1230
1231 RefPtr<RadioAction>
1232 Editor::snap_mode_action (SnapMode mode)
1233 {
1234         const char* action = 0;
1235         RefPtr<Action> act;
1236         
1237         switch (mode) {
1238         case Editing::SnapOff:
1239                 action = X_("snap-off");
1240                 break;
1241         case Editing::SnapNormal:
1242                 action = X_("snap-normal");
1243                 break;
1244         case Editing::SnapMagnetic:
1245                 action = X_("snap-magnetic");
1246                 break;
1247         default:
1248                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap mode type", (int) mode) << endmsg;
1249                 /*NOTREACHED*/
1250         }
1251         
1252         act = ActionManager::get_action (X_("Editor"), action);
1253         
1254         if (act) {
1255                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1256                 return ract;
1257                 
1258         } else  {
1259                 error << string_compose (_("programming error: %1: %2"), "Editor::snap_mode_chosen could not find action to match mode.", action) << endmsg;
1260                 return RefPtr<RadioAction> ();
1261         }
1262 }
1263
1264 void
1265 Editor::cycle_snap_mode ()
1266 {
1267         switch (snap_mode) {
1268         case SnapOff:
1269                 set_snap_mode (SnapNormal);
1270                 break;
1271         case SnapNormal:
1272                 set_snap_mode (SnapMagnetic);
1273                 break;
1274         case SnapMagnetic:
1275                 set_snap_mode (SnapOff);
1276                 break;
1277         }
1278 }
1279
1280 void
1281 Editor::snap_mode_chosen (SnapMode mode)
1282 {
1283         /* this is driven by a toggle on a radio group, and so is invoked twice,
1284            once for the item that became inactive and once for the one that became
1285            active.
1286         */
1287
1288         RefPtr<RadioAction> ract = snap_mode_action (mode);
1289
1290         if (ract && ract->get_active()) {
1291                 set_snap_mode (mode);
1292         }
1293 }
1294
1295 RefPtr<RadioAction>
1296 Editor::edit_point_action (EditPoint ep)
1297 {
1298         const char* action = 0;
1299         RefPtr<Action> act;
1300         
1301         switch (ep) {
1302         case Editing::EditAtPlayhead:
1303                 action = X_("edit-at-playhead");
1304                 break;
1305         case Editing::EditAtSelectedMarker:
1306                 action = X_("edit-at-selected-marker");
1307                 break;
1308         case Editing::EditAtMouse:
1309                 action = X_("edit-at-mouse");
1310                 break;
1311         default:
1312                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible edit point type", (int) ep) << endmsg;
1313                 /*NOTREACHED*/
1314         }
1315         
1316         act = ActionManager::get_action (X_("Editor"), action);
1317         
1318         if (act) {
1319                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1320                 return ract;
1321                 
1322         } else  {
1323                 error << string_compose (_("programming error: %1: %2"), "Editor::edit_point_action could not find action to match edit point.", action) << endmsg;
1324                 return RefPtr<RadioAction> ();
1325         }
1326 }
1327
1328 void
1329 Editor::edit_point_chosen (EditPoint ep)
1330 {
1331         /* this is driven by a toggle on a radio group, and so is invoked twice,
1332            once for the item that became inactive and once for the one that became
1333            active.
1334         */
1335
1336         RefPtr<RadioAction> ract = edit_point_action (ep);
1337
1338         if (ract && ract->get_active()) {
1339                 set_edit_point_preference (ep);
1340         }
1341 }
1342
1343
1344 RefPtr<RadioAction>
1345 Editor::zoom_focus_action (ZoomFocus focus)
1346 {
1347         const char* action = 0;
1348         RefPtr<Action> act;
1349         
1350         switch (focus) {
1351         case ZoomFocusLeft:
1352                 action = X_("zoom-focus-left");
1353                 break;
1354         case ZoomFocusRight:
1355                 action = X_("zoom-focus-right");
1356                 break;
1357         case ZoomFocusCenter:
1358                 action = X_("zoom-focus-center");
1359                 break;
1360         case ZoomFocusPlayhead:
1361                 action = X_("zoom-focus-playhead");
1362                 break;
1363         case ZoomFocusMouse:
1364                 action = X_("zoom-focus-mouse");
1365                 break;
1366         case ZoomFocusEdit:
1367                 action = X_("zoom-focus-edit");
1368                 break;
1369         default:
1370                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible focus type", (int) focus) << endmsg;
1371                 /*NOTREACHED*/
1372         }
1373         
1374         act = ActionManager::get_action (X_("Zoom"), action);
1375         
1376         if (act) {
1377                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1378                 return ract;
1379         } else {
1380                 error << string_compose (_("programming error: %1: %2"), "Editor::zoom_focus_action could not find action to match focus.", action) << endmsg;
1381         }
1382
1383         return RefPtr<RadioAction> ();
1384 }
1385
1386 void
1387 Editor::zoom_focus_chosen (ZoomFocus focus)
1388 {
1389         /* this is driven by a toggle on a radio group, and so is invoked twice,
1390            once for the item that became inactive and once for the one that became
1391            active.
1392         */
1393
1394         RefPtr<RadioAction> ract = zoom_focus_action (focus);
1395
1396         if (ract && ract->get_active()) {
1397                 set_zoom_focus (focus);
1398         }
1399 }
1400
1401 void
1402 Editor::smpte_fps_chosen (SmpteFormat format)
1403 {
1404         /* this is driven by a toggle on a radio group, and so is invoked twice,
1405            once for the item that became inactive and once for the one that became
1406            active.
1407         */
1408
1409         if (session) {
1410
1411                 RefPtr<Action> act;
1412
1413                 switch (format) {
1414                         case smpte_23976: 
1415                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte23976"));
1416                          break;
1417                         case smpte_24: 
1418                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte24"));
1419                          break;
1420                         case smpte_24976: 
1421                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte24976"));
1422                          break;
1423                         case smpte_25: 
1424                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte25"));
1425                          break;
1426                         case smpte_2997: 
1427                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte2997"));
1428                          break;
1429                         case smpte_2997drop: 
1430                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte2997drop"));
1431                          break;
1432                         case smpte_30: 
1433                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte30"));
1434                          break;
1435                         case smpte_30drop: 
1436                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte30drop"));
1437                          break;
1438                         case smpte_5994: 
1439                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte5994"));
1440                          break;
1441                         case smpte_60: 
1442                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte60"));
1443                          break;
1444                         default:
1445                                 cerr << "Editor received unexpected smpte type" << endl;
1446                 }
1447
1448                 if (act) {
1449                         RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1450                         if (ract && ract->get_active()) {
1451                                 session->set_smpte_format (format);
1452                         }
1453                 }
1454         }
1455 }
1456
1457 void
1458 Editor::video_pullup_chosen (Session::PullupFormat pullup)
1459 {
1460         /* this is driven by a toggle on a radio group, and so is invoked twice,
1461            once for the item that became inactive and once for the one that became
1462            active.
1463         */
1464
1465         const char* action = 0;
1466
1467         RefPtr<Action> act;
1468         
1469         float pull = 0.0;
1470         
1471         switch (pullup) {
1472         case Session::pullup_Plus4Plus1:
1473                 pull = 4.1667 + 0.1;
1474                 action = X_("PullupPlus4Plus1");
1475                 break;
1476         case Session::pullup_Plus4:
1477                 pull = 4.1667;
1478                 action = X_("PullupPlus4");
1479                 break;
1480         case Session::pullup_Plus4Minus1:
1481                 pull = 4.1667 - 0.1;
1482                 action = X_("PullupPlus4Minus1");
1483                 break;
1484         case Session::pullup_Plus1:
1485                 pull = 0.1;
1486                 action = X_("PullupPlus1");
1487                 break;
1488         case Session::pullup_None:
1489                 pull = 0.0;
1490                 action = X_("PullupNone");
1491                 break;
1492         case Session::pullup_Minus1:
1493                 pull = -0.1;
1494                 action = X_("PullupMinus1");
1495                 break;
1496         case Session::pullup_Minus4Plus1:
1497                 pull = -4.1667 + 0.1;
1498                 action = X_("PullupMinus4Plus1");
1499                 break;
1500         case Session::pullup_Minus4:
1501                 pull = -4.1667;
1502                 action = X_("PullupMinus4");
1503                 break;
1504         case Session::pullup_Minus4Minus1:
1505                 pull = -4.1667 - 0.1;
1506                 action = X_("PullupMinus4Minus1");
1507                 break;
1508         default:
1509                 fatal << string_compose (_("programming error: %1"), "Session received unexpected pullup type") << endmsg;
1510                 /*NOTREACHED*/
1511         }
1512         
1513         act = ActionManager::get_action (X_("Editor"), action);
1514         
1515         if (act) {
1516                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1517                 if (ract && ract->get_active()) {
1518                         Config->set_video_pullup ( pull );
1519                 }
1520                 
1521         } else  {
1522                 error << string_compose (_("programming error: %1"), "Editor::video_pullup_chosen could not find action to match pullup.") << endmsg;
1523         }
1524 }
1525
1526 void
1527 Editor::update_subframes_per_frame ()
1528 {
1529         ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_subframes_per_frame));
1530
1531         RefPtr<Action> act;
1532         const char* action = 0;
1533
1534         uint32_t sfpf = Config->get_subframes_per_frame();
1535
1536         if (sfpf == 80) {
1537                 action = X_("Subframes80");
1538         } else if (sfpf == 100) {
1539                 action = X_("Subframes100");
1540         } else {
1541                 warning << string_compose (_("Configuraton is using unhandled subframes per frame value: %1"), sfpf) << endmsg;
1542                 /*NOTREACHED*/
1543                 return;
1544         }
1545
1546         act = ActionManager::get_action (X_("Editor"), action);
1547
1548         if (act) {
1549                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1550                 if (ract && !ract->get_active()) {
1551                         ract->set_active (true);
1552                 }
1553         }
1554 }
1555
1556 void
1557 Editor::subframes_per_frame_chosen (uint32_t sfpf)
1558 {
1559         /* this is driven by a toggle on a radio group, and so is invoked twice,
1560            once for the item that became inactive and once for the one that became
1561            active.
1562         */
1563
1564         const char* action = 0;
1565
1566         RefPtr<Action> act;
1567         
1568         if (sfpf == 80) {
1569                 action = X_("Subframes80");
1570         } else if (sfpf == 100) {       
1571                 action = X_("Subframes100");
1572         } else {
1573                 fatal << string_compose (_("programming error: %1 %2"), "Session received unexpected subframes per frame value: ", sfpf) << endmsg;
1574                 /*NOTREACHED*/
1575         }
1576         
1577         act = ActionManager::get_action (X_("Editor"), action);
1578         
1579         if (act) {
1580                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1581                 if (ract && ract->get_active()) {
1582                         Config->set_subframes_per_frame ((uint32_t) rint (sfpf));
1583                 }
1584                 
1585         } else  {
1586                 error << string_compose (_("programming error: %1"), "Editor::subframes_per_frame_chosen could not find action to match value.") << endmsg;
1587         }
1588 }
1589
1590 void
1591 Editor::toggle_auto_xfade ()
1592 {
1593         ActionManager::toggle_config_state ("Editor", "toggle-auto-xfades", &Configuration::set_auto_xfade, &Configuration::get_auto_xfade);
1594 }
1595
1596 void
1597 Editor::toggle_xfades_active ()
1598 {
1599         ActionManager::toggle_config_state ("Editor", "toggle-xfades-active", &Configuration::set_xfades_active, &Configuration::get_xfades_active);
1600 }
1601
1602 void
1603 Editor::toggle_xfade_visibility ()
1604 {
1605         ActionManager::toggle_config_state ("Editor", "toggle-xfades-visible", &Configuration::set_xfades_visible, &Configuration::get_xfades_visible);
1606 }
1607
1608 void
1609 Editor::toggle_link_region_and_track_selection ()
1610 {
1611         ActionManager::toggle_config_state ("Editor", "link-region-and-track-selection", &Configuration::set_link_region_and_track_selection, &Configuration::get_link_region_and_track_selection);
1612 }
1613
1614 /** A Configuration parameter has changed.
1615  * @param parameter_name Name of the changed parameter.
1616  */
1617 void
1618 Editor::parameter_changed (const char* parameter_name)
1619 {
1620 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
1621         //cerr << "Editor::parameter_changed: " << parameter_name << endl;
1622         ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::parameter_changed), parameter_name));
1623
1624         if (PARAM_IS ("auto-loop")) {
1625                 update_loop_range_view (true);
1626         } else if (PARAM_IS ("punch-in")) {
1627                 update_punch_range_view (true);
1628         } else if (PARAM_IS ("punch-out")) {
1629                 update_punch_range_view (true);
1630         } else if (PARAM_IS ("layer-model")) {
1631                 update_layering_model ();
1632         } else if (PARAM_IS ("smpte-format")) {
1633                 update_smpte_mode ();
1634                 update_just_smpte ();
1635         } else if (PARAM_IS ("video-pullup")) {
1636                 update_video_pullup ();
1637         } else if (PARAM_IS ("xfades-active")) {
1638                 ActionManager::map_some_state ("Editor", "toggle-xfades-active", &Configuration::get_xfades_active);
1639         } else if (PARAM_IS ("xfades-visible")) {
1640                 ActionManager::map_some_state ("Editor", "toggle-xfades-visible", &Configuration::get_xfades_visible);
1641                 update_xfade_visibility ();
1642         } else if (PARAM_IS ("auto-xfade")) {
1643                 ActionManager::map_some_state ("Editor", "toggle-auto-xfades", &Configuration::get_auto_xfade);
1644         } else if (PARAM_IS ("xfade-model")) {
1645                 update_crossfade_model ();
1646         } else if (PARAM_IS ("edit-mode")) {
1647                 edit_mode_selector.set_active_text (edit_mode_to_string (Config->get_edit_mode()));
1648         } else if (PARAM_IS ("subframes-per-frame")) {
1649                 update_subframes_per_frame ();
1650                 update_just_smpte ();
1651         } else if (PARAM_IS ("link-region-and-track-selection")) {
1652                 ActionManager::map_some_state ("Editor", "link-region-and-track-selection", &Configuration::get_link_region_and_track_selection);
1653         }
1654
1655 #undef PARAM_IS
1656 }
1657
1658 void
1659 Editor::reset_focus ()
1660 {
1661         track_canvas->grab_focus();
1662 }
1663
1664 void
1665 Editor::reset_canvas_action_sensitivity (bool onoff)
1666 {
1667         if (_edit_point != EditAtMouse) {
1668                 onoff = true;
1669         }
1670
1671         for (vector<Glib::RefPtr<Action> >::iterator x = ActionManager::mouse_edit_point_requires_canvas_actions.begin();  
1672              x != ActionManager::mouse_edit_point_requires_canvas_actions.end(); ++x) {
1673                 (*x)->set_sensitive (onoff);
1674         }
1675 }