the return of VST support
[ardour.git] / gtk2_ardour / editor_actions.cc
1 #include <ardour/ardour.h>
2
3 #include "utils.h"
4 #include "editor.h"
5 #include "editing.h"
6 #include "actions.h"
7 #include "ardour_ui.h"
8 #include "i18n.h"
9
10 using namespace Gtk;
11 using namespace Glib;
12 using namespace std;
13 using namespace sigc;
14 using namespace ARDOUR;
15 using namespace PBD;
16 using namespace Editing;
17
18 void
19 Editor::register_actions ()
20 {
21         RefPtr<Action> act;
22
23         editor_actions = ActionGroup::create (X_("Editor"));
24         
25         /* non-operative menu items for menu bar */
26
27         ActionManager::register_action (editor_actions, X_("Edit"), _("Edit"));
28         ActionManager::register_action (editor_actions, X_("EditSelectRegionOptions"), _("Select regions"));
29         ActionManager::register_action (editor_actions, X_("EditSelectRangeOptions"), _("Select range operations"));
30         ActionManager::register_action (editor_actions, X_("EditCursorMovementOptions"), _("Move edit cursor"));
31         ActionManager::register_action (editor_actions, X_("RegionEditOps"), _("Region operations"));
32         ActionManager::register_action (editor_actions, X_("Tools"), _("Tools"));
33         ActionManager::register_action (editor_actions, X_("View"), _("View"));
34         ActionManager::register_action (editor_actions, X_("ZoomFocus"), _("ZoomFocus"));
35         ActionManager::register_action (editor_actions, X_("MeterHold"), _("Meter hold"));
36         ActionManager::register_action (editor_actions, X_("MeterFalloff"), _("Meter falloff"));
37         ActionManager::register_action (editor_actions, X_("Solo"), _("Solo"));
38         ActionManager::register_action (editor_actions, X_("Crossfades"), _("Crossfades"));
39         ActionManager::register_action (editor_actions, X_("Monitoring"), _("Monitoring"));
40         ActionManager::register_action (editor_actions, X_("Autoconnect"), _("Autoconnect"));
41         ActionManager::register_action (editor_actions, X_("Layering"), _("Layering"));
42         ActionManager::register_action (editor_actions, X_("Metering"), _("Metering"));
43         ActionManager::register_action (editor_actions, X_("MeteringFallOffRate"), _("Fall off rate"));
44         ActionManager::register_action (editor_actions, X_("MeteringHoldTime"), _("Hold Time"));
45         ActionManager::register_action (editor_actions, X_("addExistingAudioFiles"), _("Add Existing Audio"));
46
47         /* add named actions for the editor */
48
49
50         act = ActionManager::register_toggle_action (editor_actions, "show-editor-mixer", _("Show Editor Mixer"), mem_fun (*this, &Editor::editor_mixer_button_toggled));
51         ActionManager::session_sensitive_actions.push_back (act);
52
53         RadioAction::Group crossfade_model_group;
54
55         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesFull", _("Span Entire Overlap"), bind (mem_fun(*this, &Editor::set_crossfade_model), FullCrossfade));
56         ActionManager::session_sensitive_actions.push_back (act);
57         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesShort", _("Short"), bind (mem_fun(*this, &Editor::set_crossfade_model), ShortCrossfade));
58         ActionManager::session_sensitive_actions.push_back (act);
59
60         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-active", _("Active"), mem_fun(*this, &Editor::toggle_xfades_active));
61         ActionManager::session_sensitive_actions.push_back (act);
62         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-visible", _("Visible"), mem_fun(*this, &Editor::toggle_xfade_visibility));
63         ActionManager::session_sensitive_actions.push_back (act);
64         act = ActionManager::register_toggle_action (editor_actions, "toggle-auto-xfades", _("Created Automatically"), mem_fun(*this, &Editor::toggle_auto_xfade));
65         ActionManager::session_sensitive_actions.push_back (act);
66
67         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-start", _("Playhead to Next Region Start"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (Start)));
68         ActionManager::session_sensitive_actions.push_back (act);
69         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-end", _("Playhead to Next Region End"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (End)));
70         ActionManager::session_sensitive_actions.push_back (act);
71         act = ActionManager::register_action (editor_actions, "playhead-to-next-region-sync", _("Playhead to Next Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), playhead_cursor, RegionPoint (SyncPoint)));
72         ActionManager::session_sensitive_actions.push_back (act);
73
74         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-start", _("Playhead to Previous Region Start"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (Start)));
75         ActionManager::session_sensitive_actions.push_back (act);
76         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-end", _("Playhead to Previous Region End"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (End)));
77         ActionManager::session_sensitive_actions.push_back (act);
78         act = ActionManager::register_action (editor_actions, "playhead-to-previous-region-sync", _("Playhead to Previous Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), playhead_cursor, RegionPoint (SyncPoint)));
79         ActionManager::session_sensitive_actions.push_back (act);
80
81         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-start", _("Edit Cursor to Next Region Start"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), edit_cursor, RegionPoint (Start)));
82         ActionManager::session_sensitive_actions.push_back (act);
83         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-end", _("Edit Cursor to Next Region End"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), edit_cursor, RegionPoint (End)));
84         ActionManager::session_sensitive_actions.push_back (act);
85         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-sync", _("Edit Cursor to Next Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_next_region_point), edit_cursor, RegionPoint (SyncPoint)));
86         ActionManager::session_sensitive_actions.push_back (act);
87
88         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-start", _("Edit Cursor to Previous Region Start"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), edit_cursor, RegionPoint (Start)));
89         ActionManager::session_sensitive_actions.push_back (act);
90         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-end", _("Edit Cursor to Previous Region End"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), edit_cursor, RegionPoint (End)));
91         ActionManager::session_sensitive_actions.push_back (act);
92         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-sync", _("Edit Cursor to Previous Region Sync"), bind (mem_fun(*this, &Editor::cursor_to_previous_region_point), edit_cursor, RegionPoint (SyncPoint)));
93         ActionManager::session_sensitive_actions.push_back (act);
94
95         act = ActionManager::register_action (editor_actions, "playhead-to-range-start", _("Playhead to Range Start"), bind (mem_fun(*this, &Editor::cursor_to_selection_start), playhead_cursor));
96         ActionManager::session_sensitive_actions.push_back (act);
97         act = ActionManager::register_action (editor_actions, "playhead-to-range-end", _("Playhead to Range End"), bind (mem_fun(*this, &Editor::cursor_to_selection_end), playhead_cursor));
98         ActionManager::session_sensitive_actions.push_back (act);
99
100         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-start", _("Edit Cursor to Range Start"), bind (mem_fun(*this, &Editor::cursor_to_selection_start), edit_cursor));
101         ActionManager::session_sensitive_actions.push_back (act);
102         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-end", _("Edit Cursor to Range End"), bind (mem_fun(*this, &Editor::cursor_to_selection_end), edit_cursor));
103         ActionManager::session_sensitive_actions.push_back (act);
104
105         act = ActionManager::register_action (editor_actions, "select-all", _("select all"), bind (mem_fun(*this, &Editor::select_all), Selection::Set));
106         ActionManager::session_sensitive_actions.push_back (act);
107         act = ActionManager::register_action (editor_actions, "select-all-after-edit-cursor", _("Select All After Edit Cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, true));
108         ActionManager::session_sensitive_actions.push_back (act);
109         act = ActionManager::register_action (editor_actions, "select-all-before-edit-cursor", _("Select All Before Edit Cursor"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), edit_cursor, false));
110         ActionManager::session_sensitive_actions.push_back (act);
111
112         act = ActionManager::register_action (editor_actions, "select-all-after-playhead", _("Select All After Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, true));
113         ActionManager::session_sensitive_actions.push_back (act);
114         act = ActionManager::register_action (editor_actions, "select-all-before-playhead", _("Select All Before Playhead"), bind (mem_fun(*this, &Editor::select_all_selectables_using_cursor), playhead_cursor, false));
115         ActionManager::session_sensitive_actions.push_back (act);
116         act = ActionManager::register_action (editor_actions, "select-all-between-cursors", _("Select All Between Cursors"), bind (mem_fun(*this, &Editor::select_all_selectables_between_cursors), playhead_cursor, edit_cursor));
117         ActionManager::session_sensitive_actions.push_back (act);
118
119         act = ActionManager::register_action (editor_actions, "select-all-in-punch-range", _("Select All in Punch Range"), mem_fun(*this, &Editor::select_all_selectables_using_punch));
120         ActionManager::session_sensitive_actions.push_back (act);
121         act = ActionManager::register_action (editor_actions, "select-all-in-loop-range", _("Select All in Loop Range"), mem_fun(*this, &Editor::select_all_selectables_using_loop));
122         ActionManager::session_sensitive_actions.push_back (act);
123
124         act = ActionManager::register_action (editor_actions, "jump-forward-to-mark", _("Jump Forward to Mark"), mem_fun(*this, &Editor::jump_forward_to_mark));
125         ActionManager::session_sensitive_actions.push_back (act);
126         act = ActionManager::register_action (editor_actions, "jump-backward-to-mark", _("Jump Backward to Mark"), mem_fun(*this, &Editor::jump_backward_to_mark));
127         ActionManager::session_sensitive_actions.push_back (act);
128         act = ActionManager::register_action (editor_actions, "add-location-from-playhead", _("Add Location from Playhead"), mem_fun(*this, &Editor::add_location_from_playhead_cursor));
129         ActionManager::session_sensitive_actions.push_back (act);
130
131         act = ActionManager::register_action (editor_actions, "nudge-forward", _("Nudge Forward"), bind (mem_fun(*this, &Editor::nudge_forward), false));
132         ActionManager::session_sensitive_actions.push_back (act);
133         act = ActionManager::register_action (editor_actions, "nudge-next-forward", _("Nudge Next Forward"), bind (mem_fun(*this, &Editor::nudge_forward), true));
134         ActionManager::session_sensitive_actions.push_back (act);
135         act = ActionManager::register_action (editor_actions, "nudge-backward", _("Nudge Backward"), bind (mem_fun(*this, &Editor::nudge_backward), false));
136         ActionManager::session_sensitive_actions.push_back (act);
137         act = ActionManager::register_action (editor_actions, "nudge-next-backward", _("Nudge Next Backward"), bind (mem_fun(*this, &Editor::nudge_backward), true));
138         ActionManager::session_sensitive_actions.push_back (act);
139
140         act = ActionManager::register_action (editor_actions, "temporal-zoom-out", _("Zoom Out"), bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
141         ActionManager::session_sensitive_actions.push_back (act);
142         act = ActionManager::register_action (editor_actions, "temporal-zoom-in", _("Zoom In"), bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
143         ActionManager::session_sensitive_actions.push_back (act);
144         act = ActionManager::register_action (editor_actions, "zoom-to-session", _("Zoom to Session"), mem_fun(*this, &Editor::temporal_zoom_session));
145         ActionManager::session_sensitive_actions.push_back (act);
146
147         act = ActionManager::register_action (editor_actions, "scroll-tracks-up", _("Scroll Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up));
148         ActionManager::session_sensitive_actions.push_back (act);
149         act = ActionManager::register_action (editor_actions, "scroll-tracks-down", _("Scroll Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down));
150         ActionManager::session_sensitive_actions.push_back (act);
151         act = ActionManager::register_action (editor_actions, "step-tracks-up", _("Step Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up_line));
152         ActionManager::session_sensitive_actions.push_back (act);
153         act = ActionManager::register_action (editor_actions, "step-tracks-down", _("Step Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down_line));
154         ActionManager::session_sensitive_actions.push_back (act);
155
156         act = ActionManager::register_action (editor_actions, "scroll-backward", _("Scroll Backward"), bind (mem_fun(*this, &Editor::scroll_backward), 0.8f));
157         ActionManager::session_sensitive_actions.push_back (act);
158         act = ActionManager::register_action (editor_actions, "scroll-forward", _("Scroll Forward"), bind (mem_fun(*this, &Editor::scroll_forward), 0.8f));
159         ActionManager::session_sensitive_actions.push_back (act);
160         act = ActionManager::register_action (editor_actions, "goto", _("goto"), mem_fun(*this, &Editor::goto_frame));
161         ActionManager::session_sensitive_actions.push_back (act);
162         act = ActionManager::register_action (editor_actions, "center-playhead", _("Center Playhead"), mem_fun(*this, &Editor::center_playhead));
163         ActionManager::session_sensitive_actions.push_back (act);
164         act = ActionManager::register_action (editor_actions, "center-edit-cursor", _("Center Edit Cursor"), mem_fun(*this, &Editor::center_edit_cursor));
165         ActionManager::session_sensitive_actions.push_back (act);
166         act = ActionManager::register_action (editor_actions, "playhead-forward", _("Playhead Forward"), mem_fun(*this, &Editor::playhead_forward));
167         ActionManager::session_sensitive_actions.push_back (act);
168         act = ActionManager::register_action (editor_actions, "playhead-backward", _("Playhead Backward"), mem_fun(*this, &Editor::playhead_backward));
169         ActionManager::session_sensitive_actions.push_back (act);
170         act = ActionManager::register_action (editor_actions, "playhead-to-edit", _("Playhead to Edit"), bind (mem_fun(*this, &Editor::cursor_align), true));
171         ActionManager::session_sensitive_actions.push_back (act);
172         act = ActionManager::register_action (editor_actions, "edit-to-playhead", _("Edit to Playhead"), bind (mem_fun(*this, &Editor::cursor_align), false));
173         ActionManager::session_sensitive_actions.push_back (act);
174
175         act = ActionManager::register_action (editor_actions, "align-regions-start", _("Align Regions Start"), bind (mem_fun(*this, &Editor::align), ARDOUR::Start));
176         ActionManager::session_sensitive_actions.push_back (act);
177         act = ActionManager::register_action (editor_actions, "align-regions-start-relative", _("Align Regions Start Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::Start));
178         ActionManager::session_sensitive_actions.push_back (act);
179         act = ActionManager::register_action (editor_actions, "align-regions-end", _("Align Regions End"), bind (mem_fun(*this, &Editor::align), ARDOUR::End));
180         ActionManager::session_sensitive_actions.push_back (act);
181         act = ActionManager::register_action (editor_actions, "align-regions-end-relative", _("Align Regions End Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::End));
182         ActionManager::session_sensitive_actions.push_back (act);
183
184         act = ActionManager::register_action (editor_actions, "align-regions-sync", _("Align Regions Sync"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint));
185         ActionManager::session_sensitive_actions.push_back (act);
186         act = ActionManager::register_action (editor_actions, "align-regions-sync-relative", _("Align Regions Sync Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint));
187         ActionManager::session_sensitive_actions.push_back (act);
188         
189         act = ActionManager::register_action (editor_actions, "audition-at-mouse", _("Audition at Mouse"), mem_fun(*this, &Editor::kbd_audition));
190         ActionManager::session_sensitive_actions.push_back (act);
191         act = ActionManager::register_action (editor_actions, "brush-at-mouse", _("Brush at Mouse"), mem_fun(*this, &Editor::kbd_brush));
192         ActionManager::session_sensitive_actions.push_back (act);
193         act = ActionManager::register_action (editor_actions, "set-edit-cursor", _("Set Edit Cursor"), mem_fun(*this, &Editor::kbd_set_edit_cursor));
194         ActionManager::session_sensitive_actions.push_back (act);
195         act = ActionManager::register_action (editor_actions, "mute-unmute-region", _("Mute/Unmute Region"), mem_fun(*this, &Editor::kbd_mute_unmute_region));
196         ActionManager::session_sensitive_actions.push_back (act);
197         act = ActionManager::register_action (editor_actions, "set-playhead", _("Set Playhead"), mem_fun(*this, &Editor::kbd_set_playhead_cursor));
198         ActionManager::session_sensitive_actions.push_back (act);
199         act = ActionManager::register_action (editor_actions, "split-region", _("Split Region"), mem_fun(*this, &Editor::kbd_split));
200         ActionManager::session_sensitive_actions.push_back (act);
201         act = ActionManager::register_action (editor_actions, "set-region-sync-position", _("Set Region Sync Position"), mem_fun(*this, &Editor::kbd_set_sync_position));
202         ActionManager::session_sensitive_actions.push_back (act);
203
204         act = ActionManager::register_action (editor_actions, "undo", _("Undo"), bind (mem_fun(*this, &Editor::undo), 1U));
205         ActionManager::session_sensitive_actions.push_back (act);
206         act = ActionManager::register_action (editor_actions, "redo", _("Redo"), bind (mem_fun(*this, &Editor::redo), 1U));
207         ActionManager::session_sensitive_actions.push_back (act);
208
209         act = ActionManager::register_action (editor_actions, "export-session", _("Export Session"), mem_fun(*this, &Editor::export_session));
210         ActionManager::session_sensitive_actions.push_back (act);
211         act = ActionManager::register_action (editor_actions, "export-range", _("Export Range"), mem_fun(*this, &Editor::export_selection));
212         ActionManager::session_sensitive_actions.push_back (act);
213
214         act = ActionManager::register_action (editor_actions, "editor-cut", _("Cut"), mem_fun(*this, &Editor::cut));
215         ActionManager::session_sensitive_actions.push_back (act);
216         /* Note: for now, editor-delete does the exact same thing as editor-cut */
217         act = ActionManager::register_action (editor_actions, "editor-delete", _("Delete"), mem_fun(*this, &Editor::cut));
218         ActionManager::session_sensitive_actions.push_back (act);
219         act = ActionManager::register_action (editor_actions, "editor-copy", _("Copy"), mem_fun(*this, &Editor::copy));
220         ActionManager::session_sensitive_actions.push_back (act);
221         act = ActionManager::register_action (editor_actions, "editor-paste", _("Paste"), mem_fun(*this, &Editor::keyboard_paste));
222         ActionManager::session_sensitive_actions.push_back (act);
223         act = ActionManager::register_action (editor_actions, "duplicate-region", _("Duplicate Region"), mem_fun(*this, &Editor::keyboard_duplicate_region));
224         ActionManager::session_sensitive_actions.push_back (act);
225         act = ActionManager::register_action (editor_actions, "duplicate-range", _("Duplicate Range"), mem_fun(*this, &Editor::keyboard_duplicate_selection));
226         ActionManager::session_sensitive_actions.push_back (act);
227         act = ActionManager::register_action (editor_actions, "insert-region", _("Insert Region"), mem_fun(*this, &Editor::keyboard_insert_region_list_selection));
228         ActionManager::session_sensitive_actions.push_back (act);
229         act = ActionManager::register_action (editor_actions, "reverse-region", _("Reverse Region"), mem_fun(*this, &Editor::reverse_region));
230         ActionManager::session_sensitive_actions.push_back (act);
231         act = ActionManager::register_action (editor_actions, "normalize-region", _("Normalize Region"), mem_fun(*this, &Editor::normalize_region));
232         ActionManager::session_sensitive_actions.push_back (act);
233         act = ActionManager::register_action (editor_actions, "crop", _("crop"), mem_fun(*this, &Editor::crop_region_to_selection));
234         ActionManager::session_sensitive_actions.push_back (act);
235         act = ActionManager::register_action (editor_actions, "insert-chunk", _("Insert Chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f));
236         ActionManager::session_sensitive_actions.push_back (act);
237
238         act = ActionManager::register_action (editor_actions, "split-at-edit-cursor", _("Split at edit cursor"), mem_fun(*this, &Editor::split_region));
239         ActionManager::edit_cursor_in_region_sensitive_actions.push_back (act);
240
241         act = ActionManager::register_action (editor_actions, "start-range", _("Start Range"), mem_fun(*this, &Editor::keyboard_selection_begin));
242         ActionManager::session_sensitive_actions.push_back (act);
243         act = ActionManager::register_action (editor_actions, "finish-range", _("Finish Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), false));
244         ActionManager::session_sensitive_actions.push_back (act);
245         act = ActionManager::register_action (editor_actions, "finish-add-range", _("Finish add Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), true));
246         ActionManager::session_sensitive_actions.push_back (act);
247
248         act = ActionManager::register_action (editor_actions, "extend-range-to-end-of-region", _("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false));
249         ActionManager::session_sensitive_actions.push_back (act);
250         act = ActionManager::register_action (editor_actions, "extend-range-to-start-of-region", _("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false));
251         ActionManager::session_sensitive_actions.push_back (act);
252
253         act = ActionManager::register_toggle_action (editor_actions, "toggle-follow-playhead", _("Follow Playhead"), (mem_fun(*this, &Editor::toggle_follow_playhead)));
254         ActionManager::session_sensitive_actions.push_back (act);
255         act = ActionManager::register_action (editor_actions, "remove-last-capture", _("Remove Last Capture"), (mem_fun(*this, &Editor::remove_last_capture)));
256         ActionManager::session_sensitive_actions.push_back (act);
257
258         Glib::RefPtr<ActionGroup> zoom_actions = ActionGroup::create (X_("Zoom"));
259         RadioAction::Group zoom_group;
260
261         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-left", _("Zoom Focus Left"), bind (mem_fun(*this, &Editor::set_zoom_focus), Editing::ZoomFocusLeft));
262         ActionManager::session_sensitive_actions.push_back (act);
263         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-right", _("Zoom Focus Right"), bind (mem_fun(*this, &Editor::set_zoom_focus), Editing::ZoomFocusRight));
264         ActionManager::session_sensitive_actions.push_back (act);
265         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-center", _("Zoom Focus Center"), bind (mem_fun(*this, &Editor::set_zoom_focus), Editing::ZoomFocusCenter));
266         ActionManager::session_sensitive_actions.push_back (act);
267         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-playhead", _("Zoom Focus Playhead"), bind (mem_fun(*this, &Editor::set_zoom_focus), Editing::ZoomFocusPlayhead));
268         ActionManager::session_sensitive_actions.push_back (act);
269         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-edit", _("Zoom Focus Edit"), bind (mem_fun(*this, &Editor::set_zoom_focus), Editing::ZoomFocusEdit));
270         ActionManager::session_sensitive_actions.push_back (act);
271
272         Glib::RefPtr<ActionGroup> mouse_mode_actions = ActionGroup::create (X_("MouseMode"));
273         RadioAction::Group mouse_mode_group;
274
275         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-object", _("Object Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseObject, false));
276         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-range", _("Range Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseRange, false));
277         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-gain", _("Gain Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseGain, false));
278         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-zoom", _("Zoom Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseZoom, false));
279         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-timefx", _("Timefx Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseTimeFX, false));
280
281         Glib::RefPtr<ActionGroup> snap_actions = ActionGroup::create (X_("Snap"));
282         RadioAction::Group snap_choice_group;
283
284         ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap To"));
285
286         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-frame"), _("Snap to frame"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToFrame)));
287         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-cd-frame"), _("Snap to cd frame"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToCDFrame)));
288         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-frame"), _("Snap to SMPTE frame"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToSMPTEFrame)));
289         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-seconds"), _("Snap to SMPTE seconds"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToSMPTESeconds)));
290         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-minutes"), _("Snap to SMPTE minutes"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToSMPTEMinutes)));
291         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-seconds"), _("Snap to seconds"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToSeconds)));
292         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-minutes"), _("Snap to minutes"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToMinutes)));
293         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirtyseconds"), _("Snap to thirtyseconds"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToAThirtysecondBeat)));
294         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-asixteenthbeat"), _("Snap to asixteenthbeat"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToASixteenthBeat)));
295         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-eighths"), _("Snap to eighths"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToAEighthBeat)));
296         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-quarters"), _("Snap to quarters"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToAQuarterBeat)));
297         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirds"), _("Snap to thirds"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToAThirdBeat)));
298         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-beat"), _("Snap to beat"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToBeat)));
299         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-bar"), _("Snap to bar"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToBar)));
300         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-mark"), _("Snap to mark"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToMark)));
301         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-edit-cursor"), _("Snap to edit cursor"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToEditCursor)));
302         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-start"), _("Snap to region start"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToRegionStart)));
303         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-end"), _("Snap to region end"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToRegionEnd)));
304         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-sync"), _("Snap to region sync"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToRegionSync)));
305         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-boundary"), _("Snap to region boundary"), (bind (mem_fun(*this, &Editor::set_snap_to), Editing::SnapToRegionBoundary)));
306
307         /* REGION LIST */
308
309         Glib::RefPtr<ActionGroup> rl_actions = ActionGroup::create (X_("RegionList"));
310         RadioAction::Group sort_type_group;
311         RadioAction::Group sort_order_group;
312
313         /* the region list popup menu */
314         ActionManager::register_action (rl_actions, X_("RegionListSort"), _("Sort"));
315
316         act = ActionManager::register_action (rl_actions, X_("rlAudition"), _("Audition"), mem_fun(*this, &Editor::audition_region_from_region_list));
317         ActionManager::region_list_selection_sensitive_actions.push_back (act);
318         act = ActionManager::register_action (rl_actions, X_("rlHide"), _("Hide"), mem_fun(*this, &Editor::hide_region_from_region_list));
319         ActionManager::region_list_selection_sensitive_actions.push_back (act);
320         act = ActionManager::register_action (rl_actions, X_("rlRemove"), _("Remove"), mem_fun (*this, &Editor::remove_region_from_region_list));
321         ActionManager::region_list_selection_sensitive_actions.push_back (act);
322         ActionManager::register_toggle_action (rl_actions, X_("rlShowAll"), _("Show all"), mem_fun(*this, &Editor::toggle_full_region_list));
323         ActionManager::register_toggle_action (rl_actions, X_("rlShowAuto"), _("Show automatic regions"), mem_fun(*this, &Editor::toggle_show_auto_regions));
324
325         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortAscending"),  _("Ascending"),
326                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), true));
327         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortDescending"),   _("Descending"),
328                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), false));
329         
330         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionName"),  _("By Region Name"),
331                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByName));
332         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionLength"),  _("By Region Length"),
333                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByLength));
334         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionPosition"),  _("By Region Position"),
335                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByPosition));
336         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionTimestamp"),  _("By Region Timestamp"),
337                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByTimestamp));
338         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionStartinFile"),  _("By Region Start in File"),
339                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByStartInFile));
340         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionEndinFile"),  _("By Region End in File"),
341                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByEndInFile));
342         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileName"),  _("By Source File Name"),
343                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileName));
344         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileLength"),  _("By Source File Length"),
345                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileLength));
346         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileCreationDate"),  _("By Source File Creation Date"),
347                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileCreationDate));
348         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFilesystem"),  _("By Source Filesystem"),
349                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileFS));
350
351
352         /* the next two are duplicate items with different names for use in two different contexts */
353
354         act = ActionManager::register_action (editor_actions, X_("addExternalAudioToRegionList"), _("Add External Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion));
355         ActionManager::session_sensitive_actions.push_back (act);
356         act = ActionManager::register_action (editor_actions, X_("addExternalAudioAsRegion"), _("as Region(s)"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion));
357         ActionManager::session_sensitive_actions.push_back (act);
358         act = ActionManager::register_action (editor_actions, X_("addExternalAudioAsTrack"), _("as Tracks"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsTrack));
359         ActionManager::session_sensitive_actions.push_back (act);
360         act = ActionManager::register_action (editor_actions, X_("addExternalAudioToTrack"), _("to Tracks"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportToTrack));
361         ActionManager::session_sensitive_actions.push_back (act);
362
363         ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformVisibility"), _("Show Waveforms"), mem_fun (*this, &Editor::toggle_waveform_visibility));
364         ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformsWhileRecording"), _("Show Waveforms While Recording"), mem_fun (*this, &Editor::toggle_waveforms_while_recording));
365         act = ActionManager::register_toggle_action (editor_actions, X_("ToggleMeasureVisibility"), _("Show Measures"), mem_fun (*this, &Editor::toggle_measure_visibility));
366         
367         RadioAction::Group meter_falloff_group;
368         RadioAction::Group meter_hold_group;
369
370         /*
371             Slowest = 6.6dB/sec falloff at update rate of 40ms
372             Slow    = 6.8dB/sec falloff at update rate of 40ms
373         */
374
375         ActionManager::register_radio_action (editor_actions, meter_falloff_group, X_("MeterFalloffOff"), _("Off"), bind (mem_fun (*this, &Editor::set_meter_falloff), 0));
376         ActionManager::register_radio_action (editor_actions, meter_falloff_group, X_("MeterFalloffSlowest"), _("Slowest"), bind (mem_fun (*this, &Editor::set_meter_falloff), 1)); 
377         ActionManager::register_radio_action (editor_actions, meter_falloff_group, X_("MeterFalloffSlow"), _("Slow"), bind (mem_fun (*this, &Editor::set_meter_falloff), 2));
378         ActionManager::register_radio_action (editor_actions, meter_falloff_group, X_("MeterFalloffMedium"), _("Medium"), bind (mem_fun (*this, &Editor::set_meter_falloff), 3));
379         ActionManager::register_radio_action (editor_actions, meter_falloff_group, X_("MeterFalloffFast"), _("Fast"), bind (mem_fun (*this, &Editor::set_meter_falloff), 4));
380         ActionManager::register_radio_action (editor_actions, meter_falloff_group, X_("MeterFalloffFaster"), _("Faster"), bind (mem_fun (*this, &Editor::set_meter_falloff), 5));
381         ActionManager::register_radio_action (editor_actions, meter_falloff_group, X_("MeterFalloffFastest"), _("Fastest"), bind (mem_fun (*this, &Editor::set_meter_falloff), 6));
382
383         ActionManager::register_radio_action (editor_actions, meter_hold_group,  X_("MeterHoldOff"), _("Off"), bind (mem_fun (*this, &Editor::set_meter_hold), 0));
384         ActionManager::register_radio_action (editor_actions, meter_hold_group,  X_("MeterHoldShort"), _("Short"), bind (mem_fun (*this, &Editor::set_meter_hold), 40));
385         ActionManager::register_radio_action (editor_actions, meter_hold_group,  X_("MeterHoldMedium"), _("Medium"), bind (mem_fun (*this, &Editor::set_meter_hold), 100));
386         ActionManager::register_radio_action (editor_actions, meter_hold_group,  X_("MeterHoldLong"), _("Long"), bind (mem_fun (*this, &Editor::set_meter_hold), 200));
387
388         RadioAction::Group layer_model_group;
389
390         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerLaterHigher"), _("Later is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), Session::LaterHigher));
391         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerMoveAddHigher"), _("Most Recently Moved/Added is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), Session::MoveAddHigher));
392         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerAddHigher"), _("Most Recently Added is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), Session::AddHigher));
393
394         ActionManager::add_action_group (rl_actions);
395         ActionManager::add_action_group (zoom_actions);
396         ActionManager::add_action_group (mouse_mode_actions);
397         ActionManager::add_action_group (snap_actions);
398         ActionManager::add_action_group (editor_actions);
399 }
400
401 void
402 Editor::toggle_waveform_visibility ()
403 {
404         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
405         if (act) {
406                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
407                 set_show_waveforms (tact->get_active());
408         }
409 }
410
411 void
412 Editor::toggle_waveforms_while_recording ()
413 {
414         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
415         if (act) {
416                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
417                 set_show_waveforms_recording (tact->get_active());
418         }
419 }
420
421 void
422 Editor::toggle_measure_visibility ()
423 {
424         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
425         if (act) {
426                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
427                 set_show_measures (tact->get_active());
428         }
429 }
430
431 void
432 Editor::toggle_auto_xfade ()
433 {
434         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-auto-xfades"));
435         if (act) {
436                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
437                 Config->set_auto_xfade (tact->get_active());
438         }
439 }
440
441 void
442 Editor::toggle_xfades_active ()
443 {
444         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-xfades-active"));
445         if (session && act) {
446                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
447                 session->set_crossfades_active (tact->get_active());
448         }
449 }
450
451 void
452 Editor::toggle_xfade_visibility ()
453 {
454         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-xfades-visible"));
455         if (session && act) {
456                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
457                 // set_xfade_visibility (tact->get_active());
458         }
459 }
460
461 void
462 Editor::set_layer_model (Session::LayerModel model)
463 {
464         /* this is driven by a toggle on a radio group, and so is invoked twice,
465            once for the item that became inactive and once for the one that became
466            active.
467         */
468
469         RefPtr<Action> act;
470
471         if (session) {
472                 switch (model) {
473                 case Session::LaterHigher:
474                         act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
475                         break;
476                 case Session::MoveAddHigher:
477                         act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
478                         break;
479                 case Session::AddHigher:
480                         act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
481                         break;
482                 }
483                 
484                 if (act) {
485                         RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
486                         if (ract && ract->get_active()) {
487                                 session->set_layer_model (model);
488                         }
489                 }
490         }
491 }
492
493 void
494 Editor::set_crossfade_model (CrossfadeModel model)
495 {
496         RefPtr<Action> act;
497
498         /* this is driven by a toggle on a radio group, and so is invoked twice,
499            once for the item that became inactive and once for the one that became
500            active.
501         */
502
503         if (session) {
504                 switch (model) {
505                 case FullCrossfade:
506                         act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
507                         break;
508                 case ShortCrossfade:
509                         act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
510                         break;
511                 }
512                 
513                 if (act) {
514                         RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
515                         if (ract && ract->get_active()) {
516                                 session->set_xfade_model (model);
517                         }
518                 }
519         }
520 }