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