merged with trunk revs 2605-2627
[ardour.git] / gtk2_ardour / editor_actions.cc
1 /*
2     Copyright (C) 2000-2007 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include <ardour/ardour.h>
21
22 #include "utils.h"
23 #include "editor.h"
24 #include "editing.h"
25 #include "actions.h"
26 #include "ardour_ui.h"
27 #include "gui_thread.h"
28 #include "i18n.h"
29
30 using namespace Gtk;
31 using namespace Glib;
32 using namespace std;
33 using namespace sigc;
34 using namespace ARDOUR;
35 using namespace PBD;
36 using namespace Editing;
37
38 void
39 Editor::register_actions ()
40 {
41         RefPtr<Action> act;
42
43         editor_actions = ActionGroup::create (X_("Editor"));
44         
45         /* non-operative menu items for menu bar */
46
47         ActionManager::register_action (editor_actions, X_("Edit"), _("Edit"));
48         ActionManager::register_action (editor_actions, X_("Select"), _("Select"));
49         ActionManager::register_action (editor_actions, X_("EditSelectRegionOptions"), _("Select Regions"));
50         ActionManager::register_action (editor_actions, X_("EditSelectRangeOptions"), _("Select Range Operations"));
51         ActionManager::register_action (editor_actions, X_("EditCursorMovementOptions"), _("Move Selected Marker"));
52         ActionManager::register_action (editor_actions, X_("RegionEditOps"), _("Region operations"));
53         ActionManager::register_action (editor_actions, X_("Tools"), _("Tools"));
54         ActionManager::register_action (editor_actions, X_("View"), _("View"));
55         ActionManager::register_action (editor_actions, X_("ZoomFocus"), _("Zoom Focus"));
56         ActionManager::register_action (editor_actions, X_("MeterHold"), _("Meter hold"));
57         ActionManager::register_action (editor_actions, X_("MeterFalloff"), _("Meter falloff"));
58         ActionManager::register_action (editor_actions, X_("Solo"), _("Solo"));
59         ActionManager::register_action (editor_actions, X_("Crossfades"), _("Crossfades"));
60         ActionManager::register_action (editor_actions, X_("Monitoring"), _("Monitoring"));
61         ActionManager::register_action (editor_actions, X_("Autoconnect"), _("Autoconnect"));
62         ActionManager::register_action (editor_actions, X_("Layering"), _("Layering"));
63         ActionManager::register_action (editor_actions, X_("Timecode"), _("Timecode fps"));
64         ActionManager::register_action (editor_actions, X_("Pullup"), _("Pullup / Pulldown"));
65         ActionManager::register_action (editor_actions, X_("Subframes"), _("Subframes"));
66
67
68         /* add named actions for the editor */
69
70         act = ActionManager::register_toggle_action (editor_actions, "show-editor-mixer", _("Show Editor Mixer"), mem_fun (*this, &Editor::editor_mixer_button_toggled));
71         ActionManager::session_sensitive_actions.push_back (act);
72         act = ActionManager::register_toggle_action (editor_actions, "show-editor-list", _("Show Editor List"), mem_fun (*this, &Editor::editor_list_button_toggled));
73         ActionManager::session_sensitive_actions.push_back (act);
74
75         RadioAction::Group crossfade_model_group;
76
77         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesFull", _("Span Entire Overlap"), bind (mem_fun(*this, &Editor::set_crossfade_model), FullCrossfade));
78         ActionManager::session_sensitive_actions.push_back (act);
79         act = ActionManager::register_radio_action (editor_actions, crossfade_model_group, "CrossfadesShort", _("Short"), bind (mem_fun(*this, &Editor::set_crossfade_model), ShortCrossfade));
80         ActionManager::session_sensitive_actions.push_back (act);
81
82         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-active", _("Active"), mem_fun(*this, &Editor::toggle_xfades_active));
83         ActionManager::session_sensitive_actions.push_back (act);
84         act = ActionManager::register_toggle_action (editor_actions, "toggle-xfades-visible", _("Show"), mem_fun(*this, &Editor::toggle_xfade_visibility));
85         ActionManager::session_sensitive_actions.push_back (act);
86         act = ActionManager::register_toggle_action (editor_actions, "toggle-auto-xfades", _("Created Automatically"), mem_fun(*this, &Editor::toggle_auto_xfade));
87         ActionManager::session_sensitive_actions.push_back (act);
88
89         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)));
90         ActionManager::session_sensitive_actions.push_back (act);
91         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)));
92         ActionManager::session_sensitive_actions.push_back (act);
93         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)));
94         ActionManager::session_sensitive_actions.push_back (act);
95
96         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)));
97         ActionManager::session_sensitive_actions.push_back (act);
98         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)));
99         ActionManager::session_sensitive_actions.push_back (act);
100         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)));
101         ActionManager::session_sensitive_actions.push_back (act);
102
103         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-start", _("Edit Cursor to Next Region Start"), bind (mem_fun(*this, &Editor::edit_point_to_next_region_point), RegionPoint (Start)));
104         ActionManager::session_sensitive_actions.push_back (act);
105         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-end", _("Edit Cursor to Next Region End"), bind (mem_fun(*this, &Editor::edit_point_to_next_region_point), RegionPoint (End)));
106         ActionManager::session_sensitive_actions.push_back (act);
107         act = ActionManager::register_action (editor_actions, "edit-cursor-to-next-region-sync", _("Edit Cursor to Next Region Sync"), bind (mem_fun(*this, &Editor::edit_point_to_next_region_point), RegionPoint (SyncPoint)));
108         ActionManager::session_sensitive_actions.push_back (act);
109
110         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-start", _("Edit Cursor to Previous Region Start"), bind (mem_fun(*this, &Editor::edit_point_to_previous_region_point), RegionPoint (Start)));
111         ActionManager::session_sensitive_actions.push_back (act);
112         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-end", _("Edit Cursor to Previous Region End"), bind (mem_fun(*this, &Editor::edit_point_to_previous_region_point), RegionPoint (End)));
113         ActionManager::session_sensitive_actions.push_back (act);
114         act = ActionManager::register_action (editor_actions, "edit-cursor-to-previous-region-sync", _("Edit Cursor to Previous Region Sync"), bind (mem_fun(*this, &Editor::edit_point_to_previous_region_point), RegionPoint (SyncPoint)));
115         ActionManager::session_sensitive_actions.push_back (act);
116
117         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-start", _("Edit Cursor to Range Start"), mem_fun(*this, &Editor::edit_point_to_selection_start));
118         ActionManager::session_sensitive_actions.push_back (act);
119         act = ActionManager::register_action (editor_actions, "edit-cursor-to-range-end", _("Edit Cursor to Range End"), mem_fun(*this, &Editor::edit_point_to_selection_end));
120         ActionManager::session_sensitive_actions.push_back (act);
121
122         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));
123         ActionManager::session_sensitive_actions.push_back (act);
124         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));
125         ActionManager::session_sensitive_actions.push_back (act);
126
127         act = ActionManager::register_action (editor_actions, "select-all", _("Select All"), bind (mem_fun(*this, &Editor::select_all), Selection::Set));
128         ActionManager::session_sensitive_actions.push_back (act);
129         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_edit), true));
130         ActionManager::session_sensitive_actions.push_back (act);
131         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_edit), false));
132         ActionManager::session_sensitive_actions.push_back (act);
133
134         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));
135         ActionManager::session_sensitive_actions.push_back (act);
136         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));
137         ActionManager::session_sensitive_actions.push_back (act);
138         act = ActionManager::register_action (editor_actions, "select-all-between-cursors", _("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), false));
139         ActionManager::session_sensitive_actions.push_back (act);
140         act = ActionManager::register_action (editor_actions, "select-all-within-cursors", _("Select All Between Playhead & Edit Point"), bind (mem_fun(*this, &Editor::select_all_selectables_between), true));
141         ActionManager::session_sensitive_actions.push_back (act);
142
143         act = ActionManager::register_action (editor_actions, "select-range-between-cursors", _("Select Range Between Playhead & Edit Point"), mem_fun(*this, &Editor::select_range_between));
144         ActionManager::session_sensitive_actions.push_back (act);
145
146         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));
147         ActionManager::session_sensitive_actions.push_back (act);
148         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));
149         ActionManager::session_sensitive_actions.push_back (act);
150
151         act = ActionManager::register_action (editor_actions, "jump-forward-to-mark", _("Jump Forward to Mark"), mem_fun(*this, &Editor::jump_forward_to_mark));
152         ActionManager::session_sensitive_actions.push_back (act);
153         act = ActionManager::register_action (editor_actions, "jump-backward-to-mark", _("Jump Backward to Mark"), mem_fun(*this, &Editor::jump_backward_to_mark));
154         ActionManager::session_sensitive_actions.push_back (act);
155         act = ActionManager::register_action (editor_actions, "add-location-from-playhead", _("Add Mark from Playhead"), mem_fun(*this, &Editor::add_location_from_playhead_cursor));
156         ActionManager::session_sensitive_actions.push_back (act);
157
158         act = ActionManager::register_action (editor_actions, "nudge-forward", _("Nudge Forward"), bind (mem_fun(*this, &Editor::nudge_forward), false));
159         ActionManager::session_sensitive_actions.push_back (act);
160         act = ActionManager::register_action (editor_actions, "nudge-next-forward", _("Nudge Next Forward"), bind (mem_fun(*this, &Editor::nudge_forward), true));
161         ActionManager::session_sensitive_actions.push_back (act);
162         act = ActionManager::register_action (editor_actions, "nudge-backward", _("Nudge Backward"), bind (mem_fun(*this, &Editor::nudge_backward), false));
163         ActionManager::session_sensitive_actions.push_back (act);
164         act = ActionManager::register_action (editor_actions, "nudge-next-backward", _("Nudge Next Backward"), bind (mem_fun(*this, &Editor::nudge_backward), true));
165         ActionManager::session_sensitive_actions.push_back (act);
166
167         act = ActionManager::register_action (editor_actions, "temporal-zoom-out", _("Zoom Out"), bind (mem_fun(*this, &Editor::temporal_zoom_step), true));
168         ActionManager::session_sensitive_actions.push_back (act);
169         act = ActionManager::register_action (editor_actions, "temporal-zoom-in", _("Zoom In"), bind (mem_fun(*this, &Editor::temporal_zoom_step), false));
170         ActionManager::session_sensitive_actions.push_back (act);
171         act = ActionManager::register_action (editor_actions, "zoom-to-session", _("Zoom to Session"), mem_fun(*this, &Editor::temporal_zoom_session));
172         ActionManager::session_sensitive_actions.push_back (act);
173
174         act = ActionManager::register_action (editor_actions, "scroll-tracks-up", _("Scroll Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up));
175         ActionManager::session_sensitive_actions.push_back (act);
176         act = ActionManager::register_action (editor_actions, "scroll-tracks-down", _("Scroll Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down));
177         ActionManager::session_sensitive_actions.push_back (act);
178         act = ActionManager::register_action (editor_actions, "step-tracks-up", _("Step Tracks Up"), mem_fun(*this, &Editor::scroll_tracks_up_line));
179         ActionManager::session_sensitive_actions.push_back (act);
180         act = ActionManager::register_action (editor_actions, "step-tracks-down", _("Step Tracks Down"), mem_fun(*this, &Editor::scroll_tracks_down_line));
181         ActionManager::session_sensitive_actions.push_back (act);
182
183         act = ActionManager::register_action (editor_actions, "scroll-backward", _("Scroll Backward"), bind (mem_fun(*this, &Editor::scroll_backward), 0.8f));
184         ActionManager::session_sensitive_actions.push_back (act);
185         act = ActionManager::register_action (editor_actions, "scroll-forward", _("Scroll Forward"), bind (mem_fun(*this, &Editor::scroll_forward), 0.8f));
186         ActionManager::session_sensitive_actions.push_back (act);
187         act = ActionManager::register_action (editor_actions, "goto", _("goto"), mem_fun(*this, &Editor::goto_frame));
188         ActionManager::session_sensitive_actions.push_back (act);
189         act = ActionManager::register_action (editor_actions, "center-playhead", _("Center Playhead"), mem_fun(*this, &Editor::center_playhead));
190         ActionManager::session_sensitive_actions.push_back (act);
191         act = ActionManager::register_action (editor_actions, "center-edit-cursor", _("Center Edit Point"), mem_fun(*this, &Editor::center_edit_point));
192         ActionManager::session_sensitive_actions.push_back (act);
193
194         act = ActionManager::register_action (editor_actions, "scroll-playhead-forward", _("Playhead forward"), bind (mem_fun(*this, &Editor::scroll_playhead), true));;
195         ActionManager::session_sensitive_actions.push_back (act);
196         act = ActionManager::register_action (editor_actions, "scroll-playhead-backward", _("Playhead Backward"), bind (mem_fun(*this, &Editor::scroll_playhead), false));
197         ActionManager::session_sensitive_actions.push_back (act);
198
199         act = ActionManager::register_action (editor_actions, "playhead-to-edit", _("Playhead to Edit"), bind (mem_fun(*this, &Editor::cursor_align), true));
200         ActionManager::session_sensitive_actions.push_back (act);
201         act = ActionManager::register_action (editor_actions, "edit-to-playhead", _("Edit to Playhead"), bind (mem_fun(*this, &Editor::cursor_align), false));
202         ActionManager::session_sensitive_actions.push_back (act);
203
204
205         act = ActionManager::register_action (editor_actions, "trim-from-start", _("Start to edit point"), mem_fun(*this, &Editor::trim_region_from_edit_point));
206         ActionManager::session_sensitive_actions.push_back (act);
207         act = ActionManager::register_action (editor_actions, "trim-to-end", _("Edit point to end"), mem_fun(*this, &Editor::trim_region_to_edit_point));
208         ActionManager::session_sensitive_actions.push_back (act);
209         act = ActionManager::register_action (editor_actions, "trim-region-to-loop", _("Trim To Loop"), mem_fun(*this, &Editor::trim_region_to_loop));
210         ActionManager::session_sensitive_actions.push_back (act);
211         act = ActionManager::register_action (editor_actions, "trim-region-to-punch", _("Trim To Punch"), mem_fun(*this, &Editor::trim_region_to_punch));
212         ActionManager::session_sensitive_actions.push_back (act);
213         
214         act = ActionManager::register_action (editor_actions, "set-fade-in-length", _("Set Fade In Length"), bind (mem_fun(*this, &Editor::set_fade_length), true));
215         ActionManager::session_sensitive_actions.push_back (act);
216         act = ActionManager::register_action (editor_actions, "set-fade-out-length", _("Set Fade Out Length"), bind (mem_fun(*this, &Editor::set_fade_length), false));
217         ActionManager::session_sensitive_actions.push_back (act);
218
219         act = ActionManager::register_action (editor_actions, "align-regions-start", _("Align Regions Start"), bind (mem_fun(*this, &Editor::align), ARDOUR::Start));
220         ActionManager::session_sensitive_actions.push_back (act);
221         act = ActionManager::register_action (editor_actions, "align-regions-start-relative", _("Align Regions Start Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::Start));
222         ActionManager::session_sensitive_actions.push_back (act);
223         act = ActionManager::register_action (editor_actions, "align-regions-end", _("Align Regions End"), bind (mem_fun(*this, &Editor::align), ARDOUR::End));
224         ActionManager::session_sensitive_actions.push_back (act);
225         act = ActionManager::register_action (editor_actions, "align-regions-end-relative", _("Align Regions End Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::End));
226         ActionManager::session_sensitive_actions.push_back (act);
227
228         act = ActionManager::register_action (editor_actions, "align-regions-sync", _("Align Regions Sync"), bind (mem_fun(*this, &Editor::align), ARDOUR::SyncPoint));
229         ActionManager::session_sensitive_actions.push_back (act);
230         act = ActionManager::register_action (editor_actions, "align-regions-sync-relative", _("Align Regions Sync Relative"), bind (mem_fun(*this, &Editor::align_relative), ARDOUR::SyncPoint));
231         ActionManager::session_sensitive_actions.push_back (act);
232         
233         act = ActionManager::register_action (editor_actions, "audition-at-mouse", _("Audition at Mouse"), mem_fun(*this, &Editor::kbd_audition));
234         ActionManager::session_sensitive_actions.push_back (act);
235         act = ActionManager::register_action (editor_actions, "brush-at-mouse", _("Brush at Mouse"), mem_fun(*this, &Editor::kbd_brush));
236         ActionManager::session_sensitive_actions.push_back (act);
237         act = ActionManager::register_action (editor_actions, "mute-unmute-region", _("Mute/Unmute Region"), mem_fun(*this, &Editor::kbd_mute_unmute_region));
238         ActionManager::session_sensitive_actions.push_back (act);
239         act = ActionManager::register_action (editor_actions, "set-region-sync-position", _("Set Region Sync Position"), mem_fun(*this, &Editor::kbd_set_sync_position));
240         ActionManager::session_sensitive_actions.push_back (act);
241
242         act = ActionManager::register_action (editor_actions, "set-playhead", _("Set Playhead"), mem_fun(*this, &Editor::set_playhead_cursor));
243         ActionManager::session_sensitive_actions.push_back (act);
244         act = ActionManager::register_action (editor_actions, "set-edit-point", _("Set Edit Point"), mem_fun(*this, &Editor::set_edit_point));
245         ActionManager::session_sensitive_actions.push_back (act);
246         act = ActionManager::register_action (editor_actions, "split-region", _("Split Region"), mem_fun(*this, &Editor::split));
247         ActionManager::session_sensitive_actions.push_back (act);
248
249         undo_action = act = ActionManager::register_action (editor_actions, "undo", _("Undo"), bind (mem_fun(*this, &Editor::undo), 1U));
250         ActionManager::session_sensitive_actions.push_back (act);
251         redo_action = act = ActionManager::register_action (editor_actions, "redo", _("Redo"), bind (mem_fun(*this, &Editor::redo), 1U));
252         ActionManager::session_sensitive_actions.push_back (act);
253
254         act = ActionManager::register_action (editor_actions, "export-session", _("Export Session"), mem_fun(*this, &Editor::export_session));
255         ActionManager::session_sensitive_actions.push_back (act);
256         act = ActionManager::register_action (editor_actions, "export-range", _("Export Range"), mem_fun(*this, &Editor::export_selection));
257         ActionManager::session_sensitive_actions.push_back (act);
258
259         act = ActionManager::register_action (editor_actions, "editor-cut", _("Cut"), mem_fun(*this, &Editor::cut));
260         ActionManager::session_sensitive_actions.push_back (act);
261         /* Note: for now, editor-delete does the exact same thing as editor-cut */
262         act = ActionManager::register_action (editor_actions, "editor-delete", _("Delete"), mem_fun(*this, &Editor::cut));
263         ActionManager::session_sensitive_actions.push_back (act);
264         act = ActionManager::register_action (editor_actions, "editor-copy", _("Copy"), mem_fun(*this, &Editor::copy));
265         ActionManager::session_sensitive_actions.push_back (act);
266         act = ActionManager::register_action (editor_actions, "editor-paste", _("Paste"), mem_fun(*this, &Editor::keyboard_paste));
267         ActionManager::session_sensitive_actions.push_back (act);
268         act = ActionManager::register_action (editor_actions, "duplicate-region", _("Duplicate Region"), mem_fun(*this, &Editor::keyboard_duplicate_region));
269         ActionManager::session_sensitive_actions.push_back (act);
270         act = ActionManager::register_action (editor_actions, "duplicate-range", _("Duplicate Range"), mem_fun(*this, &Editor::keyboard_duplicate_selection));
271         ActionManager::session_sensitive_actions.push_back (act);
272         act = ActionManager::register_action (editor_actions, "insert-region", _("Insert Region"), mem_fun(*this, &Editor::keyboard_insert_region_list_selection));
273         ActionManager::session_sensitive_actions.push_back (act);
274         act = ActionManager::register_action (editor_actions, "reverse-region", _("Reverse Regions"), mem_fun(*this, &Editor::reverse_regions));
275         ActionManager::session_sensitive_actions.push_back (act);
276         act = ActionManager::register_action (editor_actions, "normalize-region", _("Normalize Regions"), mem_fun(*this, &Editor::normalize_regions));
277         ActionManager::session_sensitive_actions.push_back (act);
278         act = ActionManager::register_action (editor_actions, "quantize-region", _("Quantize Regions"), mem_fun(*this, &Editor::quantize_regions));
279         ActionManager::session_sensitive_actions.push_back (act);
280         act = ActionManager::register_action (editor_actions, "crop", _("Crop"), mem_fun(*this, &Editor::crop_region_to_selection));
281         ActionManager::session_sensitive_actions.push_back (act);
282         act = ActionManager::register_action (editor_actions, "insert-chunk", _("Insert Chunk"), bind (mem_fun(*this, &Editor::paste_named_selection), 1.0f));
283         ActionManager::session_sensitive_actions.push_back (act);
284
285         act = ActionManager::register_action (editor_actions, "split-at-edit-cursor", _("Split At Edit Point"), mem_fun(*this, &Editor::split_region));
286         ActionManager::edit_point_in_region_sensitive_actions.push_back (act);
287
288         act = ActionManager::register_action (editor_actions, "start-range", _("Start Range"), mem_fun(*this, &Editor::keyboard_selection_begin));
289         ActionManager::session_sensitive_actions.push_back (act);
290         act = ActionManager::register_action (editor_actions, "finish-range", _("Finish Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), false));
291         ActionManager::session_sensitive_actions.push_back (act);
292         act = ActionManager::register_action (editor_actions, "finish-add-range", _("Finish add Range"), bind (mem_fun(*this, &Editor::keyboard_selection_finish), true));
293         ActionManager::session_sensitive_actions.push_back (act);
294
295         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));
296         ActionManager::session_sensitive_actions.push_back (act);
297         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));
298         ActionManager::session_sensitive_actions.push_back (act);
299
300         act = ActionManager::register_toggle_action (editor_actions, "toggle-follow-playhead", _("Follow Playhead"), (mem_fun(*this, &Editor::toggle_follow_playhead)));
301         ActionManager::session_sensitive_actions.push_back (act);
302         act = ActionManager::register_action (editor_actions, "remove-last-capture", _("Remove Last Capture"), (mem_fun(*this, &Editor::remove_last_capture)));
303         ActionManager::session_sensitive_actions.push_back (act);
304
305         Glib::RefPtr<ActionGroup> zoom_actions = ActionGroup::create (X_("Zoom"));
306         RadioAction::Group zoom_group;
307
308         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-left", _("Zoom Focus Left"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusLeft));
309         ActionManager::session_sensitive_actions.push_back (act);
310         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-right", _("Zoom Focus Right"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusRight));
311         ActionManager::session_sensitive_actions.push_back (act);
312         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-center", _("Zoom Focus Center"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusCenter));
313         ActionManager::session_sensitive_actions.push_back (act);
314         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-playhead", _("Zoom Focus Playhead"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusPlayhead));
315         ActionManager::session_sensitive_actions.push_back (act);
316         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-mouse", _("Zoom Focus Mouse"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusMouse));
317         ActionManager::session_sensitive_actions.push_back (act);
318         ActionManager::register_radio_action (zoom_actions, zoom_group, "zoom-focus-edit", _("Zoom Focus Edit"), bind (mem_fun(*this, &Editor::zoom_focus_chosen), Editing::ZoomFocusEdit));
319         ActionManager::session_sensitive_actions.push_back (act);
320
321         Glib::RefPtr<ActionGroup> mouse_mode_actions = ActionGroup::create (X_("MouseMode"));
322         RadioAction::Group mouse_mode_group;
323
324         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));
325         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));
326         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));
327         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));
328         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));
329         ActionManager::register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-note", _("Note Tool"), bind (mem_fun(*this, &Editor::set_mouse_mode), Editing::MouseNote, false));
330
331         RadioAction::Group edit_point_group;
332         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-playhead"), _("Playhead"), (bind (mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
333         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-mouse"), _("Mouse"), (bind (mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
334         ActionManager::register_radio_action (editor_actions, edit_point_group, X_("edit-at-selected-marker"), _("Marker"), (bind (mem_fun(*this, &Editor::edit_point_chosen), Editing::EditAtPlayhead)));
335
336         ActionManager::register_action (editor_actions, X_("SnapTo"), _("Snap To"));
337         ActionManager::register_action (editor_actions, X_("SnapMode"), _("Snap Mode"));
338
339         RadioAction::Group snap_mode_group;
340         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-normal"), _("Normal"), (bind (mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapNormal)));
341         ActionManager::register_radio_action (editor_actions, snap_mode_group, X_("snap-magnetic"), _("Magnetic"), (bind (mem_fun(*this, &Editor::snap_mode_chosen), Editing::SnapMagnetic)));
342
343         Glib::RefPtr<ActionGroup> snap_actions = ActionGroup::create (X_("Snap"));
344         RadioAction::Group snap_choice_group;
345
346         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-frame"), _("Snap to frame"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToFrame)));
347         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-cd-frame"), _("Snap to cd frame"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToCDFrame)));
348         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-frame"), _("Snap to SMPTE frame"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSMPTEFrame)));
349         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-seconds"), _("Snap to SMPTE seconds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSMPTESeconds)));
350         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-smpte-minutes"), _("Snap to SMPTE minutes"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSMPTEMinutes)));
351         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-seconds"), _("Snap to seconds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToSeconds)));
352         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-minutes"), _("Snap to minutes"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToMinutes)));
353         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirtyseconds"), _("Snap to thirtyseconds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAThirtysecondBeat)));
354         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-asixteenthbeat"), _("Snap to asixteenthbeat"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToASixteenthBeat)));
355         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-eighths"), _("Snap to eighths"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAEighthBeat)));
356         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-quarters"), _("Snap to quarters"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAQuarterBeat)));
357         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-thirds"), _("Snap to thirds"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToAThirdBeat)));
358         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-beat"), _("Snap to beat"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBeat)));
359         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-bar"), _("Snap to bar"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToBar)));
360         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-mark"), _("Snap to mark"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToMark)));
361         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-edit-cursor"), _("Snap to edit point"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToEditPoint)));
362         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-start"), _("Snap to region start"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionStart)));
363         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-end"), _("Snap to region end"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionEnd)));
364         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-sync"), _("Snap to region sync"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionSync)));
365         ActionManager::register_radio_action (snap_actions, snap_choice_group, X_("snap-to-region-boundary"), _("Snap to region boundary"), (bind (mem_fun(*this, &Editor::snap_type_chosen), Editing::SnapToRegionBoundary)));
366
367         /* REGION LIST */
368
369         Glib::RefPtr<ActionGroup> rl_actions = ActionGroup::create (X_("RegionList"));
370         RadioAction::Group sort_type_group;
371         RadioAction::Group sort_order_group;
372
373         /* the region list popup menu */
374         ActionManager::register_action (rl_actions, X_("RegionListSort"), _("Sort"));
375
376         act = ActionManager::register_action (rl_actions, X_("rlAudition"), _("Audition"), mem_fun(*this, &Editor::audition_region_from_region_list));
377         ActionManager::region_list_selection_sensitive_actions.push_back (act);
378         act = ActionManager::register_action (rl_actions, X_("rlHide"), _("Hide"), mem_fun(*this, &Editor::hide_region_from_region_list));
379         ActionManager::region_list_selection_sensitive_actions.push_back (act);
380         act = ActionManager::register_action (rl_actions, X_("rlRemove"), _("Remove"), mem_fun (*this, &Editor::remove_region_from_region_list));
381         ActionManager::region_list_selection_sensitive_actions.push_back (act);
382         ActionManager::register_toggle_action (rl_actions, X_("rlShowAll"), _("Show all"), mem_fun(*this, &Editor::toggle_full_region_list));
383         ActionManager::register_toggle_action (rl_actions, X_("rlShowAuto"), _("Show automatic regions"), mem_fun(*this, &Editor::toggle_show_auto_regions));
384
385         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortAscending"),  _("Ascending"),
386                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), true));
387         ActionManager::register_radio_action (rl_actions, sort_order_group, X_("SortDescending"),   _("Descending"),
388                                bind (mem_fun(*this, &Editor::reset_region_list_sort_direction), false));
389         
390         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionName"),  _("By Region Name"),
391                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByName));
392         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionLength"),  _("By Region Length"),
393                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByLength));
394         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionPosition"),  _("By Region Position"),
395                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByPosition));
396         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionTimestamp"),  _("By Region Timestamp"),
397                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByTimestamp));
398         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionStartinFile"),  _("By Region Start in File"),
399                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByStartInFile));
400         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortByRegionEndinFile"),  _("By Region End in File"),
401                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), ByEndInFile));
402         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileName"),  _("By Source File Name"),
403                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileName));
404         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileLength"),  _("By Source File Length"),
405                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileLength));
406         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFileCreationDate"),  _("By Source File Creation Date"),
407                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileCreationDate));
408         ActionManager::register_radio_action (rl_actions, sort_type_group, X_("SortBySourceFilesystem"),  _("By Source Filesystem"),
409                                bind (mem_fun(*this, &Editor::reset_region_list_sort_type), BySourceFileFS));
410
411
412         /* the next two are duplicate items with different names for use in two different contexts */
413
414         ActionManager::register_action (editor_actions, X_("addExistingAudioFiles"), _("Add Existing Audio"), mem_fun (*this, &Editor::external_audio_dialog));
415
416         act = ActionManager::register_action (editor_actions, X_("addExternalAudioToRegionList"), _("Add External Audio"), bind (mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion));
417         ActionManager::session_sensitive_actions.push_back (act);
418
419         ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformVisibility"), _("Show Waveforms"), mem_fun (*this, &Editor::toggle_waveform_visibility));
420         ActionManager::register_toggle_action (editor_actions, X_("ToggleWaveformsWhileRecording"), _("Show Waveforms While Recording"), mem_fun (*this, &Editor::toggle_waveforms_while_recording));
421         act = ActionManager::register_toggle_action (editor_actions, X_("ToggleMeasureVisibility"), _("Show Measures"), mem_fun (*this, &Editor::toggle_measure_visibility));
422         
423         /* if there is a logo in the editor canvas, its always visible at startup */
424
425         act = ActionManager::register_toggle_action (editor_actions, X_("ToggleLogoVisibility"), _("Show Logo"), mem_fun (*this, &Editor::toggle_logo_visibility));
426         Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
427         tact->set_active (true);
428
429         RadioAction::Group layer_model_group;
430
431         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerLaterHigher"), _("Later is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), LaterHigher));
432         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerMoveAddHigher"), _("Most Recently Moved/Added is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), MoveAddHigher));
433         ActionManager::register_radio_action (editor_actions, layer_model_group,  X_("LayerAddHigher"), _("Most Recently Added is Higher"), bind (mem_fun (*this, &Editor::set_layer_model), AddHigher));
434
435         RadioAction::Group smpte_group;
436
437         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte23976"), _("23.976"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_23976));
438         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte24"), _("24"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_24));
439         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte24976"), _("24.976"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_24976));
440         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte25"), _("25"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_25));
441         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte2997"), _("29.97"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_2997));
442         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte2997drop"), _("29.97 drop"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_2997drop));
443         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte30"), _("30"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_30));
444         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte30drop"), _("30 drop"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_30drop));
445         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte5994"), _("59.94"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_5994));
446         ActionManager::register_radio_action (editor_actions, smpte_group,  X_("Smpte60"), _("60"), bind (mem_fun (*this, &Editor::smpte_fps_chosen), smpte_60));
447
448         RadioAction::Group pullup_group;
449
450         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4Plus1"), _("+4.1667% + 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4Plus1));
451         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4"), _("+4.1667%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4));
452         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus4Minus1"), _("+4.1667% - 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus4Minus1));
453         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupPlus1"), _("+ 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Plus1));
454         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupNone"), _("None"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_None));
455         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus1"), _("- 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus1));
456         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4Plus1"), _("-4.1667% + 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4Plus1));
457         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4"), _("-4.1667%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4));
458         ActionManager::register_radio_action (editor_actions, pullup_group,  X_("PullupMinus4Minus1"), _("-4.1667% - 0.1%"), bind (mem_fun (*this, &Editor::video_pullup_chosen), Session::pullup_Minus4Minus1));
459
460         RadioAction::Group subframe_group;
461
462         ActionManager::register_radio_action (editor_actions, subframe_group,  X_("Subframes80"), _("80 per frame"), bind (mem_fun (*this, 
463 &Editor::subframes_per_frame_chosen), 80));
464         ActionManager::register_radio_action (editor_actions, subframe_group,  X_("Subframes100"), _("100 per frame"), bind (mem_fun (*this, 
465 &Editor::subframes_per_frame_chosen), 100));
466
467         ActionManager::add_action_group (rl_actions);
468         ActionManager::add_action_group (zoom_actions);
469         ActionManager::add_action_group (mouse_mode_actions);
470         ActionManager::add_action_group (snap_actions);
471         ActionManager::add_action_group (editor_actions);
472 }
473
474 void
475 Editor::toggle_waveform_visibility ()
476 {
477         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformVisibility"));
478         if (act) {
479                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
480                 set_show_waveforms (tact->get_active());
481         }
482 }
483
484 void
485 Editor::toggle_waveforms_while_recording ()
486 {
487         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleWaveformsWhileRecording"));
488         if (act) {
489                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
490                 set_show_waveforms_recording (tact->get_active());
491         }
492 }
493
494 void
495 Editor::toggle_measure_visibility ()
496 {
497         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleMeasureVisibility"));
498         if (act) {
499                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
500                 set_show_measures (tact->get_active());
501         }
502 }
503
504 void
505 Editor::toggle_logo_visibility ()
506 {
507         Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleLogoVisibility"));
508
509         if (act) {
510                 Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
511                 if (logo_item) {
512                         if (tact->get_active()) {
513                                 logo_item->show ();
514                         } else {
515                                 logo_item->hide ();
516                         }
517                 }
518         }
519 }
520
521 void
522 Editor::set_crossfade_model (CrossfadeModel model)
523 {
524         RefPtr<Action> act;
525
526         /* this is driven by a toggle on a radio group, and so is invoked twice,
527            once for the item that became inactive and once for the one that became
528            active.
529         */
530
531         switch (model) {
532         case FullCrossfade:
533                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
534                 break;
535         case ShortCrossfade:
536                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
537                 break;
538         }
539         
540         if (act) {
541                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
542                 if (ract && ract->get_active()) {
543                         Config->set_xfade_model (model);
544                 }
545         }
546 }
547
548 void
549 Editor::update_crossfade_model ()
550 {
551         RefPtr<Action> act;
552
553         switch (Config->get_xfade_model()) {
554         case FullCrossfade:
555                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesFull"));
556                 break;
557         case ShortCrossfade:
558                 act = ActionManager::get_action (X_("Editor"), X_("CrossfadesShort"));
559                 break;
560         }
561
562         if (act) {
563                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
564                 if (ract && !ract->get_active()) {
565                         ract->set_active (true);
566                 }
567         }
568 }
569
570 void
571 Editor::update_smpte_mode ()
572 {
573         ENSURE_GUI_THREAD(mem_fun(*this, &Editor::update_smpte_mode));
574
575         RefPtr<Action> act;
576         const char* action = 0;
577
578         switch (Config->get_smpte_format()) {
579         case smpte_23976:
580                 action = X_("Smpte23976");
581                 break;
582         case smpte_24:
583                 action = X_("Smpte24");
584                 break;
585         case smpte_24976:
586                 action = X_("Smpte24976");
587                 break;
588         case smpte_25:
589                 action = X_("Smpte25");
590                 break;
591         case smpte_2997:
592                 action = X_("Smpte2997");
593                 break;
594         case smpte_2997drop:
595                 action = X_("Smpte2997drop");
596                 break;
597         case smpte_30:
598                 action = X_("Smpte30");
599                 break;
600         case smpte_30drop:
601                 action = X_("Smpte30drop");
602                 break;
603         case smpte_5994:
604                 action = X_("Smpte5994");
605                 break;
606         case smpte_60:
607                 action = X_("Smpte60");
608                 break;
609         }
610
611         act = ActionManager::get_action (X_("Editor"), action);
612
613         if (act) {
614                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
615                 if (ract && !ract->get_active()) {
616                         ract->set_active (true);
617                 }
618         }
619 }
620
621 void
622 Editor::update_video_pullup ()
623 {
624         ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_video_pullup));
625
626         RefPtr<Action> act;
627         const char* action = 0;
628
629         float pullup = Config->get_video_pullup();
630
631         if ( pullup < (-4.1667 - 0.1) * 0.99) {
632                 action = X_("PullupMinus4Minus1");
633         } else if ( pullup < (-4.1667) * 0.99 ) {
634                 action = X_("PullupMinus4");
635         } else if ( pullup < (-4.1667 + 0.1) * 0.99 ) {
636                 action = X_("PullupMinus4Plus1");
637         } else if ( pullup < (-0.1) * 0.99 ) {
638                 action = X_("PullupMinus1");
639         } else if (pullup > (4.1667 + 0.1) * 0.99 ) {
640                 action = X_("PullupPlus4Plus1");
641         } else if ( pullup > (4.1667) * 0.99 ) {
642                 action = X_("PullupPlus4");
643         } else if ( pullup > (4.1667 - 0.1) * 0.99) {
644                 action = X_("PullupPlus4Minus1");
645         } else if ( pullup > (0.1) * 0.99 ) {
646                 action = X_("PullupPlus1");
647         } else {
648                 action = X_("PullupNone");
649         }
650
651         act = ActionManager::get_action (X_("Editor"), action);
652
653         if (act) {
654                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
655                 if (ract && !ract->get_active()) {
656                         ract->set_active (true);
657                 }
658         }
659 }
660
661 void
662 Editor::update_layering_model ()
663 {
664         RefPtr<Action> act;
665
666         switch (Config->get_layer_model()) {
667         case LaterHigher:
668                 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
669                 break;
670         case MoveAddHigher:
671                 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
672                 break;
673         case AddHigher:
674                 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
675                 break;
676         }
677
678         if (act) {
679                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
680                 if (ract && !ract->get_active()) {
681                         ract->set_active (true);
682                 }
683         }
684 }
685
686 void
687 Editor::set_layer_model (LayerModel model)
688 {
689         /* this is driven by a toggle on a radio group, and so is invoked twice,
690            once for the item that became inactive and once for the one that became
691            active.
692         */
693
694         RefPtr<Action> act;
695
696         switch (model) {
697         case LaterHigher:
698                 act = ActionManager::get_action (X_("Editor"), X_("LayerLaterHigher"));
699                 break;
700         case MoveAddHigher:
701                 act = ActionManager::get_action (X_("Editor"), X_("LayerMoveAddHigher"));
702                 break;
703         case AddHigher:
704                 act = ActionManager::get_action (X_("Editor"), X_("LayerAddHigher"));
705                 break;
706         }
707         
708         if (act) {
709                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
710                 if (ract && ract->get_active() && Config->get_layer_model() != model) {
711                         Config->set_layer_model (model);
712                 }
713         }
714 }
715
716 RefPtr<RadioAction>
717 Editor::snap_type_action (SnapType type)
718 {
719
720         const char* action = 0;
721         RefPtr<Action> act;
722         
723         switch (type) {
724         case Editing::SnapToFrame:
725                 action = "snap-to-frame";
726                 break;
727         case Editing::SnapToCDFrame:
728                 action = "snap-to-cd-frame";
729                 break;
730         case Editing::SnapToSMPTEFrame:
731                 action = "snap-to-smpte-frame";
732                 break;
733         case Editing::SnapToSMPTESeconds:
734                 action = "snap-to-smpte-seconds";
735                 break;
736         case Editing::SnapToSMPTEMinutes:
737                 action = "snap-to-smpte-minutes";
738                 break;
739         case Editing::SnapToSeconds:
740                 action = "snap-to-seconds";
741                 break;
742         case Editing::SnapToMinutes:
743                 action = "snap-to-minutes";
744                 break;
745         case Editing::SnapToAThirtysecondBeat:
746                 action = "snap-to-thirtyseconds";
747                 break;
748         case Editing::SnapToASixteenthBeat:
749                 action = "snap-to-asixteenthbeat";
750                 break;
751         case Editing::SnapToAEighthBeat:
752                 action = "snap-to-eighths";
753                 break;
754         case Editing::SnapToAQuarterBeat:
755                 action = "snap-to-quarters";
756                 break;
757         case Editing::SnapToAThirdBeat:
758                 action = "snap-to-thirds";
759                 break;
760         case Editing::SnapToBeat:
761                 action = "snap-to-beat";
762                 break;
763         case Editing::SnapToBar:
764                 action = "snap-to-bar";
765                 break;
766         case Editing::SnapToMark:
767                 action = "snap-to-mark";
768                 break;
769         case Editing::SnapToEditPoint:
770                 action = "snap-to-edit-cursor";
771                 break;
772         case Editing::SnapToRegionStart:
773                 action = "snap-to-region-start";
774                 break;
775         case Editing::SnapToRegionEnd:
776                 action = "snap-to-region-end";
777                 break;
778         case Editing::SnapToRegionSync:
779                 action = "snap-to-region-sync";
780                 break;
781         case Editing::SnapToRegionBoundary:
782                 action = "snap-to-region-boundary";
783                 break;
784         default:
785                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap-to type", (int) type) << endmsg;
786                 /*NOTREACHED*/
787         }
788
789         act = ActionManager::get_action (X_("Snap"), action);
790
791         if (act) {
792                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
793                 return ract;
794
795         } else  {
796                 error << string_compose (_("programming error: %1"), "Editor::snap_type_chosen could not find action to match type.") << endmsg;
797                 return RefPtr<RadioAction>();
798         }
799 }
800
801 void
802 Editor::snap_type_chosen (SnapType type)
803 {
804         /* this is driven by a toggle on a radio group, and so is invoked twice,
805            once for the item that became inactive and once for the one that became
806            active.
807         */
808
809         RefPtr<RadioAction> ract = snap_type_action (type);
810
811         if (ract && ract->get_active()) {
812                 set_snap_to (type);
813         }
814 }
815
816 RefPtr<RadioAction>
817 Editor::snap_mode_action (SnapMode mode)
818 {
819         const char* action = 0;
820         RefPtr<Action> act;
821         
822         switch (mode) {
823         case Editing::SnapNormal:
824                 action = X_("snap-normal");
825                 break;
826         case Editing::SnapMagnetic:
827                 action = X_("snap-magnetic");
828                 break;
829         default:
830                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible snap mode type", (int) mode) << endmsg;
831                 /*NOTREACHED*/
832         }
833         
834         act = ActionManager::get_action (X_("Editor"), action);
835         
836         if (act) {
837                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
838                 return ract;
839                 
840         } else  {
841                 error << string_compose (_("programming error: %1: %2"), "Editor::snap_mode_chosen could not find action to match mode.", action) << endmsg;
842                 return RefPtr<RadioAction> ();
843         }
844 }
845
846 void
847 Editor::snap_mode_chosen (SnapMode mode)
848 {
849         /* this is driven by a toggle on a radio group, and so is invoked twice,
850            once for the item that became inactive and once for the one that became
851            active.
852         */
853
854         RefPtr<RadioAction> ract = snap_mode_action (mode);
855
856         if (ract && ract->get_active()) {
857                 set_snap_mode (mode);
858         }
859 }
860
861 RefPtr<RadioAction>
862 Editor::edit_point_action (EditPoint ep)
863 {
864         const char* action = 0;
865         RefPtr<Action> act;
866         
867         switch (ep) {
868         case Editing::EditAtPlayhead:
869                 action = X_("edit-at-playhead");
870                 break;
871         case Editing::EditAtSelectedMarker:
872                 action = X_("edit-at-selected-marker");
873                 break;
874         case Editing::EditAtMouse:
875                 action = X_("edit-at-mouse");
876                 break;
877         default:
878                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible edit point type", (int) ep) << endmsg;
879                 /*NOTREACHED*/
880         }
881         
882         act = ActionManager::get_action (X_("Editor"), action);
883         
884         if (act) {
885                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
886                 return ract;
887                 
888         } else  {
889                 error << string_compose (_("programming error: %1: %2"), "Editor::edit_point_action could not find action to match edit point.", action) << endmsg;
890                 return RefPtr<RadioAction> ();
891         }
892 }
893
894 void
895 Editor::edit_point_chosen (EditPoint ep)
896 {
897         /* this is driven by a toggle on a radio group, and so is invoked twice,
898            once for the item that became inactive and once for the one that became
899            active.
900         */
901
902         RefPtr<RadioAction> ract = edit_point_action (ep);
903
904         if (ract && ract->get_active()) {
905                 set_edit_point_preference (ep);
906         }
907 }
908
909
910 RefPtr<RadioAction>
911 Editor::zoom_focus_action (ZoomFocus focus)
912 {
913         const char* action = 0;
914         RefPtr<Action> act;
915         
916         switch (focus) {
917         case ZoomFocusLeft:
918                 action = X_("zoom-focus-left");
919                 break;
920         case ZoomFocusRight:
921                 action = X_("zoom-focus-right");
922                 break;
923         case ZoomFocusCenter:
924                 action = X_("zoom-focus-center");
925                 break;
926         case ZoomFocusPlayhead:
927                 action = X_("zoom-focus-playhead");
928                 break;
929         case ZoomFocusMouse:
930                 action = X_("zoom-focus-mouse");
931                 break;
932         case ZoomFocusEdit:
933                 action = X_("zoom-focus-edit");
934                 break;
935         default:
936                 fatal << string_compose (_("programming error: %1: %2"), "Editor: impossible focus type", (int) focus) << endmsg;
937                 /*NOTREACHED*/
938         }
939         
940         act = ActionManager::get_action (X_("Zoom"), action);
941         
942         if (act) {
943                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
944                 return ract;
945         } else {
946                 error << string_compose (_("programming error: %1: %2"), "Editor::zoom_focus_action could not find action to match focus.", action) << endmsg;
947         }
948
949         return RefPtr<RadioAction> ();
950 }
951
952 void
953 Editor::zoom_focus_chosen (ZoomFocus focus)
954 {
955         /* this is driven by a toggle on a radio group, and so is invoked twice,
956            once for the item that became inactive and once for the one that became
957            active.
958         */
959
960         RefPtr<RadioAction> ract = zoom_focus_action (focus);
961
962         if (ract && ract->get_active()) {
963                 set_zoom_focus (focus);
964         }
965 }
966
967 void
968 Editor::smpte_fps_chosen (SmpteFormat format)
969 {
970         /* this is driven by a toggle on a radio group, and so is invoked twice,
971            once for the item that became inactive and once for the one that became
972            active.
973         */
974
975         if (session) {
976
977                 RefPtr<Action> act;
978
979                 switch (format) {
980                         case smpte_23976: 
981                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte23976"));
982                          break;
983                         case smpte_24: 
984                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte24"));
985                          break;
986                         case smpte_24976: 
987                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte24976"));
988                          break;
989                         case smpte_25: 
990                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte25"));
991                          break;
992                         case smpte_2997: 
993                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte2997"));
994                          break;
995                         case smpte_2997drop: 
996                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte2997drop"));
997                          break;
998                         case smpte_30: 
999                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte30"));
1000                          break;
1001                         case smpte_30drop: 
1002                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte30drop"));
1003                          break;
1004                         case smpte_5994: 
1005                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte5994"));
1006                          break;
1007                         case smpte_60: 
1008                                 act = ActionManager::get_action (X_("Editor"), X_("Smpte60"));
1009                          break;
1010                         default:
1011                                 cerr << "Editor received unexpected smpte type" << endl;
1012                 }
1013
1014                 if (act) {
1015                         RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1016                         if (ract && ract->get_active()) {
1017                                 session->set_smpte_format (format);
1018                         }
1019                 }
1020         }
1021 }
1022
1023 void
1024 Editor::video_pullup_chosen (Session::PullupFormat pullup)
1025 {
1026         /* this is driven by a toggle on a radio group, and so is invoked twice,
1027            once for the item that became inactive and once for the one that became
1028            active.
1029         */
1030
1031         const char* action = 0;
1032
1033         RefPtr<Action> act;
1034         
1035         float pull = 0.0;
1036         
1037         switch (pullup) {
1038         case Session::pullup_Plus4Plus1:
1039                 pull = 4.1667 + 0.1;
1040                 action = X_("PullupPlus4Plus1");
1041                 break;
1042         case Session::pullup_Plus4:
1043                 pull = 4.1667;
1044                 action = X_("PullupPlus4");
1045                 break;
1046         case Session::pullup_Plus4Minus1:
1047                 pull = 4.1667 - 0.1;
1048                 action = X_("PullupPlus4Minus1");
1049                 break;
1050         case Session::pullup_Plus1:
1051                 pull = 0.1;
1052                 action = X_("PullupPlus1");
1053                 break;
1054         case Session::pullup_None:
1055                 pull = 0.0;
1056                 action = X_("PullupNone");
1057                 break;
1058         case Session::pullup_Minus1:
1059                 pull = -0.1;
1060                 action = X_("PullupMinus1");
1061                 break;
1062         case Session::pullup_Minus4Plus1:
1063                 pull = -4.1667 + 0.1;
1064                 action = X_("PullupMinus4Plus1");
1065                 break;
1066         case Session::pullup_Minus4:
1067                 pull = -4.1667;
1068                 action = X_("PullupMinus4");
1069                 break;
1070         case Session::pullup_Minus4Minus1:
1071                 pull = -4.1667 - 0.1;
1072                 action = X_("PullupMinus4Minus1");
1073                 break;
1074         default:
1075                 fatal << string_compose (_("programming error: %1"), "Session received unexpected pullup type") << endmsg;
1076                 /*NOTREACHED*/
1077         }
1078         
1079         act = ActionManager::get_action (X_("Editor"), action);
1080         
1081         if (act) {
1082                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1083                 if (ract && ract->get_active()) {
1084                         Config->set_video_pullup ( pull );
1085                 }
1086                 
1087         } else  {
1088                 error << string_compose (_("programming error: %1"), "Editor::video_pullup_chosen could not find action to match pullup.") << endmsg;
1089         }
1090 }
1091
1092 void
1093 Editor::update_subframes_per_frame ()
1094 {
1095         ENSURE_GUI_THREAD (mem_fun(*this, &Editor::update_subframes_per_frame));
1096
1097         RefPtr<Action> act;
1098         const char* action = 0;
1099
1100         uint32_t sfpf = Config->get_subframes_per_frame();
1101
1102         if (sfpf == 80) {
1103                 action = X_("Subframes80");
1104         } else if (sfpf == 100) {
1105                 action = X_("Subframes100");
1106         } else {
1107                 warning << string_compose (_("Configuraton is using unhandled subframes per frame value: %1"), sfpf) << endmsg;
1108                 /*NOTREACHED*/
1109                 return;
1110         }
1111
1112         act = ActionManager::get_action (X_("Editor"), action);
1113
1114         if (act) {
1115                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1116                 if (ract && !ract->get_active()) {
1117                         ract->set_active (true);
1118                 }
1119         }
1120 }
1121
1122 void
1123 Editor::subframes_per_frame_chosen (uint32_t sfpf)
1124 {
1125         /* this is driven by a toggle on a radio group, and so is invoked twice,
1126            once for the item that became inactive and once for the one that became
1127            active.
1128         */
1129
1130         const char* action = 0;
1131
1132         RefPtr<Action> act;
1133         
1134         if (sfpf == 80) {
1135                 action = X_("Subframes80");
1136         } else if (sfpf == 100) {       
1137                 action = X_("Subframes100");
1138         } else {
1139                 fatal << string_compose (_("programming error: %1 %2"), "Session received unexpected subframes per frame value: ", sfpf) << endmsg;
1140                 /*NOTREACHED*/
1141         }
1142         
1143         act = ActionManager::get_action (X_("Editor"), action);
1144         
1145         if (act) {
1146                 RefPtr<RadioAction> ract = RefPtr<RadioAction>::cast_dynamic(act);
1147                 if (ract && ract->get_active()) {
1148                         Config->set_subframes_per_frame ((uint32_t) rint (sfpf));
1149                 }
1150                 
1151         } else  {
1152                 error << string_compose (_("programming error: %1"), "Editor::subframes_per_frame_chosen could not find action to match value.") << endmsg;
1153         }
1154 }
1155
1156 void
1157 Editor::toggle_auto_xfade ()
1158 {
1159         ActionManager::toggle_config_state ("Editor", "toggle-auto-xfades", &Configuration::set_auto_xfade, &Configuration::get_auto_xfade);
1160 }
1161
1162 void
1163 Editor::toggle_xfades_active ()
1164 {
1165         ActionManager::toggle_config_state ("Editor", "toggle-xfades-active", &Configuration::set_xfades_active, &Configuration::get_xfades_active);
1166 }
1167
1168 void
1169 Editor::toggle_xfade_visibility ()
1170 {
1171         ActionManager::toggle_config_state ("Editor", "toggle-xfades-visible", &Configuration::set_xfades_visible, &Configuration::get_xfades_visible);
1172 }
1173
1174 /** A Configuration parameter has changed.
1175  * @param parameter_name Name of the changed parameter.
1176  */
1177 void
1178 Editor::parameter_changed (const char* parameter_name)
1179 {
1180 #define PARAM_IS(x) (!strcmp (parameter_name, (x)))
1181
1182         ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::parameter_changed), parameter_name));
1183
1184         if (PARAM_IS ("auto-loop")) {
1185                 update_loop_range_view (true);
1186         } else if (PARAM_IS ("punch-in")) {
1187                 update_punch_range_view (true);
1188         } else if (PARAM_IS ("punch-out")) {
1189                 update_punch_range_view (true);
1190         } else if (PARAM_IS ("layer-model")) {
1191                 update_layering_model ();
1192         } else if (PARAM_IS ("smpte-format")) {
1193                 update_smpte_mode ();
1194                 update_just_smpte ();
1195         } else if (PARAM_IS ("video-pullup")) {
1196                 update_video_pullup ();
1197         } else if (PARAM_IS ("xfades-active")) {
1198                 ActionManager::map_some_state ("Editor", "toggle-xfades-active", &Configuration::get_xfades_active);
1199         } else if (PARAM_IS ("xfades-visible")) {
1200                 ActionManager::map_some_state ("Editor", "toggle-xfades-visible", &Configuration::get_xfades_visible);
1201                 update_xfade_visibility ();
1202         } else if (PARAM_IS ("auto-xfade")) {
1203                 ActionManager::map_some_state ("Editor", "toggle-auto-xfades", &Configuration::get_auto_xfade);
1204         } else if (PARAM_IS ("xfade-model")) {
1205                 update_crossfade_model ();
1206         } else if (PARAM_IS ("edit-mode")) {
1207                 edit_mode_selector.set_active_text (edit_mode_to_string (Config->get_edit_mode()));
1208         } else if (PARAM_IS ("subframes-per-frame")) {
1209                 update_subframes_per_frame ();
1210                 update_just_smpte ();
1211         }
1212
1213 #undef PARAM_IS
1214 }
1215
1216 void
1217 Editor::reset_focus ()
1218 {
1219         track_canvas.grab_focus();
1220 }