d92f44be863cb87e0dde7d2ebc6cf4f1a9cc603e
[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 <gio/gio.h>
21 #include <gtk/gtkiconfactory.h>
22
23 #include "ardour/ardour.h"
24 #include "ardour/profile.h"
25 #include "ardour/session.h"
26
27 #include "actions.h"
28 #include "ardour_ui.h"
29 #include "editing.h"
30 #include "editor.h"
31 #include "gui_thread.h"
32 #include "time_axis_view.h"
33 #include "utils.h"
34 #include "i18n.h"
35 #include "audio_time_axis.h"
36 #include "editor_group_tabs.h"
37 #include "editor_routes.h"
38 #include "editor_regions.h"
39
40 using namespace Gtk;
41 using namespace Glib;
42 using namespace std;
43 using namespace ARDOUR;
44 using namespace PBD;
45 using namespace Editing;
46
47 void
48 Editor::register_actions ()
49 {
50         RefPtr<Action> act;
51
52         editor_actions = ActionGroup::create (X_("Editor"));
53
54         /* non-operative menu items for menu bar */
55
56         ActionManager::register_action (editor_actions, X_("AlignMenu"), _("Align"));
57         ActionManager::register_action (editor_actions, X_("Autoconnect"), _("Autoconnect"));
58         ActionManager::register_action (editor_actions, X_("Crossfades"), _("Crossfades"));
59         ActionManager::register_action (editor_actions, X_("Edit"), _("Edit"));
60         ActionManager::register_action (editor_actions, X_("EditCursorMovementOptions"), _("Move Selected Marker"));
61         ActionManager::register_action (editor_actions, X_("EditSelectRangeOptions"), _("Select Range Operations"));
62         ActionManager::register_action (editor_actions, X_("EditSelectRegionOptions"), _("Select Regions"));
63         ActionManager::register_action (editor_actions, X_("EditPointMenu"), _("Edit Point"));
64         ActionManager::register_action (editor_actions, X_("FadeMenu"), _("Fade"));
65         ActionManager::register_action (editor_actions, X_("LatchMenu"), _("Latch"));
66         ActionManager::register_action (editor_actions, X_("RegionMenu"), _("Region"));
67         ActionManager::register_action (editor_actions, X_("RegionMenuLayering"), _("Layering"));
68         ActionManager::register_action (editor_actions, X_("RegionMenuNudge"), _("Nudge"));
69         ActionManager::register_action (editor_actions, X_("RegionMenuTrim"), _("Trim"));
70         ActionManager::register_action (editor_actions, X_("RegionMenuGain"), _("Gain"));
71         ActionManager::register_action (editor_actions, X_("RegionMenuRanges"), _("Ranges"));
72         ActionManager::register_action (editor_actions, X_("RegionMenuFades"), _("Fades"));
73         ActionManager::register_action (editor_actions, X_("RegionMenuMIDI"), _("MIDI"));
74         ActionManager::register_action (editor_actions, X_("RegionMenuDuplicate"), _("Duplicate"));
75         ActionManager::register_action (editor_actions, X_("Link"), _("Link"));
76         ActionManager::register_action (editor_actions, X_("ZoomFocusMenu"), _("Zoom Focus"));
77         ActionManager::register_action (editor_actions, X_("KeyMouseActions"), _("Key Mouse"));
78         ActionManager::register_action (editor_actions, X_("LocateToMarker"), _("Locate to Markers"));
79         ActionManager::register_action (editor_actions, X_("MarkerMenu"), _("Markers"));
80         ActionManager::register_action (editor_actions, X_("MeterFalloff"), _("Meter falloff"));
81         ActionManager::register_action (editor_actions, X_("MeterHold"), _("Meter hold"));
82         ActionManager::register_action (editor_actions, X_("MiscOptions"), _("Misc Options"));
83         ActionManager::register_action (editor_actions, X_("Monitoring"), _("Monitoring"));
84         ActionManager::register_action (editor_actions, X_("MoveActiveMarkMenu"), _("Active Mark"));
85         ActionManager::register_action (editor_actions, X_("MovePlayHeadMenu"), _("Playhead"));
86         ActionManager::register_action (editor_actions, X_("PlayMenu"), _("Play"));
87         ActionManager::register_action (editor_actions, X_("PrimaryClockMenu"), _("Primary Clock"));
88         ActionManager::register_action (editor_actions, X_("Pullup"), _("Pullup / Pulldown"));
89         ActionManager::register_action (editor_actions, X_("RegionEditOps"), _("Region operations"));
90         ActionManager::register_action (editor_actions, X_("RegionGainMenu"), _("Gain"));
91         ActionManager::register_action (editor_actions, X_("RulerMenu"), _("Rulers"));
92         ActionManager::register_action (editor_actions, X_("SavedViewMenu"), _("Views"));
93         ActionManager::register_action (editor_actions, X_("ScrollMenu"), _("Scroll"));
94         ActionManager::register_action (editor_actions, X_("SecondaryClockMenu"), _("Secondary Clock"));
95         ActionManager::register_action (editor_actions, X_("Select"), _("Select"));
96         ActionManager::register_action (editor_actions, X_("SelectMenu"), _("Select"));
97         ActionManager::register_action (editor_actions, X_("SeparateMenu"), _("Separate"));
98         ActionManager::register_action (editor_actions, X_("SetLoopMenu"), _("Loop"));
99         ActionManager::register_action (editor_actions, X_("SetPunchMenu"), _("Punch"));
100         ActionManager::register_action (editor_actions, X_("Solo"), _("Solo"));
101         ActionManager::register_action (editor_actions, X_("Subframes"), _("Subframes"));
102         ActionManager::register_action (editor_actions, X_("SyncMenu"), _("Sync"));
103         ActionManager::register_action (editor_actions, X_("TempoMenu"), _("Tempo"));
104         ActionManager::register_action (editor_actions, X_("Timecode"), _("Timecode fps"));
105         ActionManager::register_action (editor_actions, X_("TrackHeightMenu"), _("Height"));
106         ActionManager::register_action (editor_actions, X_("TrackMenu"), _("Track"));
107         ActionManager::register_action (editor_actions, X_("Tools"), _("Tools"));
108         ActionManager::register_action (editor_actions, X_("View"), _("View"));
109         ActionManager::register_action (editor_actions, X_("ZoomFocus"), _("Zoom Focus"));
110         ActionManager::register_action (editor_actions, X_("ZoomMenu"), _("Zoom"));
111
112         register_region_actions ();
113
114         /* add named actions for the editor */
115
116         ActionManager::register_action (editor_actions, "escape", _("Break drag or deselect all"), sigc::mem_fun (*this, &Editor::escape));
117
118         act = ActionManager::register_toggle_action (editor_actions, "show-editor-mixer", _("Show Editor Mixer"), sigc::mem_fun (*this, &Editor::editor_mixer_button_toggled));
119         ActionManager::session_sensitive_actions.push_back (act);
120         act = ActionManager::register_toggle_action (editor_actions, "show-editor-list", _("Show Editor List"), sigc::mem_fun (*this, &Editor::editor_list_button_toggled));
121         ActionManager::session_sensitive_actions.push_back (act);
122
123         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-boundary", _("Playhead to Next Region Boundary"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_boundary), true ));
124         ActionManager::session_sensitive_actions.push_back (act);
125         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-boundary-noselection", _("Playhead to Next Region Boundary (No Track Selection)"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_boundary), false ));
126         ActionManager::session_sensitive_actions.push_back (act);
127         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-boundary", _("Playhead to Previous Region Boundary"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_boundary), true));
128         ActionManager::session_sensitive_actions.push_back (act);
129         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-boundary-noselection", _("Playhead to Previous Region Boundary (No Track Selection)"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_boundary), false));
130         ActionManager::session_sensitive_actions.push_back (act);
131
132         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-start", _("Playhead to Next Region Start"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (Start)));
133         ActionManager::session_sensitive_actions.push_back (act);
134         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-end", _("Playhead to Next Region End"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (End)));
135         ActionManager::session_sensitive_actions.push_back (act);
136         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-sync", _("Playhead to Next Region Sync"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (SyncPoint)));
137         ActionManager::session_sensitive_actions.push_back (act);
138
139         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-start", _("Playhead to Previous Region Start"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (Start)));
140         ActionManager::session_sensitive_actions.push_back (act);
141         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-end", _("Playhead to Previous Region End"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (End)));
142         ActionManager::session_sensitive_actions.push_back (act);
143         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-sync", _("Playhead to Previous Region Sync"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (SyncPoint)));
144         ActionManager::session_sensitive_actions.push_back (act);
145
146         act = ActionManager::register_action (editor_actions, "selected-marker-to-next-region-boundary", _("To Next Region Boundary"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_next_region_boundary), true));
147         ActionManager::session_sensitive_actions.push_back (act);
148         act = ActionManager::register_action (editor_actions, "selected-marker-to-next-region-boundary-noselection", _("To Next Region Boundary (No Track Selection)"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_next_region_boundary), false));
149         ActionManager::session_sensitive_actions.push_back (act);
150         act = ActionManager::register_action (editor_actions, "selected-marker-to-previous-region-boundary", _("To Previous Region Boundary"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_previous_region_boundary), true));
151         ActionManager::session_sensitive_actions.push_back (act);
152         act = ActionManager::register_action (editor_actions, "selected-marker-to-previous-region-boundary-noselection", _("to Previous Region Boundary (No Track Selection)"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_previous_region_boundary), false));
153         ActionManager::session_sensitive_actions.push_back (act);
154
155         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-start", _("To Next Region Start"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_next_region_point), RegionPoint (Start)));
156         ActionManager::session_sensitive_actions.push_back (act);
157         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-end", _("To Next Region End"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_next_region_point), RegionPoint (End)));
158         ActionManager::session_sensitive_actions.push_back (act);
159         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-sync", _("To Next Region Sync"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_next_region_point), RegionPoint (SyncPoint)));
160         ActionManager::session_sensitive_actions.push_back (act);
161
162         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-start", _("To Previous Region Start"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_previous_region_point), RegionPoint (Start)));
163         ActionManager::session_sensitive_actions.push_back (act);
164         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-end", _("To Previous Region End"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_previous_region_point), RegionPoint (End)));
165         ActionManager::session_sensitive_actions.push_back (act);
166         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-sync", _("To Previous Region Sync"), sigc::bind (sigc::mem_fun(*this, &Editor::selected_marker_to_previous_region_point), RegionPoint (SyncPoint)));
167         ActionManager::session_sensitive_actions.push_back (act);
168
169         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-start", _("To Range Start"), sigc::mem_fun(*this, &Editor::selected_marker_to_selection_start));
170         ActionManager::session_sensitive_actions.push_back (act);
171         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-end", _("To Range End"), sigc::mem_fun(*this, &Editor::selected_marker_to_selection_end));
172         ActionManager::session_sensitive_actions.push_back (act);
173
174         act = ActionManager::register_action (editor_actions, "playhead-to-range-start", _("Playhead to Range Start"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_selection_start), playhead_cursor));
175         ActionManager::session_sensitive_actions.push_back (act);
176         act = ActionManager::register_action (editor_actions, "playhead-to-range-end", _("Playhead to Range End"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_to_selection_end), playhead_cursor));
177         ActionManager::session_sensitive_actions.push_back (act);
178
179         act = ActionManager::register_action (editor_actions, "select-all", _("Select All"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all), Selection::Set));
180         ActionManager::session_sensitive_actions.push_back (act);
181         act = ActionManager::register_action (editor_actions, "deselect-all", _("Deselect All"), sigc::mem_fun(*this, &Editor::deselect_all));
182         ActionManager::session_sensitive_actions.push_back (act);
183         act = ActionManager::register_action (editor_actions, "invert-selection", _("Invert Selection"), sigc::mem_fun(*this, &Editor::invert_selection));
184         ActionManager::session_sensitive_actions.push_back (act);
185         act = ActionManager::register_action (editor_actions, "select-all-after-edit-cursor", _("Select All After Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), true));
186         ActionManager::session_sensitive_actions.push_back (act);
187         act = ActionManager::register_action (editor_actions, "select-all-before-edit-cursor", _("Select All Before Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), false));
188         ActionManager::session_sensitive_actions.push_back (act);
189
190         act = ActionManager::register_action (editor_actions, "select-all-between-cursors", _("Select All Overlapping Edit Range"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_between), false));
191         ActionManager::session_sensitive_actions.push_back (act);
192         act = ActionManager::register_action (editor_actions, "select-all-within-cursors", _("Select All Inside Edit Range"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_between), true));
193         ActionManager::session_sensitive_actions.push_back (act);
194
195         act = ActionManager::register_action (editor_actions, "select-range-between-cursors", _("Select Edit Range"), sigc::mem_fun(*this, &Editor::select_range_between));
196         ActionManager::session_sensitive_actions.push_back (act);
197
198         act = ActionManager::register_action (editor_actions, "select-all-in-punch-range", _("Select All in Punch Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_punch));
199         ActionManager::session_sensitive_actions.push_back (act);
200         act = ActionManager::register_action (editor_actions, "select-all-in-loop-range", _("Select All in Loop Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_loop));
201         ActionManager::session_sensitive_actions.push_back (act);
202
203         act = ActionManager::register_action (editor_actions, "select-next-route", _("Select Next Track or Bus"), sigc::mem_fun(*this, &Editor::select_next_route));
204         ActionManager::session_sensitive_actions.push_back (act);
205         act = ActionManager::register_action (editor_actions, "select-prev-route", _("Select Previous Track or Bus"), sigc::mem_fun(*this, &Editor::select_prev_route));
206         ActionManager::session_sensitive_actions.push_back (act);
207
208         act = ActionManager::register_action (editor_actions, "track-record-enable-toggle", _("Toggle Record Enable"), sigc::mem_fun(*this, &Editor::toggle_record_enable));
209         ActionManager::session_sensitive_actions.push_back (act);
210         ActionManager::track_selection_sensitive_actions.push_back (act);
211
212         for (int i = 1; i <= 12; ++i) {
213                 string const a = string_compose (X_("save-visual-state-%1"), i);
214                 string const n = string_compose (_("Save View %1"), i);
215                 act = ActionManager::register_action (editor_actions, a.c_str(), n.c_str(), sigc::bind (sigc::mem_fun (*this, &Editor::start_visual_state_op), i - 1));
216                 ActionManager::session_sensitive_actions.push_back (act);
217         }
218
219         for (int i = 1; i <= 12; ++i) {
220                 string const a = string_compose (X_("goto-visual-state-%1"), i);
221                 string const n = string_compose (_("Goto View %1"), i);
222                 act = ActionManager::register_action (editor_actions, a.c_str(), n.c_str(), sigc::bind (sigc::mem_fun (*this, &Editor::cancel_visual_state_op), i - 1));
223                 ActionManager::session_sensitive_actions.push_back (act);
224         }
225         
226         for (int i = 1; i <= 9; ++i) {
227                 string const a = string_compose (X_("goto-mark-%1"), i);
228                 string const n = string_compose (_("Locate to Mark %1"), i);
229                 act = ActionManager::register_action (editor_actions, a.c_str(), n.c_str(), sigc::bind (sigc::mem_fun (*this, &Editor::goto_nth_marker), i - 1));
230                 ActionManager::session_sensitive_actions.push_back (act);
231         }
232
233         act = ActionManager::register_action (editor_actions, "jump-forward-to-mark", _("Jump Forward to Mark"), sigc::mem_fun(*this, &Editor::jump_forward_to_mark));
234         ActionManager::session_sensitive_actions.push_back (act);
235         act = ActionManager::register_action (editor_actions, "jump-backward-to-mark", _("Jump Backward to Mark"), sigc::mem_fun(*this, &Editor::jump_backward_to_mark));
236         ActionManager::session_sensitive_actions.push_back (act);
237         act = ActionManager::register_action (editor_actions, "add-location-from-playhead", _("Add Mark from Playhead"), sigc::mem_fun(*this, &Editor::add_location_from_playhead_cursor));
238         ActionManager::session_sensitive_actions.push_back (act);
239
240         act = ActionManager::register_action (editor_actions, "nudge-next-forward", _("Nudge Next Forward"), sigc::bind (sigc::mem_fun(*this, &Editor::nudge_forward), true, false));
241         ActionManager::session_sensitive_actions.push_back (act);
242         act = ActionManager::register_action (editor_actions, "nudge-next-backward", _("Nudge Next Backward"), sigc::bind (sigc::mem_fun(*this, &Editor::nudge_backward), true, false));
243         ActionManager::session_sensitive_actions.push_back (act);
244
245         act = ActionManager::register_action (editor_actions, "nudge-playhead-forward", _("Nudge Playhead Forward"), sigc::bind (sigc::mem_fun(*this, &Editor::nudge_forward), false, true));
246         ActionManager::session_sensitive_actions.push_back (act);
247         act = ActionManager::register_action (editor_actions, "nudge-playhead-backward", _("Nudge Playhead Backward"), sigc::bind (sigc::mem_fun(*this, &Editor::nudge_backward), false, true));
248         ActionManager::session_sensitive_actions.push_back (act);
249         act = ActionManager::register_action (editor_actions, "playhead-forward-to-grid", _("Forward to Grid"), sigc::mem_fun(*this, &Editor::playhead_forward_to_grid));
250         ActionManager::session_sensitive_actions.push_back (act);
251         act = ActionManager::register_action (editor_actions, "playhead-backward-to-grid", _("Backward to Grid"), sigc::mem_fun(*this, &Editor::playhead_backward_to_grid));
252         ActionManager::session_sensitive_actions.push_back (act);
253
254
255         act = ActionManager::register_action (editor_actions, "temporal-zoom-out", _("Zoom Out"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), true));
256         ActionManager::session_sensitive_actions.push_back (act);
257         act = ActionManager::register_action (editor_actions, "temporal-zoom-in", _("Zoom In"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), false));
258         ActionManager::session_sensitive_actions.push_back (act);
259         act = ActionManager::register_action (editor_actions, "zoom-to-session", _("Zoom to Session"), sigc::mem_fun(*this, &Editor::temporal_zoom_session));
260         ActionManager::session_sensitive_actions.push_back (act);
261         act = ActionManager::register_action (editor_actions, "zoom-to-region", _("Zoom to Region"), sigc::bind (sigc::mem_fun(*this, &Editor::zoom_to_region), false));
262         ActionManager::session_sensitive_actions.push_back (act);
263         act = ActionManager::register_action (editor_actions, "zoom-to-region-both-axes", _("Zoom to Region (Width and Height)"), sigc::bind (sigc::mem_fun(*this, &Editor::zoom_to_region), true));
264         ActionManager::session_sensitive_actions.push_back (act);
265         act = ActionManager::register_action (editor_actions, "toggle-zoom", _("Toggle Zoom State"), sigc::mem_fun(*this, &Editor::swap_visual_state));
266         ActionManager::session_sensitive_actions.push_back (act);
267
268         act = ActionManager::register_action (editor_actions, "move-selected-tracks-up", _("Move Selected Tracks Up"), sigc::bind (sigc::mem_fun(*_routes, &EditorRoutes::move_selected_tracks), true));
269         ActionManager::session_sensitive_actions.push_back (act);
270         ActionManager::track_selection_sensitive_actions.push_back (act);
271         act = ActionManager::register_action (editor_actions, "move-selected-tracks-down", _("Move Selected Tracks Down"), sigc::bind (sigc::mem_fun(*_routes, &EditorRoutes::move_selected_tracks), false));
272         ActionManager::session_sensitive_actions.push_back (act);
273         ActionManager::track_selection_sensitive_actions.push_back (act);
274
275         act = ActionManager::register_action (editor_actions, "scroll-tracks-up", _("Scroll Tracks Up"), sigc::mem_fun(*this, &Editor::scroll_tracks_up));
276         ActionManager::session_sensitive_actions.push_back (act);
277         ActionManager::track_selection_sensitive_actions.push_back (act);
278         act = ActionManager::register_action (editor_actions, "scroll-tracks-down", _("Scroll Tracks Down"), sigc::mem_fun(*this, &Editor::scroll_tracks_down));
279         ActionManager::track_selection_sensitive_actions.push_back (act);
280         ActionManager::session_sensitive_actions.push_back (act);
281         act = ActionManager::register_action (editor_actions, "step-tracks-up", _("Step Tracks Up"), sigc::mem_fun(*this, &Editor::scroll_tracks_up_line));
282         ActionManager::track_selection_sensitive_actions.push_back (act);
283         ActionManager::session_sensitive_actions.push_back (act);
284         act = ActionManager::register_action (editor_actions, "step-tracks-down", _("Step Tracks Down"), sigc::mem_fun(*this, &Editor::scroll_tracks_down_line));
285         ActionManager::session_sensitive_actions.push_back (act);
286         ActionManager::track_selection_sensitive_actions.push_back (act);
287
288         act = ActionManager::register_action (editor_actions, "scroll-backward", _("Scroll Backward"), sigc::bind (sigc::mem_fun(*this, &Editor::scroll_backward), 0.8f));
289         ActionManager::session_sensitive_actions.push_back (act);
290         act = ActionManager::register_action (editor_actions, "scroll-forward", _("Scroll Forward"), sigc::bind (sigc::mem_fun(*this, &Editor::scroll_forward), 0.8f));
291         ActionManager::session_sensitive_actions.push_back (act);
292         act = ActionManager::register_action (editor_actions, "goto", _("goto"), sigc::mem_fun(*this, &Editor::goto_frame));
293         ActionManager::session_sensitive_actions.push_back (act);
294         act = ActionManager::register_action (editor_actions, "center-playhead", _("Center Playhead"), sigc::mem_fun(*this, &Editor::center_playhead));
295         ActionManager::session_sensitive_actions.push_back (act);
296         act = ActionManager::register_action (editor_actions, "center-edit-cursor", _("Center Active Marker"), sigc::mem_fun(*this, &Editor::center_edit_point));
297         ActionManager::session_sensitive_actions.push_back (act);
298
299         act = ActionManager::register_action (editor_actions, "scroll-playhead-forward", _("Playhead Forward"), sigc::bind (sigc::mem_fun(*this, &Editor::scroll_playhead), true));;
300         ActionManager::session_sensitive_actions.push_back (act);
301         act = ActionManager::register_action (editor_actions, "scroll-playhead-backward", _("Playhead Backward"), sigc::bind (sigc::mem_fun(*this, &Editor::scroll_playhead), false));
302         ActionManager::session_sensitive_actions.push_back (act);
303
304         act = ActionManager::register_action (editor_actions, "playhead-to-edit", _("Playhead to Active Mark"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_align), true));
305         ActionManager::session_sensitive_actions.push_back (act);
306         act = ActionManager::register_action (editor_actions, "edit-to-playhead", _("Active Mark to Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::cursor_align), false));
307         ActionManager::session_sensitive_actions.push_back (act);
308
309         act = ActionManager::register_action (editor_actions, "set-loop-from-edit-range", _("Set Loop from Edit Range"), sigc::bind (sigc::mem_fun(*this, &Editor::set_loop_from_edit_range), false));
310         ActionManager::session_sensitive_actions.push_back (act);
311         act = ActionManager::register_action (editor_actions, "set-punch-from-edit-range", _("Set Punch from Edit Range"), sigc::mem_fun(*this, &Editor::set_punch_from_edit_range));
312         ActionManager::session_sensitive_actions.push_back (act);
313
314         act = ActionManager::register_action (editor_actions, "play-from-edit-point", _("Play From Edit Point"), sigc::mem_fun(*this, &Editor::play_from_edit_point));
315         ActionManager::session_sensitive_actions.push_back (act);
316         act = ActionManager::register_action (editor_actions, "play-from-edit-point-and-return", _("Play from Edit Point and Return"), sigc::mem_fun(*this, &Editor::play_from_edit_point_and_return));
317         ActionManager::session_sensitive_actions.push_back (act);
318
319         act = ActionManager::register_action (editor_actions, "play-edit-range", _("Play Edit Range"), sigc::mem_fun(*this, &Editor::play_edit_range));
320         act = ActionManager::register_action (editor_actions, "brush-at-mouse", _("Brush at Mouse"), sigc::mem_fun(*this, &Editor::kbd_brush));
321         ActionManager::session_sensitive_actions.push_back (act);
322
323         act = ActionManager::register_action (editor_actions, "set-playhead", _("Playhead to Mouse"), sigc::mem_fun(*this, &Editor::set_playhead_cursor));
324         ActionManager::session_sensitive_actions.push_back (act);
325         act = ActionManager::register_action (editor_actions, "set-edit-point", _("Active Marker to Mouse"), sigc::mem_fun(*this, &Editor::set_edit_point));
326         ActionManager::session_sensitive_actions.push_back (act);
327
328         act = ActionManager::register_action (editor_actions, "duplicate-range", _("Duplicate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_dialog), false));
329         ActionManager::session_sensitive_actions.push_back (act);
330
331         undo_action = act = ActionManager::register_action (editor_actions, "undo", _("Undo"), sigc::bind (sigc::mem_fun(*this, &Editor::undo), 1U));
332         ActionManager::session_sensitive_actions.push_back (act);
333         redo_action = act = ActionManager::register_action (editor_actions, "redo", _("Redo"), sigc::bind (sigc::mem_fun(*this, &Editor::redo), 1U));
334         ActionManager::session_sensitive_actions.push_back (act);
335
336         act = ActionManager::register_action (editor_actions, "export-audio", _("Export Audio"), sigc::mem_fun(*this, &Editor::export_audio));
337         ActionManager::session_sensitive_actions.push_back (act);
338         act = ActionManager::register_action (editor_actions, "export-range", _("Export Range"), sigc::mem_fun(*this, &Editor::export_range));
339         ActionManager::session_sensitive_actions.push_back (act);
340
341         act = ActionManager::register_action (editor_actions, "editor-separate", _("Separate"), sigc::mem_fun(*this, &Editor::separate_region_from_selection));
342         ActionManager::session_sensitive_actions.push_back (act);
343         ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
344         
345         act = ActionManager::register_action (editor_actions, "separate-from-punch", _("Separate Using Punch Range"), sigc::mem_fun(*this, &Editor::separate_region_from_punch));
346         ActionManager::session_sensitive_actions.push_back (act);
347         ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
348         
349         act = ActionManager::register_action (editor_actions, "separate-from-loop", _("Separate Using Loop Range"), sigc::mem_fun(*this, &Editor::separate_region_from_loop));
350         ActionManager::session_sensitive_actions.push_back (act);
351         ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
352         
353         act = ActionManager::register_action (editor_actions, "editor-crop", _("Crop"), sigc::mem_fun(*this, &Editor::crop_region_to_selection));
354         ActionManager::session_sensitive_actions.push_back (act);
355         ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
356         
357         act = ActionManager::register_action (editor_actions, "editor-cut", _("Cut"), sigc::mem_fun(*this, &Editor::cut));
358         ActionManager::session_sensitive_actions.push_back (act);
359         
360         /* Note: for now, editor-delete does the exact same thing as editor-cut */
361         act = ActionManager::register_action (editor_actions, "editor-delete", _("Delete"), sigc::mem_fun(*this, &Editor::cut));
362         ActionManager::session_sensitive_actions.push_back (act);
363         act = ActionManager::register_action (editor_actions, "editor-copy", _("Copy"), sigc::mem_fun(*this, &Editor::copy));
364         ActionManager::session_sensitive_actions.push_back (act);
365         act = ActionManager::register_action (editor_actions, "editor-paste", _("Paste"), sigc::mem_fun(*this, &Editor::keyboard_paste));
366         ActionManager::session_sensitive_actions.push_back (act);
367
368         act = ActionManager::register_action (editor_actions, "set-tempo-from-edit-range", _("Set Tempo from Edit Range=Bar"), sigc::mem_fun(*this, &Editor::use_range_as_bar));
369         ActionManager::session_sensitive_actions.push_back (act);
370
371         act = ActionManager::register_toggle_action (editor_actions, "toggle-log-window", _("Log"),
372                         sigc::mem_fun (ARDOUR_UI::instance(), &ARDOUR_UI::toggle_errors));
373         ActionManager::session_sensitive_actions.push_back (act);
374
375         act = ActionManager::register_action (editor_actions, "tab-to-transient-forwards", _("Move Forward to Transient"), sigc::bind (sigc::mem_fun(*this, &Editor::tab_to_transient), true));
376         ActionManager::session_sensitive_actions.push_back (act);
377         act = ActionManager::register_action (editor_actions, "tab-to-transient-backwards", _("Move Backwards to Transient"), sigc::bind (sigc::mem_fun(*this, &Editor::tab_to_transient), false));
378         ActionManager::session_sensitive_actions.push_back (act);
379
380         act = ActionManager::register_action (editor_actions, "crop", _("Crop"), sigc::mem_fun(*this, &Editor::crop_region_to_selection));
381         ActionManager::session_sensitive_actions.push_back (act);
382
383         act = ActionManager::register_action (editor_actions, "start-range", _("Start Range"), sigc::mem_fun(*this, &Editor::keyboard_selection_begin));
384         ActionManager::session_sensitive_actions.push_back (act);
385         act = ActionManager::register_action (editor_actions, "finish-range", _("Finish Range"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_finish), false));
386         ActionManager::session_sensitive_actions.push_back (act);
387         act = ActionManager::register_action (editor_actions, "finish-add-range", _("Finish Add Range"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_finish), true));
388         ActionManager::session_sensitive_actions.push_back (act);
389
390         act = ActionManager::register_action (editor_actions, "extend-range-to-end-of-region", _("Extend Range to End of Region"), sigc::bind (sigc::mem_fun(*this, &Editor::extend_selection_to_end_of_region), false));
391         ActionManager::session_sensitive_actions.push_back (act);
392         act = ActionManager::register_action (editor_actions, "extend-range-to-start-of-region", _("Extend Range to Start of Region"), sigc::bind (sigc::mem_fun(*this, &Editor::extend_selection_to_start_of_region), false));
393         ActionManager::session_sensitive_actions.push_back (act);
394
395         act = ActionManager::register_toggle_action (editor_actions, "toggle-follow-playhead", _("Follow Playhead"), (sigc::mem_fun(*this, &Editor::toggle_follow_playhead)));
396         ActionManager::session_sensitive_actions.push_back (act);
397         act = ActionManager::register_action (editor_actions, "remove-last-capture", _("Remove Last Capture"), (sigc::mem_fun(*this, &Editor::remove_last_capture)));
398         ActionManager::session_sensitive_actions.push_back (act);
399
400         ActionManager::register_toggle_action (editor_actions, "toggle-stationary-playhead", _("Stationary Playhead"), (mem_fun(*this, &Editor::toggle_stationary_playhead)));
401
402         act = ActionManager::register_action (editor_actions, "insert-time", _("Insert Time"), (sigc::mem_fun(*this, &Editor::do_insert_time)));
403         ActionManager::session_sensitive_actions.push_back (act);
404         ActionManager::track_selection_sensitive_actions.push_back (act);
405
406         act = ActionManager::register_action (editor_actions, "toggle-track-active", _("Toggle Active"), (sigc::mem_fun(*this, &Editor::toggle_tracks_active)));
407         ActionManager::session_sensitive_actions.push_back (act);
408         ActionManager::track_selection_sensitive_actions.push_back (act);
409         if (Profile->get_sae()) {
410                 act = ActionManager::register_action (editor_actions, "remove-track", _("Delete"), (sigc::mem_fun(*this, &Editor::remove_tracks)));
411         } else {
412                 act = ActionManager::register_action (editor_actions, "remove-track", _("Remove"), (sigc::mem_fun(*this, &Editor::remove_tracks)));
413         }
414         ActionManager::session_sensitive_actions.push_back (act);
415         ActionManager::track_selection_sensitive_actions.push_back (act);
416
417         act = ActionManager::register_action (editor_actions, "fit-tracks", _("Fit Selected Tracks"), sigc::mem_fun(*this, &Editor::fit_selected_tracks));
418         ActionManager::session_sensitive_actions.push_back (act);
419         ActionManager::track_selection_sensitive_actions.push_back (act);
420         act = ActionManager::register_action (editor_actions, "track-height-largest", _("Largest"), sigc::bind (
421                                 sigc::mem_fun(*this, &Editor::set_track_height), HeightLargest));
422         ActionManager::session_sensitive_actions.push_back (act);
423         ActionManager::track_selection_sensitive_actions.push_back (act);
424         act = ActionManager::register_action (editor_actions, "track-height-larger", _("Larger"), sigc::bind (
425                                 sigc::mem_fun(*this, &Editor::set_track_height), HeightLarger));
426         ActionManager::session_sensitive_actions.push_back (act);
427         ActionManager::track_selection_sensitive_actions.push_back (act);
428         act = ActionManager::register_action (editor_actions, "track-height-large", _("Large"), sigc::bind (
429                                 sigc::mem_fun(*this, &Editor::set_track_height), HeightLarge));
430         ActionManager::session_sensitive_actions.push_back (act);
431         ActionManager::track_selection_sensitive_actions.push_back (act);
432         act = ActionManager::register_action (editor_actions, "track-height-normal", _("Normal"), sigc::bind (
433                                 sigc::mem_fun(*this, &Editor::set_track_height), HeightNormal));
434         ActionManager::session_sensitive_actions.push_back (act);
435         ActionManager::track_selection_sensitive_actions.push_back (act);
436         act = ActionManager::register_action (editor_actions, "track-height-small", _("Small"), sigc::bind (
437                                 sigc::mem_fun(*this, &Editor::set_track_height), HeightSmall));
438         ActionManager::track_selection_sensitive_actions.push_back (act);
439         ActionManager::session_sensitive_actions.push_back (act);
440         ActionManager::track_selection_sensitive_actions.push_back (act);
441         act = ActionManager::register_action (editor_actions, "track-height-smaller", _("Smaller"), sigc::bind (
442                                 sigc::mem_fun(*this, &Editor::set_track_height), HeightSmaller));
443         ActionManager::session_sensitive_actions.push_back (act);
444         ActionManager::track_selection_sensitive_actions.push_back (act);
445
446         Glib::RefPtr<ActionGroup> zoom_actions = ActionGroup::create (X_("Zoom"));
447         RadioAction::Group zoom_group;
448
449         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-left", _("Zoom Focus Left"), sigc::bind (sigc::mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusLeft));
450         ActionManager::session_sensitive_actions.push_back (act);
451         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-right", _("Zoom Focus Right"), sigc::bind (sigc::mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusRight));
452         ActionManager::session_sensitive_actions.push_back (act);
453         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-center", _("Zoom Focus Center"), sigc::bind (sigc::mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusCenter));
454         ActionManager::session_sensitive_actions.push_back (act);
455         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-playhead", _("Zoom Focus Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusPlayhead));
456         ActionManager::session_sensitive_actions.push_back (act);
457         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-mouse", _("Zoom Focus Mouse"), sigc::bind (sigc::mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusMouse));
458         ActionManager::session_sensitive_actions.push_back (act);
459         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-edit", _("Zoom Focus Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusEdit));
460         ActionManager::session_sensitive_actions.push_back (act);
461
462         Glib::RefPtr<ActionGroup> mouse_mode_actions = ActionGroup::create (X_("MouseMode"));
463         RadioAction::Group mouse_mode_group;
464
465         act = ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-object", _("Object Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
466         act->connect_proxy (mouse_move_button);
467         mouse_move_button.set_image (*(manage (new Image (::get_icon("tool_object")))));
468         mouse_move_button.set_label ("");
469         mouse_move_button.set_name ("MouseModeButton");
470         mouse_move_button.get_image ()->show ();
471
472         act = ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-range", _("Range Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
473         act->connect_proxy (mouse_select_button);
474         mouse_select_button.set_image (*(manage (new Image (::get_icon("tool_range")))));
475         mouse_select_button.set_label ("");
476         mouse_select_button.set_name ("MouseModeButton");
477         mouse_select_button.get_image ()->show ();
478
479         act = ActionManager::register_toggle_action (mouse_mode_actions, "set-mouse-mode-object-range", _("Link Object / Range Tools"), sigc::mem_fun (*this, &Editor::mouse_mode_object_range_toggled));
480         act->connect_proxy (join_object_range_button);
481         join_object_range_button.set_image (*(manage (new Image (::get_icon ("tool_object_range")))));
482         join_object_range_button.set_label ("");
483         join_object_range_button.set_name ("MouseModeButton");
484         join_object_range_button.get_image ()->show ();
485
486         act = ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-gain", _("Gain Tool"), sigc::bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
487         act->connect_proxy (mouse_gain_button);
488         mouse_gain_button.set_image (*(manage (new Image (::get_icon("tool_gain")))));
489         mouse_gain_button.set_label ("");
490         mouse_gain_button.set_name ("MouseModeButton");
491         mouse_gain_button.get_image ()->show ();
492
493         act = ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-zoom", _("Zoom Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
494         act->connect_proxy (mouse_zoom_button);
495         mouse_zoom_button.set_image (*(manage (new Image (::get_icon("tool_zoom")))));
496         mouse_zoom_button.set_label ("");
497         mouse_zoom_button.set_name ("MouseModeButton");
498         mouse_zoom_button.get_image ()->show ();
499
500         act = ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-audition", _("Audition Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
501         act->connect_proxy (mouse_audition_button);
502         mouse_audition_button.set_image (*(manage (new Image (::get_icon("tool_audition")))));
503         mouse_audition_button.set_label ("");
504         mouse_audition_button.set_name ("MouseModeButton");
505         mouse_audition_button.get_image ()->show ();
506
507         act = ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-timefx", _("Time FX Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
508         act->connect_proxy (mouse_timefx_button);
509         mouse_timefx_button.set_image (*(manage (new Image (::get_icon("tool_stretch")))));
510         mouse_timefx_button.set_label ("");
511         mouse_timefx_button.set_name ("MouseModeButton");
512         mouse_timefx_button.get_image ()->show ();
513
514         ActionManager::register_action (editor_actions, "step-mouse-mode", _("Step Mouse Mode"), sigc::bind (sigc::mem_fun(*this, &Editor::step_mouse_mode), true));
515
516         act = ActionManager::register_toggle_action (mouse_mode_actions, "toggle-internal-edit", _("Edit MIDI"), sigc::mem_fun(*this, &Editor::toggle_internal_editing));
517         act->connect_proxy (internal_edit_button);
518         internal_edit_button.set_image (*(manage (new Image (::get_icon("tool_note")))));
519         internal_edit_button.set_label ("");
520         internal_edit_button.set_name ("MouseModeButton");
521         internal_edit_button.get_image ()->show ();
522
523         RadioAction::Group edit_point_group;
524         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-playhead"), _("Playhead"), (sigc::bind (sigc::mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
525         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-mouse"), _("Mouse"), (sigc::bind (sigc::mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
526         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-selected-marker"), _("Marker"), (sigc::bind (sigc::mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
527
528         ActionManager::register_action (editor_actions, "cycle-edit-point", _("Change Edit Point"), sigc::bind (sigc::mem_fun (*this, &Editor::cycle_edit_point), false));
529         ActionManager::register_action (editor_actions, "cycle-edit-point-with-marker", _("Change Edit Point Including Marker"), sigc::bind (sigc::mem_fun (*this, &Editor::cycle_edit_point), true));
530         if (!Profile->get_sae()) {
531                 ActionManager::register_action (editor_actions, "set-edit-splice", _("Splice"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Splice));
532         }
533         ActionManager::register_action (editor_actions, "set-edit-slide", _("Slide"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Slide));
534         ActionManager::register_action (editor_actions, "set-edit-lock", _("Lock"), sigc::bind (sigc::mem_fun (*this, &Editor::set_edit_mode), Lock));
535         ActionManager::register_action (editor_actions, "toggle-edit-mode", _("Toggle Edit Mode"), sigc::mem_fun (*this, &Editor::cycle_edit_mode));
536
537         ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap to"));
538         ActionManager::register_action (editor_actions, X_("SnapMode"), _("Snap Mode"));
539
540         RadioAction::Group snap_mode_group;
541         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-off"), _("No Grid"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapOff)));
542         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-normal"), _("Grid"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapNormal)));
543         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-magnetic"), _("Magnetic"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapMagnetic)));
544
545         ActionManager::register_action (editor_actions, X_("cycle-snap-mode"), _("Next Snap Mode"), sigc::mem_fun (*this, &Editor::cycle_snap_mode));
546         ActionManager::register_action (editor_actions, X_("cycle-snap-choice"), _("Next Snap Choice"), sigc::mem_fun (*this, &Editor::cycle_snap_choice));
547
548         Glib::RefPtr<ActionGroup> snap_actions = ActionGroup::create (X_("Snap"));
549         RadioAction::Group snap_choice_group;
550
551         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-cd-frame"), _("Snap to CD Frame"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToCDFrame)));
552         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-timecode-frame"), _("Snap to Timecode Frame"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToTimecodeFrame)));
553         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-timecode-seconds"), _("Snap to Timecode Seconds"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToTimecodeSeconds)));
554         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-timecode-minutes"), _("Snap to Timecode Minutes"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToTimecodeMinutes)));
555         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-seconds"), _("Snap to Seconds"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSeconds)));
556         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-minutes"), _("Snap to Minutes"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToMinutes)));
557
558         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirtyseconds"), _("Snap to Thirty Seconds"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv32)));
559         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-twentyeighths"), _("Snap to Twenty Eighths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv28)));
560         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-twentyfourths"), _("Snap to Twenty Fourths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv24)));
561         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-twentieths"), _("Snap to Twentieths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv20)));
562         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-asixteenthbeat"), _("Snap to Sixteenths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv16)));
563         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-fourteenths"), _("Snap to Fourteenths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv14)));
564         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-twelfths"), _("Snap to Tweflths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv12)));
565         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-tenths"), _("Snap to Tenths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv10)));
566         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-eighths"), _("Snap to Eighths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv8)));
567         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-sevenths"), _("Snap to Sevenths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv7)));
568         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-sixths"), _("Snap to Sixths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv6)));
569         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-fifths"), _("Snap to Fifths"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv5)));
570         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-quarters"), _("Snap to Quarters"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv4)));
571         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirds"), _("Snap to Thirds"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv3)));
572         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-halves"), _("Snap to Halves"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeatDiv2)));
573
574         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-beat"), _("Snap to Beat"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeat)));
575         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-bar"), _("Snap to Bar"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBar)));
576         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-mark"), _("Snap to Mark"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToMark)));
577         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-start"), _("Snap to Region Start"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionStart)));
578         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-end"), _("Snap to Region End"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionEnd)));
579         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-sync"), _("Snap to Region Sync"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionSync)));
580         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-boundary"), _("Snap to Region Boundary"), (sigc::bind (sigc::mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionBoundary)));
581
582         ActionManager::register_toggle_action (editor_actions, X_("show-marker-lines"), _("Show Marker Lines"), sigc::mem_fun (*this, &Editor::toggle_marker_lines));
583
584         /* RULERS */
585
586         Glib::RefPtr<ActionGroup> ruler_actions = ActionGroup::create (X_("Rulers"));
587         ruler_tempo_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-tempo-ruler"), _("Tempo"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_tempo)));
588         ruler_meter_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-meter-ruler"), _("Meter"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_meter)));
589         ruler_range_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-range-ruler"), _("Ranges"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_range_marker)));
590         ruler_marker_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-marker-ruler"), _("Markers"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_marker)));
591         ruler_cd_marker_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-cd-marker-ruler"), _("CD Markers"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_cd_marker)));
592         ruler_loop_punch_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-loop-punch-ruler"), _("Loop/Punch"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_time_transport_marker)));
593         ruler_bbt_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-bbt-ruler"), _("Bars & Beats"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_frames)));
594         ruler_samples_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-samples-ruler"), _("Samples"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_bbt)));
595         ruler_timecode_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-timecode-ruler"), _("Timecode"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_timecode)));
596         ruler_minsec_action = Glib::RefPtr<ToggleAction>::cast_static (ActionManager::register_toggle_action (ruler_actions, X_("toggle-minsec-ruler"), _("Min:Sec"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_ruler_visibility), ruler_metric_minsec)));
597
598         /* set defaults here */
599
600         no_ruler_shown_update = true;
601         ruler_meter_action->set_active (true);
602         ruler_tempo_action->set_active (true);
603         ruler_marker_action->set_active (true);
604         ruler_range_action->set_active (false);
605         ruler_loop_punch_action->set_active (true);
606         ruler_loop_punch_action->set_active (true);
607         if (Profile->get_sae()) {
608                 ruler_bbt_action->set_active (true);
609                 ruler_cd_marker_action->set_active (false);
610                 ruler_timecode_action->set_active (false);
611                 ruler_minsec_action->set_active (true);
612         } else {
613                 ruler_bbt_action->set_active (false);
614                 ruler_cd_marker_action->set_active (true);
615                 ruler_timecode_action->set_active (true);
616                 ruler_minsec_action->set_active (false);
617         }
618         ruler_samples_action->set_active (false);
619         no_ruler_shown_update = false;
620
621         /* REGION LIST */
622
623         Glib::RefPtr<ActionGroup> rl_actions = ActionGroup::create (X_("RegionList"));
624         RadioAction::Group sort_type_group;
625         RadioAction::Group sort_order_group;
626
627         /* the region list popup menu */
628         ActionManager::register_action (rl_actions, X_("RegionListSort"), _("Sort"));
629
630         act = ActionManager::register_action (rl_actions, X_("rlAudition"), _("Audition"), sigc::mem_fun(*this, &Editor::audition_region_from_region_list));
631         ActionManager::region_list_selection_sensitive_actions.push_back (act);
632         act = ActionManager::register_action (rl_actions, X_("rlHide"), _("Hide"), sigc::mem_fun(*this, &Editor::hide_region_from_region_list));
633         ActionManager::region_list_selection_sensitive_actions.push_back (act);
634         act = ActionManager::register_action (rl_actions, X_("rlShow"), _("Show"), sigc::mem_fun(*this, &Editor::show_region_in_region_list));
635         ActionManager::region_list_selection_sensitive_actions.push_back (act);
636         ActionManager::register_toggle_action (rl_actions, X_("rlShowAll"), _("Show All"), sigc::mem_fun(*_regions, &EditorRegions::toggle_full));
637         ActionManager::register_toggle_action (rl_actions, X_("rlShowAuto"), _("Show Automatic Regions"), sigc::mem_fun (*_regions, &EditorRegions::toggle_show_auto_regions));
638
639         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortAscending"),  _("Ascending"),
640                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_direction), true));
641         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortDescending"),   _("Descending"),
642                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_direction), false));
643
644         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionName"),  _("By Region Name"),
645                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByName, false));
646         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionLength"),  _("By Region Length"),
647                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByLength, false));
648         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionPosition"),  _("By Region Position"),
649                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByPosition, false));
650         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionTimestamp"),  _("By Region Timestamp"),
651                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByTimestamp, false));
652         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionStartinFile"),  _("By Region Start in File"),
653                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByStartInFile, false));
654         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionEndinFile"),  _("By Region End in File"),
655                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), ByEndInFile, false));
656         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileName"),  _("By Source File Name"),
657                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), BySourceFileName, false));
658         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileLength"),  _("By Source File Length"),
659                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), BySourceFileLength, false));
660         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileCreationDate"),  _("By Source File Creation Date"),
661                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), BySourceFileCreationDate, false));
662         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFilesystem"),  _("By Source Filesystem"),
663                         sigc::bind (sigc::mem_fun (*_regions, &EditorRegions::reset_sort_type), BySourceFileFS, false));
664
665
666         /* the next two are duplicate items with different names for use in two different contexts */
667
668         act = ActionManager::register_action (editor_actions, X_("addExistingAudioFiles"), _("Import"), sigc::mem_fun (*this, &Editor::external_audio_dialog));
669         ActionManager::session_sensitive_actions.push_back (act);
670         ActionManager::write_sensitive_actions.push_back (act);
671
672         act = ActionManager::register_action (editor_actions, X_("addExternalAudioToRegionList"), _("Import to Region List..."), sigc::bind (sigc::mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion));
673         ActionManager::session_sensitive_actions.push_back (act);
674         ActionManager::write_sensitive_actions.push_back (act);
675
676         act = ActionManager::register_action (editor_actions, X_("importFromSession"), _("Import From Session"), sigc::mem_fun(*this, &Editor::session_import_dialog));
677         ActionManager::write_sensitive_actions.push_back (act);
678
679         ActionManager::register_toggle_action (editor_actions, X_("ToggleSummary"), _("Show Summary"), sigc::mem_fun (*this, &Editor::set_summary));
680
681         ActionManager::register_toggle_action (editor_actions, X_("ToggleGroupTabs"), _("Show Group Tabs"), sigc::mem_fun (*this, &Editor::set_group_tabs));
682
683         ActionManager::register_toggle_action (editor_actions, X_("ToggleMeasureVisibility"), _("Show Measures"), sigc::mem_fun (*this, &Editor::toggle_measure_visibility));
684
685         /* if there is a logo in the editor canvas, its always visible at startup */
686
687         act = ActionManager::register_toggle_action (editor_actions, X_("ToggleLogoVisibility"), _("Show Logo"), sigc::mem_fun (*this, &Editor::toggle_logo_visibility));
688         Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
689         tact->set_active (true);
690
691         /* MIDI */
692
693         Glib::RefPtr<ActionGroup> midi_actions = ActionGroup::create (X_("MIDI"));
694         ActionManager::register_action (midi_actions, X_("panic"), _("Panic"), sigc::mem_fun(*this, &Editor::midi_panic));
695
696         ActionManager::add_action_group (rl_actions);
697         ActionManager::add_action_group (ruler_actions);
698         ActionManager::add_action_group (zoom_actions);
699         ActionManager::add_action_group (mouse_mode_actions);
700         ActionManager::add_action_group (snap_actions);
701         ActionManager::add_action_group (editor_actions);
702         ActionManager::add_action_group (midi_actions);
703 }
704
705 void
706 Editor::toggle_ruler_visibility (RulerType rt)
707 {
708         const char* action = 0;
709
710         if (no_ruler_shown_update) {
711                 return;
712         }
713
714         switch (rt) {
715         case ruler_metric_timecode:
716                 action = "toggle-timecode-ruler";
717                 break;
718         case ruler_metric_bbt:
719                 action = "toggle-bbt-ruler";
720                 break;
721         case ruler_metric_frames:
722                 action = "toggle-samples-ruler";
723                 break;
724         case ruler_metric_minsec:
725                 action = "toggle-minsec-ruler";
726                 break;
727         case ruler_time_tempo:
728                 action = "toggle-tempo-ruler";
729                 break;
730         case ruler_time_meter:
731                 action = "toggle-meter-ruler";
732                 break;
733         case ruler_time_marker:
734                 action = "toggle-marker-ruler";
735                 break;
736         case ruler_time_range_marker:
737                 action = "toggle-range-ruler";
738                 break;
739         case ruler_time_transport_marker:
740                 action = "toggle-loop-punch-ruler";
741                 break;
742         case ruler_time_cd_marker:
743                 action = "toggle-cd-marker-ruler";
744                 break;
745         }
746
747         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Rulers"), action);
748         if (act) {
749                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
750                 update_ruler_visibility ();
751                 store_ruler_visibility ();
752         }
753 }
754
755 void
756 Editor::set_summary ()
757 {
758         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleSummary"));
759         if (act) {
760                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
761                 _session->config.set_show_summary (tact->get_active ());
762         }
763 }
764
765 void
766 Editor::set_group_tabs ()
767 {
768         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleGroupTabs"));
769         if (act) {
770                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
771                 _session->config.set_show_group_tabs (tact->get_active ());
772         }
773 }
774
775 void
776 Editor::toggle_measure_visibility ()
777 {
778         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
779         if (act) {
780                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
781                 set_show_measures (tact->get_active());
782         }
783 }
784
785 void
786 Editor::toggle_logo_visibility ()
787 {
788         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleLogoVisibility"));
789
790         if (act) {
791                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
792                 if (logo_item) {
793                         if (tact->get_active()) {
794                                 logo_item->show ();
795                         } else {
796                                 logo_item->hide ();
797                         }
798                 }
799         }
800 }
801
802 RefPtr<RadioAction>
803 Editor::snap_type_action (SnapType type)
804 {
805         const char* action = 0;
806         RefPtr<Action> act;
807
808         switch (type) {
809         case Editing::SnapToCDFrame:
810                 action = "snap-to-cd-frame";
811                 break;
812         case Editing::SnapToTimecodeFrame:
813                 action = "snap-to-timecode-frame";
814                 break;
815         case Editing::SnapToTimecodeSeconds:
816                 action = "snap-to-timecode-seconds";
817                 break;
818         case Editing::SnapToTimecodeMinutes:
819                 action = "snap-to-timecode-minutes";
820                 break;
821         case Editing::SnapToSeconds:
822                 action = "snap-to-seconds";
823                 break;
824         case Editing::SnapToMinutes:
825                 action = "snap-to-minutes";
826                 break;
827         case Editing::SnapToBeatDiv32:
828                 action = "snap-to-thirtyseconds";
829                 break;
830         case Editing::SnapToBeatDiv28:
831                 action = "snap-to-twentyeighths";
832                 break;
833         case Editing::SnapToBeatDiv24:
834                 action = "snap-to-twentyfourths";
835                 break;
836         case Editing::SnapToBeatDiv20:
837                 action = "snap-to-twentieths";
838                 break;
839         case Editing::SnapToBeatDiv16:
840                 action = "snap-to-asixteenthbeat";
841                 break;
842         case Editing::SnapToBeatDiv14:
843                 action = "snap-to-fourteenths";
844                 break;
845         case Editing::SnapToBeatDiv12:
846                 action = "snap-to-twelfths";
847                 break;
848         case Editing::SnapToBeatDiv10:
849                 action = "snap-to-tenths";
850                 break;
851         case Editing::SnapToBeatDiv8:
852                 action = "snap-to-eighths";
853                 break;
854         case Editing::SnapToBeatDiv7:
855                 action = "snap-to-sevenths";
856                 break;
857         case Editing::SnapToBeatDiv6:
858                 action = "snap-to-sixths";
859                 break;
860         case Editing::SnapToBeatDiv5:
861                 action = "snap-to-fifths";
862                 break;
863         case Editing::SnapToBeatDiv4:
864                 action = "snap-to-quarters";
865                 break;
866         case Editing::SnapToBeatDiv3:
867                 action = "snap-to-thirds";
868                 break;
869         case Editing::SnapToBeatDiv2:
870                 action = "snap-to-halves";
871                 break;
872         case Editing::SnapToBeat:
873                 action = "snap-to-beat";
874                 break;
875         case Editing::SnapToBar:
876                 action = "snap-to-bar";
877                 break;
878         case Editing::SnapToMark:
879                 action = "snap-to-mark";
880                 break;
881         case Editing::SnapToRegionStart:
882                 action = "snap-to-region-start";
883                 break;
884         case Editing::SnapToRegionEnd:
885                 action = "snap-to-region-end";
886                 break;
887         case Editing::SnapToRegionSync:
888                 action = "snap-to-region-sync";
889                 break;
890         case Editing::SnapToRegionBoundary:
891                 action = "snap-to-region-boundary";
892                 break;
893         default:
894                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap-to type", (int) type) << endmsg;
895                 /*NOTREACHED*/
896         }
897
898         act = ActionManager::get_action (X_("Snap"), action);
899
900         if (act) {
901                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
902                 return ract;
903
904         } else  {
905                 error << string_compose (_("programming error: %1"), "Editor::snap_type_chosen could not find action to match type.") << endmsg;
906                 return RefPtr<RadioAction>();
907         }
908 }
909
910 void
911 Editor::cycle_snap_choice()
912 {
913         switch (_snap_type) {
914         case Editing::SnapToCDFrame:
915                 set_snap_to (Editing::SnapToTimecodeFrame);
916                 break;
917         case Editing::SnapToTimecodeFrame:
918                 set_snap_to (Editing::SnapToTimecodeSeconds);
919                 break;
920         case Editing::SnapToTimecodeSeconds:
921                 set_snap_to (Editing::SnapToTimecodeMinutes);
922                 break;
923         case Editing::SnapToTimecodeMinutes:
924                 set_snap_to (Editing::SnapToSeconds);
925                 break;
926         case Editing::SnapToSeconds:
927                 set_snap_to (Editing::SnapToMinutes);
928                 break;
929         case Editing::SnapToMinutes:
930                 set_snap_to (Editing::SnapToBeatDiv32);
931                 break;
932         case Editing::SnapToBeatDiv32:
933                 set_snap_to (Editing::SnapToBeatDiv28);
934                 break;
935         case Editing::SnapToBeatDiv28:
936                 set_snap_to (Editing::SnapToBeatDiv24);
937                 break;
938         case Editing::SnapToBeatDiv24:
939                 set_snap_to (Editing::SnapToBeatDiv20);
940                 break;
941         case Editing::SnapToBeatDiv20:
942                 set_snap_to (Editing::SnapToBeatDiv16);
943                 break;
944         case Editing::SnapToBeatDiv16:
945                 set_snap_to (Editing::SnapToBeatDiv14);
946                 break;
947         case Editing::SnapToBeatDiv14:
948                 set_snap_to (Editing::SnapToBeatDiv12);
949                 break;
950         case Editing::SnapToBeatDiv12:
951                 set_snap_to (Editing::SnapToBeatDiv10);
952                 break;
953         case Editing::SnapToBeatDiv10:
954                 set_snap_to (Editing::SnapToBeatDiv8);
955                 break;
956         case Editing::SnapToBeatDiv8:
957                 set_snap_to (Editing::SnapToBeatDiv7);
958                 break;
959         case Editing::SnapToBeatDiv7:
960                 set_snap_to (Editing::SnapToBeatDiv6);
961                 break;
962         case Editing::SnapToBeatDiv6:
963                 set_snap_to (Editing::SnapToBeatDiv5);
964                 break;
965         case Editing::SnapToBeatDiv5:
966                 set_snap_to (Editing::SnapToBeatDiv4);
967                 break;
968         case Editing::SnapToBeatDiv4:
969                 set_snap_to (Editing::SnapToBeatDiv3);
970                 break;
971         case Editing::SnapToBeatDiv3:
972                 set_snap_to (Editing::SnapToBeatDiv2);
973                 break;
974         case Editing::SnapToBeatDiv2:
975                 set_snap_to (Editing::SnapToBeat);
976                 break;
977         case Editing::SnapToBeat:
978                 set_snap_to (Editing::SnapToBar);
979                 break;
980         case Editing::SnapToBar:
981                 set_snap_to (Editing::SnapToMark);
982                 break;
983         case Editing::SnapToMark:
984                 set_snap_to (Editing::SnapToRegionStart);
985                 break;
986         case Editing::SnapToRegionStart:
987                 set_snap_to (Editing::SnapToRegionEnd);
988                 break;
989         case Editing::SnapToRegionEnd:
990                 set_snap_to (Editing::SnapToRegionSync);
991                 break;
992         case Editing::SnapToRegionSync:
993                 set_snap_to (Editing::SnapToRegionBoundary);
994                 break;
995         case Editing::SnapToRegionBoundary:
996                 set_snap_to (Editing::SnapToCDFrame);
997                 break;
998         }
999 }
1000
1001 void
1002 Editor::snap_type_chosen (SnapType type)
1003 {
1004         /* this is driven by a toggle on a radio group, and so is invoked twice,
1005            once for the item that became inactive and once for the one that became
1006            active.
1007         */
1008
1009         RefPtr<RadioAction> ract = snap_type_action (type);
1010
1011         if (ract && ract->get_active()) {
1012                 set_snap_to (type);
1013         }
1014 }
1015
1016 RefPtr<RadioAction>
1017 Editor::snap_mode_action (SnapMode mode)
1018 {
1019         const char* action = 0;
1020         RefPtr<Action> act;
1021
1022         switch (mode) {
1023         case Editing::SnapOff:
1024                 action = X_("snap-off");
1025                 break;
1026         case Editing::SnapNormal:
1027                 action = X_("snap-normal");
1028                 break;
1029         case Editing::SnapMagnetic:
1030                 action = X_("snap-magnetic");
1031                 break;
1032         default:
1033                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap mode type", (int) mode) << endmsg;
1034                 /*NOTREACHED*/
1035         }
1036
1037         act = ActionManager::get_action (X_("Editor"), action);
1038
1039         if (act) {
1040                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1041                 return ract;
1042
1043         } else  {
1044                 error << string_compose (_("programming error: %1: %2"), "Editor::snap_mode_chosen could not find action to match mode.", action) << endmsg;
1045                 return RefPtr<RadioAction> ();
1046         }
1047 }
1048
1049 void
1050 Editor::cycle_snap_mode ()
1051 {
1052         switch (_snap_mode) {
1053         case SnapOff:
1054                 set_snap_mode (SnapNormal);
1055                 break;
1056         case SnapNormal:
1057                 set_snap_mode (SnapMagnetic);
1058                 break;
1059         case SnapMagnetic:
1060                 set_snap_mode (SnapOff);
1061                 break;
1062         }
1063 }
1064
1065 void
1066 Editor::snap_mode_chosen (SnapMode mode)
1067 {
1068         /* this is driven by a toggle on a radio group, and so is invoked twice,
1069            once for the item that became inactive and once for the one that became
1070            active.
1071         */
1072
1073         RefPtr<RadioAction> ract = snap_mode_action (mode);
1074
1075         if (ract && ract->get_active()) {
1076                 set_snap_mode (mode);
1077         }
1078 }
1079
1080 RefPtr<RadioAction>
1081 Editor::edit_point_action (EditPoint ep)
1082 {
1083         const char* action = 0;
1084         RefPtr<Action> act;
1085
1086         switch (ep) {
1087         case Editing::EditAtPlayhead:
1088                 action = X_("edit-at-playhead");
1089                 break;
1090         case Editing::EditAtSelectedMarker:
1091                 action = X_("edit-at-selected-marker");
1092                 break;
1093         case Editing::EditAtMouse:
1094                 action = X_("edit-at-mouse");
1095                 break;
1096         default:
1097                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible edit point type", (int) ep) << endmsg;
1098                 /*NOTREACHED*/
1099         }
1100
1101         act = ActionManager::get_action (X_("Editor"), action);
1102
1103         if (act) {
1104                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1105                 return ract;
1106
1107         } else  {
1108                 error << string_compose (_("programming error: %1: %2"), "Editor::edit_point_action could not find action to match edit point.", action) << endmsg;
1109                 return RefPtr<RadioAction> ();
1110         }
1111 }
1112
1113 void
1114 Editor::edit_point_chosen (EditPoint ep)
1115 {
1116         /* this is driven by a toggle on a radio group, and so is invoked twice,
1117            once for the item that became inactive and once for the one that became
1118            active.
1119         */
1120
1121         RefPtr<RadioAction> ract = edit_point_action (ep);
1122
1123         if (ract && ract->get_active()) {
1124                 set_edit_point_preference (ep);
1125         }
1126 }
1127
1128
1129 RefPtr<RadioAction>
1130 Editor::zoom_focus_action (ZoomFocus focus)
1131 {
1132         const char* action = 0;
1133         RefPtr<Action> act;
1134
1135         switch (focus) {
1136         case ZoomFocusLeft:
1137                 action = X_("zoom-focus-left");
1138                 break;
1139         case ZoomFocusRight:
1140                 action = X_("zoom-focus-right");
1141                 break;
1142         case ZoomFocusCenter:
1143                 action = X_("zoom-focus-center");
1144                 break;
1145         case ZoomFocusPlayhead:
1146                 action = X_("zoom-focus-playhead");
1147                 break;
1148         case ZoomFocusMouse:
1149                 action = X_("zoom-focus-mouse");
1150                 break;
1151         case ZoomFocusEdit:
1152                 action = X_("zoom-focus-edit");
1153                 break;
1154         default:
1155                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible focus type", (int) focus) << endmsg;
1156                 /*NOTREACHED*/
1157         }
1158
1159         act = ActionManager::get_action (X_("Zoom"), action);
1160
1161         if (act) {
1162                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1163                 return ract;
1164         } else {
1165                 error << string_compose (_("programming error: %1: %2"), "Editor::zoom_focus_action could not find action to match focus.", action) << endmsg;
1166         }
1167
1168         return RefPtr<RadioAction> ();
1169 }
1170
1171 void
1172 Editor::zoom_focus_chosen (ZoomFocus focus)
1173 {
1174         /* this is driven by a toggle on a radio group, and so is invoked twice,
1175            once for the item that became inactive and once for the one that became
1176            active.
1177         */
1178
1179         RefPtr<RadioAction> ract = zoom_focus_action (focus);
1180
1181         if (ract && ract->get_active()) {
1182                 set_zoom_focus (focus);
1183         }
1184 }
1185
1186 /** A Configuration parameter has changed.
1187  * @param parameter_name Name of the changed parameter.
1188  */
1189 void
1190 Editor::parameter_changed (std::string p)
1191 {
1192         ENSURE_GUI_THREAD (*this, &Editor::parameter_changed, p)
1193
1194         if (p == "auto-loop") {
1195                 update_loop_range_view (true);
1196         } else if (p == "punch-in") {
1197                 update_punch_range_view (true);
1198         } else if (p == "punch-out") {
1199                 update_punch_range_view (true);
1200         } else if (p == "timecode-format") {
1201                 update_just_timecode ();
1202         } else if (p == "xfades-visible") {
1203                 update_xfade_visibility ();
1204         } else if (p == "show-region-fades") {
1205                 update_region_fade_visibility ();
1206         } else if (p == "edit-mode") {
1207                 edit_mode_selector.set_active_text (edit_mode_to_string (Config->get_edit_mode()));
1208         } else if (p == "subframes-per-frame") {
1209                 update_just_timecode ();
1210         } else if (p == "show-track-meters") {
1211                 toggle_meter_updating();
1212         } else if (p == "show-summary") {
1213
1214                 bool const s = _session->config.get_show_summary ();
1215                 if (s) {
1216                         _summary_hbox.show ();
1217                 } else {
1218                         _summary_hbox.hide ();
1219                 }
1220
1221                 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleSummary"));
1222                 if (act) {
1223                         Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
1224                         if (tact->get_active () != s) {
1225                                 tact->set_active (s);
1226                         }
1227                 }
1228         } else if (p == "show-group-tabs") {
1229
1230                 bool const s = _session->config.get_show_group_tabs ();
1231                 if (s) {
1232                         _group_tabs->show ();
1233                 } else {
1234                         _group_tabs->hide ();
1235                 }
1236
1237                 Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleGroupTabs"));
1238                 if (act) {
1239                         Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
1240                         if (tact->get_active () != s) {
1241                                 tact->set_active (s);
1242                         }
1243                 }
1244         }
1245 }
1246
1247 void
1248 Editor::reset_focus ()
1249 {
1250         track_canvas->grab_focus();
1251 }
1252
1253 void
1254 Editor::reset_canvas_action_sensitivity (bool onoff)
1255 {
1256         if (_edit_point != EditAtMouse) {
1257                 onoff = true;
1258         }
1259
1260         for (vector<Glib::RefPtr<Action> >::iterator x = ActionManager::mouse_edit_point_requires_canvas_actions.begin();
1261              x != ActionManager::mouse_edit_point_requires_canvas_actions.end(); ++x) {
1262                 (*x)->set_sensitive (onoff);
1263         }
1264 }
1265
1266 void
1267 Editor::toggle_internal_editing ()
1268 {
1269         Glib::RefPtr<Gtk::Action> act = ActionManager::get_action (X_("MouseMode"), X_("toggle-internal-edit"));
1270         if (act) {
1271                 Glib::RefPtr<Gtk::ToggleAction> tact = Glib::RefPtr<Gtk::ToggleAction>::cast_dynamic(act);
1272                 set_internal_edit (tact->get_active());
1273         }
1274 }
1275
1276 /* Convenience functions to slightly reduce verbosity below */
1277
1278 static RefPtr<Action>
1279 reg_sens (RefPtr<ActionGroup> group, char const * name, char const * label, sigc::slot<void> slot)
1280 {
1281         RefPtr<Action> act = ActionManager::register_action (group, name, label, slot);
1282         ActionManager::session_sensitive_actions.push_back (act);
1283         return act;
1284 }
1285
1286 static void
1287 toggle_reg_sens (RefPtr<ActionGroup> group, char const * name, char const * label, sigc::slot<void> slot)
1288 {
1289         RefPtr<Action> act = ActionManager::register_toggle_action (group, name, label, slot);
1290         ActionManager::session_sensitive_actions.push_back (act);
1291 }
1292
1293 void
1294 Editor::register_region_actions ()
1295 {
1296         _region_actions = ActionGroup::create (X_("Region"));
1297         
1298         /* PART 1: actions that operate on the selection, and for which the edit point type and location is irrelevant */
1299
1300         /* Remove selected regions */
1301         reg_sens (_region_actions, "remove-region", _("Remove"), sigc::mem_fun (*this, &Editor::remove_selected_regions));
1302         
1303         /* Offer dialogue box to rename the first selected region */
1304         reg_sens (_region_actions, "rename-region", _("Rename..."), sigc::mem_fun (*this, &Editor::rename_region));
1305         
1306         /* Raise all selected regions by 1 layer */
1307         reg_sens (_region_actions, "raise-region", _("Raise"), sigc::mem_fun (*this, &Editor::raise_region));
1308
1309         /* Raise all selected regions to the top */
1310         reg_sens (_region_actions, "raise-region-to-top", _("Raise to Top"), sigc::mem_fun (*this, &Editor::raise_region_to_top));
1311         
1312         /* Lower all selected regions by 1 layer */
1313         reg_sens (_region_actions, "lower-region", _("Lower"), sigc::mem_fun (*this, &Editor::lower_region));
1314
1315         /* Lower all selected regions to the bottom */
1316         reg_sens (_region_actions, "lower-region-to-bottom", _("Lower to Bottom"), sigc::mem_fun (*this, &Editor::lower_region_to_bottom));
1317         
1318         /* Move selected regions to their original (`natural') position */
1319         reg_sens (_region_actions, "naturalize-region", _("Move to Original Position"), sigc::mem_fun (*this, &Editor::naturalize_region));
1320         
1321         /* Toggle `locked' status of selected regions */
1322         toggle_reg_sens (_region_actions, "toggle-region-lock", _("Lock"), sigc::mem_fun(*this, &Editor::toggle_region_lock));
1323
1324         toggle_reg_sens (
1325                 _region_actions,
1326                 "toggle-region-lock-style",
1327                 _("Glue to Bars and Beats"),
1328                 sigc::mem_fun (*this, &Editor::toggle_region_lock_style)
1329                 );
1330         
1331         /* Remove sync points from selected regions */
1332         reg_sens (_region_actions, "remove-region-sync", _("Remove Sync"), sigc::mem_fun(*this, &Editor::remove_region_sync));
1333         
1334         /* Mute or unmute selected regions */
1335         toggle_reg_sens (_region_actions, "toggle-region-mute", _("Mute"), sigc::mem_fun(*this, &Editor::toggle_region_mute));
1336         
1337         /* Open the normalize dialogue to operate on the selected regions */
1338         reg_sens (_region_actions, "normalize-region", _("Normalize..."), sigc::mem_fun(*this, &Editor::normalize_region));
1339         
1340         /* Reverse selected regions */
1341         reg_sens (_region_actions, "reverse-region", _("Reverse"), sigc::mem_fun (*this, &Editor::reverse_region));
1342         
1343         /* Split selected multi-channel regions into mono regions */
1344         reg_sens (_region_actions, "split-multichannel-region", _("Make Mono Regions"), sigc::mem_fun (*this, &Editor::split_multichannel_region));
1345         
1346         /* Boost selected region gain */
1347         reg_sens (_region_actions, "boost-region-gain", _("Boost Gain"), sigc::bind (sigc::mem_fun(*this, &Editor::adjust_region_gain), true));
1348         
1349         /* Cut selected region gain */
1350         reg_sens (_region_actions, "cut-region-gain", _("Cut Gain"), sigc::bind (sigc::mem_fun(*this, &Editor::adjust_region_gain), false));
1351         
1352         /* Open the pitch shift dialogue for the selected regions */
1353         reg_sens (_region_actions, "pitch-shift-region", _("Transpose"), sigc::mem_fun (*this, &Editor::pitch_shift_region));
1354         
1355         /* Toggle selected region opacity */
1356         toggle_reg_sens (_region_actions, "toggle-opaque-region", _("Opaque"), sigc::mem_fun (*this, &Editor::toggle_opaque_region));
1357         
1358         /* Toggle active status of selected regions' fade in */
1359         toggle_reg_sens (
1360                 _region_actions, "toggle-region-fade-in", _("Fade In"), sigc::bind (sigc::mem_fun (*this, &Editor::toggle_region_fades), 1)
1361                 );
1362         
1363         /* Toggle active status of selected regions' fade out */
1364         toggle_reg_sens (
1365                 _region_actions, "toggle-region-fade-out", _("Fade Out"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_region_fades), -1)
1366                 );
1367         
1368         /* Toggle active status of selected regions' fade in and out */
1369         toggle_reg_sens (
1370                 _region_actions, "toggle-region-fades", _("Fades"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_region_fades), 0)
1371                 );
1372         
1373         /* Open the dialogue to duplicate selected regions */
1374         reg_sens (_region_actions, "duplicate-region", _("Duplicate"), sigc::bind (sigc::mem_fun (*this, &Editor::duplicate_dialog), false));
1375         
1376         /* Open the dialogue to duplicate selected regions multiple times */
1377         reg_sens (
1378                 _region_actions,
1379                 "multi-duplicate-region",
1380                 _("Multi-Duplicate..."),
1381                 sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_dialog), true)
1382                 );
1383         
1384         /* Fill tracks with selected regions */
1385         reg_sens (_region_actions, "region-fill-track", _("Fill Track"), sigc::mem_fun (*this, &Editor::region_fill_track));
1386         
1387         /* Set up the loop range from the selected regions */
1388         reg_sens (
1389                 _region_actions, "set-loop-from-region", _("Set Loop Range"), sigc::bind (sigc::mem_fun (*this, &Editor::set_loop_from_region), false)
1390                 );
1391         
1392         /* Set up the loop range from the selected regions, and start playback of it */
1393         reg_sens (_region_actions, "loop-region", _("Loop"), sigc::bind  (sigc::mem_fun(*this, &Editor::set_loop_from_region), true));
1394         
1395         /* Set the punch range from the selected regions */
1396         reg_sens (_region_actions, "set-punch-from-region", _("Set Punch"), sigc::mem_fun (*this, &Editor::set_punch_from_region));
1397         
1398         /* Add a single range marker around all selected regions */
1399         reg_sens (
1400                 _region_actions, "add-range-marker-from-region", _("Add 1 Range Marker"), sigc::mem_fun (*this, &Editor::add_location_from_region)
1401                 );
1402         
1403         /* Add a range marker around each selected region */
1404         reg_sens (
1405                 _region_actions, "add-range-markers-from-region", _("Add Range Marker(s)"), sigc::mem_fun (*this, &Editor::add_locations_from_region)
1406                 );
1407
1408         /* Snap selected regions to the grid */
1409         reg_sens (_region_actions, "snap-regions-to-grid", _("Snap to Grid"), sigc::mem_fun (*this, &Editor::snap_regions_to_grid));
1410
1411         /* Close gaps in selected regions */
1412         reg_sens (_region_actions, "close-region-gaps", _("Close Gaps"), sigc::mem_fun (*this, &Editor::close_region_gaps));
1413
1414         /* Open the Rhythm Ferret dialogue for the selected regions */
1415         reg_sens (_region_actions, "show-rhythm-ferret", _("Rhythm Ferret..."), sigc::mem_fun (*this, &Editor::show_rhythm_ferret));
1416
1417         /* Export the first selected region */
1418         reg_sens (_region_actions, "export-region", _("Export..."), sigc::mem_fun (*this, &Editor::export_region));
1419
1420         /* Separate under selected regions: XXX not sure what this does */
1421         reg_sens (
1422                 _region_actions,
1423                 "separate-under-region",
1424                 _("Separate Under"),
1425                 sigc::mem_fun (*this, &Editor::separate_under_selected_regions)
1426                 );
1427
1428         reg_sens (_region_actions, "set-fade-in-length", _("Set Fade In Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), true));
1429         reg_sens (_region_actions, "set-fade-out-length", _("Set Fade Out Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), false));
1430         reg_sens (_region_actions, "set-tempo-from-region", _("Set Tempo from Region = Bar"), sigc::mem_fun (*this, &Editor::set_tempo_from_region));
1431
1432         reg_sens (
1433                 _region_actions,
1434                 "split-region-at-transients",
1435                 _("Split at Percussion Onsets"),
1436                 sigc::mem_fun(*this, &Editor::split_region_at_transients)
1437                 );
1438
1439         /* Open the list editor dialogue for the selected regions */
1440         reg_sens (_region_actions, "show-region-list-editor", _("List Editor..."), sigc::mem_fun (*this, &Editor::show_midi_list_editor));
1441
1442         /* Open the region properties dialogue for the selected regions */
1443         reg_sens (_region_actions, "show-region-properties", _("Properties..."), sigc::mem_fun (*this, &Editor::show_region_properties));
1444
1445         reg_sens (_region_actions, "play-selected-regions", _("Play"), sigc::mem_fun(*this, &Editor::play_selected_region));
1446
1447         reg_sens (_region_actions, "bounce-region", _("Bounce"), sigc::mem_fun (*this, &Editor::bounce_region_selection));
1448
1449         reg_sens (_region_actions, "analyze-region", _("Spectral Analysis..."), sigc::mem_fun (*this, &Editor::analyze_region_selection));
1450
1451         reg_sens (_region_actions, "reset-region-gain-envelopes", _("Reset Envelope"), sigc::mem_fun (*this, &Editor::reset_region_gain_envelopes));
1452
1453         reg_sens (_region_actions, "reset-region-scale-amplitude", _("Reset Gain"), sigc::mem_fun (*this, &Editor::reset_region_scale_amplitude));
1454
1455         toggle_reg_sens (
1456                 _region_actions,
1457                 "toggle-region-gain-envelope-visible",
1458                 _("Envelope Visible"),
1459                 sigc::mem_fun (*this, &Editor::toggle_gain_envelope_visibility)
1460                 );
1461
1462         toggle_reg_sens (
1463                 _region_actions,
1464                 "toggle-region-gain-envelope-active",
1465                 _("Envelope Active"),
1466                 sigc::mem_fun (*this, &Editor::toggle_gain_envelope_active)
1467                 );
1468
1469         reg_sens (_region_actions, "quantize-region", _("Quantize"), sigc::mem_fun (*this, &Editor::quantize_region));
1470         reg_sens (_region_actions, "fork-region", _("Fork"), sigc::mem_fun (*this, &Editor::fork_region));
1471         reg_sens (_region_actions, "strip-region-silence", _("Strip Silence..."), sigc::mem_fun (*this, &Editor::strip_region_silence));
1472         reg_sens (_region_actions, "set-selection-from-region", _("Set Range Selection"), sigc::mem_fun (*this, &Editor::set_selection_from_region));
1473
1474         reg_sens (_region_actions, "nudge-forward", _("Nudge Forward"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_forward), false, false));
1475         reg_sens (_region_actions, "nudge-backward", _("Nudge Backward"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_backward), false, false));
1476
1477         reg_sens (
1478                 _region_actions,
1479                 "nudge-forward-by-capture-offset",
1480                 _("Nudge Forward by Capture Offset"),
1481                 sigc::mem_fun (*this, &Editor::nudge_forward_capture_offset)
1482                 );
1483         
1484         reg_sens (
1485                 _region_actions,
1486                 "nudge-backward-by-capture-offset",
1487                 _("Nudge Backward by Capture Offset"),
1488                 sigc::mem_fun (*this, &Editor::nudge_backward_capture_offset)
1489                 );
1490
1491         reg_sens (_region_actions, "trim-region-to-loop", _("Trim to Loop"), sigc::mem_fun (*this, &Editor::trim_region_to_loop));
1492         reg_sens (_region_actions, "trim-region-to-punch", _("Trim to Punch"), sigc::mem_fun (*this, &Editor::trim_region_to_punch));
1493         
1494         reg_sens (_region_actions, "trim-to-previous-region", _("Trim to Previous"), sigc::mem_fun(*this, &Editor::trim_region_to_previous_region_end));
1495         reg_sens (_region_actions, "trim-to-next-region", _("Trim to Next"), sigc::mem_fun(*this, &Editor::trim_region_to_next_region_start));
1496
1497         /* PART 2: actions that are not related to the selection, but for which the edit point type and location is important */
1498
1499         reg_sens (
1500                 _region_actions,
1501                 "insert-region-from-region-list",
1502                 _("Insert Region From Region List"),
1503                 sigc::bind (sigc::mem_fun (*this, &Editor::insert_region_list_selection), 1)
1504                 );
1505
1506         /* PART 3: actions that operate on the selection and also require the edit point location */
1507
1508         reg_sens (_region_actions, "set-region-sync-position", _("Set Sync Position"), sigc::mem_fun (*this, &Editor::set_region_sync_position));
1509         reg_sens (_region_actions, "place-transient", _("Place Transient"), sigc::mem_fun (*this, &Editor::place_transient));
1510         reg_sens (_region_actions, "split-region", _("Split"), sigc::mem_fun (*this, &Editor::split_region));
1511         reg_sens (_region_actions, "trim-front", _("Trim Start at Edit Point"), sigc::mem_fun (*this, &Editor::trim_region_front));
1512         reg_sens (_region_actions, "trim-back", _("Trim End at Edit Point"), sigc::mem_fun (*this, &Editor::trim_region_back));
1513
1514         reg_sens (
1515                 _region_actions,
1516                 "align-regions-start",
1517                 _("Align Start"),
1518                 sigc::bind (sigc::mem_fun(*this, &Editor::align_regions), ARDOUR::Start)
1519                 );
1520         
1521         reg_sens (
1522                 _region_actions,
1523                 "align-regions-start-relative",
1524                 _("Align Start Relative"),
1525                 sigc::bind (sigc::mem_fun (*this, &Editor::align_regions_relative), ARDOUR::Start)
1526                 );
1527         
1528         reg_sens (_region_actions, "align-regions-end", _("Align End"), sigc::bind (sigc::mem_fun (*this, &Editor::align_regions), ARDOUR::End));
1529
1530         reg_sens (
1531                 _region_actions,
1532                 "align-regions-end-relative",
1533                 _("Align End Relative"),
1534                 sigc::bind (sigc::mem_fun(*this, &Editor::align_regions_relative), ARDOUR::End)
1535                 );
1536
1537         reg_sens (
1538                 _region_actions,
1539                 "align-regions-sync",
1540                 _("Align Sync"),
1541                 sigc::bind (sigc::mem_fun(*this, &Editor::align_regions), ARDOUR::SyncPoint)
1542                 );
1543         
1544         reg_sens (
1545                 _region_actions,
1546                 "align-regions-sync-relative",
1547                 _("Align Sync Relative"),
1548                 sigc::bind (sigc::mem_fun (*this, &Editor::align_regions_relative), ARDOUR::SyncPoint)
1549                 );
1550
1551         Glib::RefPtr<Action> a = reg_sens (_region_actions, "choose-top-region", _("Choose Top..."), mem_fun (*this, &Editor::change_region_layering_order));
1552         a->set_accel_group (get_accel_group ());
1553
1554         _all_region_actions_sensitized = true;
1555
1556         ActionManager::add_action_group (_region_actions);
1557 }