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