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