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