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