Editor zoom: add zoom_to_extents()
[ardour.git] / gtk2_ardour / editor_actions.cc
index 046d9b94e111e1a825f9ac1d1dea024946039075..8a447beecf1f98898d3b7344fb4e26e8a5602b73 100644 (file)
 #include "editing.h"
 #include "editor.h"
 #include "gui_thread.h"
+#include "main_clock.h"
 #include "time_axis_view.h"
 #include "ui_config.h"
 #include "utils.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
 #include "audio_time_axis.h"
 #include "editor_group_tabs.h"
 #include "editor_routes.h"
@@ -59,6 +60,24 @@ using Gtkmm2ext::Bindings;
 
 /* Convenience functions to slightly reduce verbosity below */
 
+
+RefPtr<Action>
+Editor::register_region_action (RefPtr<ActionGroup> group, RegionActionTarget tgt, char const * name, char const * label, sigc::slot<void> slot)
+{
+       RefPtr<Action> act = myactions.register_action (group, name, label, slot);
+       ActionManager::session_sensitive_actions.push_back (act);
+       region_action_map.insert (make_pair<string,RegionAction> (name, RegionAction (act,tgt)));
+       return act;
+}
+
+void
+Editor::register_toggle_region_action (RefPtr<ActionGroup> group, RegionActionTarget tgt, char const * name, char const * label, sigc::slot<void> slot)
+{
+       RefPtr<Action> act = myactions.register_toggle_action (group, name, label, slot);
+       ActionManager::session_sensitive_actions.push_back (act);
+       region_action_map.insert (make_pair<string,RegionAction> (name, RegionAction (act,tgt)));
+}
+
 RefPtr<Action>
 Editor::reg_sens (RefPtr<ActionGroup> group, char const * name, char const * label, sigc::slot<void> slot)
 {
@@ -141,20 +160,21 @@ Editor::register_actions ()
        myactions.register_action (editor_menu_actions, X_("SyncMenu"), _("Sync"));
        myactions.register_action (editor_menu_actions, X_("TempoMenu"), _("Tempo"));
        myactions.register_action (editor_menu_actions, X_("Timecode"), _("Timecode fps"));
-       myactions.register_action (editor_menu_actions, X_("TrackHeightMenu"), _("Height"));
+
+       act = myactions.register_action (editor_menu_actions, X_("TrackHeightMenu"), _("Height"));
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
+
        myactions.register_action (editor_menu_actions, X_("TrackMenu"), _("Track"));
        myactions.register_action (editor_menu_actions, X_("Tools"), _("Tools"));
        myactions.register_action (editor_menu_actions, X_("View"), _("View"));
        myactions.register_action (editor_menu_actions, X_("ZoomFocus"), _("Zoom Focus"));
        myactions.register_action (editor_menu_actions, X_("ZoomMenu"), _("Zoom"));
-       myactions.register_action (editor_menu_actions, X_("ActionScripts"), _("Scripted Actions"));
+       myactions.register_action (editor_menu_actions, X_("LuaScripts"), _("Lua Scripts"));
 
        register_region_actions ();
 
        /* add named actions for the editor */
 
-       myactions.register_action (editor_actions, "escape", _("Break drag or deselect all"), sigc::mem_fun (*this, &Editor::escape));
-
        /* We don't bother registering "unlock" because it would be insensitive
           when required. Editor::unlock() must be invoked directly.
        */
@@ -204,6 +224,9 @@ Editor::register_actions ()
        reg_sens (editor_actions, "select-punch-range", _("Set Range to Punch Range"), sigc::mem_fun(*this, &Editor::set_selection_from_punch));
        reg_sens (editor_actions, "select-from-regions", _("Set Range to Selected Regions"), sigc::mem_fun(*this, &Editor::set_selection_from_region));
 
+       reg_sens (editor_actions, "edit-current-tempo", _("Edit Current Tempo"), sigc::mem_fun(*this, &Editor::edit_current_tempo));
+       reg_sens (editor_actions, "edit-current-meter", _("Edit Current Meter"), sigc::mem_fun(*this, &Editor::edit_current_meter));
+
        reg_sens (editor_actions, "select-all-after-edit-cursor", _("Select All After Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), true, false));
        reg_sens (editor_actions, "alternate-select-all-after-edit-cursor", _("Select All After Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), true, false));
        reg_sens (editor_actions, "select-all-before-edit-cursor", _("Select All Before Edit Point"), sigc::bind (sigc::mem_fun(*this, &Editor::select_all_selectables_using_edit), false, false));
@@ -217,17 +240,20 @@ Editor::register_actions ()
        reg_sens (editor_actions, "select-all-in-punch-range", _("Select All in Punch Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_punch));
        reg_sens (editor_actions, "select-all-in-loop-range", _("Select All in Loop Range"), sigc::mem_fun(*this, &Editor::select_all_selectables_using_loop));
 
-       reg_sens (editor_actions, "select-next-route", _("Select Next Track or Bus"), sigc::mem_fun(*this, &Editor::select_next_route));
-       reg_sens (editor_actions, "select-prev-route", _("Select Previous Track or Bus"), sigc::mem_fun(*this, &Editor::select_prev_route));
+       reg_sens (editor_actions, "select-next-route", _("Select Next Track or Bus"), sigc::bind (sigc::mem_fun(*this, &Editor::select_next_stripable), true));
+       reg_sens (editor_actions, "select-prev-route", _("Select Previous Track or Bus"), sigc::bind (sigc::mem_fun(*this, &Editor::select_prev_stripable), true));
+
+       reg_sens (editor_actions, "select-next-stripable", _("Select Next Strip"), sigc::bind (sigc::mem_fun(*this, &Editor::select_next_stripable), false));
+       reg_sens (editor_actions, "select-prev-stripable", _("Select Previous Strip"), sigc::bind (sigc::mem_fun(*this, &Editor::select_prev_stripable), false));
 
        act = reg_sens (editor_actions, "track-record-enable-toggle", _("Toggle Record Enable"), sigc::mem_fun(*this, &Editor::toggle_record_enable));
        ActionManager::track_selection_sensitive_actions.push_back (act);
        act = reg_sens (editor_actions, "track-solo-toggle", _("Toggle Solo"), sigc::mem_fun(*this, &Editor::toggle_solo));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
        act = reg_sens (editor_actions, "track-mute-toggle", _("Toggle Mute"), sigc::mem_fun(*this, &Editor::toggle_mute));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
        act = reg_sens (editor_actions, "track-solo-isolate-toggle", _("Toggle Solo Isolate"), sigc::mem_fun(*this, &Editor::toggle_solo_isolate));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
 
        for (int i = 1; i <= 12; ++i) {
                string const a = string_compose (X_("save-visual-state-%1"), i);
@@ -247,33 +273,12 @@ Editor::register_actions ()
                reg_sens (editor_actions, a.c_str(), n.c_str(), sigc::bind (sigc::mem_fun (*this, &Editor::goto_nth_marker), i - 1));
        }
 
-
-       reg_sens (editor_actions, "jump-forward-to-mark", _("Jump to Next Mark"), sigc::mem_fun(*this, &Editor::jump_forward_to_mark));
-       reg_sens (editor_actions, "alternate-jump-forward-to-mark", _("Jump to Next Mark"), sigc::mem_fun(*this, &Editor::jump_forward_to_mark));
-       reg_sens (editor_actions, "jump-backward-to-mark", _("Jump to Previous Mark"), sigc::mem_fun(*this, &Editor::jump_backward_to_mark));
-       reg_sens (editor_actions, "alternate-jump-backward-to-mark", _("Jump to Previous Mark"), sigc::mem_fun(*this, &Editor::jump_backward_to_mark));
-
-       reg_sens (editor_actions, "set-session-start-from-playhead", _("Set Session Start from Playhead"), sigc::mem_fun(*this, &Editor::set_session_start_from_playhead));
-       reg_sens (editor_actions, "set-session-end-from-playhead", _("Set Session End from Playhead"), sigc::mem_fun(*this, &Editor::set_session_end_from_playhead));
-
-       reg_sens (editor_actions, "add-location-from-playhead", _("Add Mark from Playhead"), sigc::mem_fun(*this, &Editor::add_location_from_playhead_cursor));
-       reg_sens (editor_actions, "alternate-add-location-from-playhead", _("Add Mark from Playhead"), sigc::mem_fun(*this, &Editor::add_location_from_playhead_cursor));
-
-       reg_sens (editor_actions, "remove-location-from-playhead", _("Remove Mark at Playhead"), sigc::mem_fun(*this, &Editor::remove_location_at_playhead_cursor));
-       reg_sens (editor_actions, "alternate-remove-location-from-playhead", _("Remove Mark at Playhead"), sigc::mem_fun(*this, &Editor::remove_location_at_playhead_cursor));
-
-       reg_sens (editor_actions, "nudge-next-forward", _("Nudge Next Later"), sigc::bind (sigc::mem_fun(*this, &Editor::nudge_forward), true, false));
-       reg_sens (editor_actions, "nudge-next-backward", _("Nudge Next Earlier"), sigc::bind (sigc::mem_fun(*this, &Editor::nudge_backward), true, false));
-
-       reg_sens (editor_actions, "nudge-playhead-forward", _("Nudge Playhead Forward"), sigc::bind (sigc::mem_fun(*this, &Editor::nudge_forward), false, true));
-       reg_sens (editor_actions, "nudge-playhead-backward", _("Nudge Playhead Backward"), sigc::bind (sigc::mem_fun(*this, &Editor::nudge_backward), false, true));
-       reg_sens (editor_actions, "playhead-forward-to-grid", _("Playhead to Next Grid"), sigc::mem_fun(*this, &Editor::playhead_forward_to_grid));
-       reg_sens (editor_actions, "playhead-backward-to-grid", _("Playhead to Previous Grid"), sigc::mem_fun(*this, &Editor::playhead_backward_to_grid));
-
        reg_sens (editor_actions, "temporal-zoom-out", _("Zoom Out"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), true));
        reg_sens (editor_actions, "temporal-zoom-in", _("Zoom In"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_step), false));
        reg_sens (editor_actions, "zoom-to-session", _("Zoom to Session"), sigc::mem_fun(*this, &Editor::temporal_zoom_session));
-       reg_sens (editor_actions, "zoom-to-selection", _("Zoom to Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), false));
+       reg_sens (editor_actions, "zoom-to-extents", _("Zoom to Extents"), sigc::mem_fun(*this, &Editor::temporal_zoom_extents));
+       reg_sens (editor_actions, "zoom-to-selection", _("Zoom to Selection"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), Both));
+       reg_sens (editor_actions, "zoom-to-selection-horiz", _("Zoom to Selection (Horizontal)"), sigc::bind (sigc::mem_fun(*this, &Editor::temporal_zoom_selection), Horizontal));
        reg_sens (editor_actions, "toggle-zoom", _("Toggle Zoom State"), sigc::mem_fun(*this, &Editor::swap_visual_state));
 
        reg_sens (editor_actions, "expand-tracks", _("Expand Track Height"), sigc::bind (sigc::mem_fun (*this, &Editor::tav_zoom_step), false));
@@ -296,14 +301,15 @@ Editor::register_actions ()
        reg_sens (editor_actions, "zoom_10_min", _("Zoom to 10 min"), sigc::bind (sigc::mem_fun(*this, &Editor::set_zoom_preset), 10 * 60 * 1000));
 
        act = reg_sens (editor_actions, "move-selected-tracks-up", _("Move Selected Tracks Up"), sigc::bind (sigc::mem_fun(*_routes, &EditorRoutes::move_selected_tracks), true));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
        act = reg_sens (editor_actions, "move-selected-tracks-down", _("Move Selected Tracks Down"), sigc::bind (sigc::mem_fun(*_routes, &EditorRoutes::move_selected_tracks), false));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
 
        act = reg_sens (editor_actions, "scroll-tracks-up", _("Scroll Tracks Up"), sigc::mem_fun(*this, &Editor::scroll_tracks_up));
        act = reg_sens (editor_actions, "scroll-tracks-down", _("Scroll Tracks Down"), sigc::mem_fun(*this, &Editor::scroll_tracks_down));
-       act = reg_sens (editor_actions, "step-tracks-up", _("Step Tracks Up"), sigc::mem_fun(*this, &Editor::scroll_tracks_up_line));
-       act = reg_sens (editor_actions, "step-tracks-down", _("Step Tracks Down"), sigc::mem_fun(*this, &Editor::scroll_tracks_down_line));
+       act = reg_sens (editor_actions, "step-tracks-up", _("Step Tracks Up"), sigc::hide_return (sigc::bind (sigc::mem_fun(*this, &Editor::scroll_up_one_track), true)));
+       act = reg_sens (editor_actions, "step-tracks-down", _("Step Tracks Down"), sigc::hide_return (sigc::bind (sigc::mem_fun(*this, &Editor::scroll_down_one_track), true)));
+       act = reg_sens (editor_actions, "select-topmost", _("Select Topmost Track"), (sigc::mem_fun(*this, &Editor::select_topmost_track)));
 
        reg_sens (editor_actions, "scroll-backward", _("Scroll Backward"), sigc::bind (sigc::mem_fun(*this, &Editor::scroll_backward), 0.8f));
        reg_sens (editor_actions, "scroll-forward", _("Scroll Forward"), sigc::bind (sigc::mem_fun(*this, &Editor::scroll_forward), 0.8f));
@@ -331,8 +337,13 @@ Editor::register_actions ()
 
        reg_sens (editor_actions, "set-playhead", _("Playhead to Mouse"), sigc::mem_fun(*this, &Editor::set_playhead_cursor));
        reg_sens (editor_actions, "set-edit-point", _("Active Marker to Mouse"), sigc::mem_fun(*this, &Editor::set_edit_point));
+       reg_sens (editor_actions, "set-auto-punch-range", _("Set Auto Punch In/Out from Playhead"), sigc::mem_fun(*this, &Editor::set_auto_punch_range));
+
+       reg_sens (editor_actions, "duplicate", _("Duplicate"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_range), false));
 
-       reg_sens (editor_actions, "duplicate-range", _("Duplicate Range"), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_range), false));
+       /* Open the dialogue to duplicate selected regions multiple times */
+       reg_sens (editor_actions, "multi-duplicate", _("Multi-Duplicate..."),
+                 sigc::bind (sigc::mem_fun (*this, &Editor::duplicate_range), true));
 
        undo_action = reg_sens (editor_actions, "undo", S_("Command|Undo"), sigc::bind (sigc::mem_fun(*this, &Editor::undo), 1U));
 
@@ -350,24 +361,24 @@ Editor::register_actions ()
        ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
 
        act = reg_sens (editor_actions, "separate-from-punch", _("Separate Using Punch Range"), sigc::mem_fun(*this, &Editor::separate_region_from_punch));
-       ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
-
        act = reg_sens (editor_actions, "separate-from-loop", _("Separate Using Loop Range"), sigc::mem_fun(*this, &Editor::separate_region_from_loop));
-       ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
 
        act = reg_sens (editor_actions, "editor-crop", _("Crop"), sigc::mem_fun(*this, &Editor::crop_region_to_selection));
-       ActionManager::mouse_edit_point_requires_canvas_actions.push_back (act);
+       ActionManager::time_selection_sensitive_actions.push_back (act);
 
        reg_sens (editor_actions, "editor-cut", _("Cut"), sigc::mem_fun(*this, &Editor::cut));
        reg_sens (editor_actions, "editor-delete", _("Delete"), sigc::mem_fun(*this, &Editor::delete_));
        reg_sens (editor_actions, "alternate-editor-delete", _("Delete"), sigc::mem_fun(*this, &Editor::delete_));
 
+       reg_sens (editor_actions, "split-region", _("Split/Separate"), sigc::mem_fun (*this, &Editor::split_region));
+
        reg_sens (editor_actions, "editor-copy", _("Copy"), sigc::mem_fun(*this, &Editor::copy));
        reg_sens (editor_actions, "editor-paste", _("Paste"), sigc::mem_fun(*this, &Editor::keyboard_paste));
 
        reg_sens (editor_actions, "editor-fade-range", _("Fade Range Selection"), sigc::mem_fun(*this, &Editor::fade_range));
 
-       reg_sens (editor_actions, "set-tempo-from-edit-range", _("Set Tempo from Edit Range = Bar"), sigc::mem_fun(*this, &Editor::use_range_as_bar));
+       act = myactions.register_action (editor_actions, "set-tempo-from-edit-range", _("Set Tempo from Edit Range = Bar"), sigc::mem_fun(*this, &Editor::use_range_as_bar));
+       ActionManager::time_selection_sensitive_actions.push_back (act);
 
        toggle_reg_sens (editor_actions, "toggle-log-window", _("Log"),
                        sigc::mem_fun (ARDOUR_UI::instance(), &ARDOUR_UI::toggle_errors));
@@ -379,21 +390,6 @@ Editor::register_actions ()
 
        reg_sens (editor_actions, "crop", _("Crop"), sigc::mem_fun(*this, &Editor::crop_region_to_selection));
 
-       reg_sens (editor_actions, "start-range-from-playhead", _("Start Range from Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_begin), EDIT_IGNORE_MOUSE ));
-       reg_sens (editor_actions, "finish-range-from-playhead", _("Finish Range from Playhead"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_finish), false, EDIT_IGNORE_MOUSE ));
-
-       reg_sens (editor_actions, "start-range", _("Start Range"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_begin), EDIT_IGNORE_NONE));
-       reg_sens (editor_actions, "finish-range", _("Finish Range"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_finish), false, EDIT_IGNORE_NONE));
-
-       reg_sens (editor_actions, "start-punch-range", _("Start Punch Range"), sigc::mem_fun(*this, &Editor::set_punch_start_from_edit_point));
-       reg_sens (editor_actions, "finish-punch-range", _("Finish Punch Range"), sigc::mem_fun(*this, &Editor::set_punch_end_from_edit_point));
-
-       reg_sens (editor_actions, "start-loop-range", _("Start Loop Range"), sigc::mem_fun(*this, &Editor::set_loop_start_from_edit_point));
-       reg_sens (editor_actions, "finish-loop-range", _("Finish Loop Range"), sigc::mem_fun(*this, &Editor::set_loop_end_from_edit_point));
-
-       reg_sens (editor_actions, "alt-start-range", _("Start Range"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_begin), EDIT_IGNORE_NONE));
-       reg_sens (editor_actions, "alt-finish-range", _("Finish Range"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_finish), false, EDIT_IGNORE_NONE));
-
 //     reg_sens (editor_actions, "finish-add-range", _("Finish Add Range"), sigc::bind (sigc::mem_fun(*this, &Editor::keyboard_selection_finish), true));
 
        reg_sens (
@@ -437,29 +433,28 @@ Editor::register_actions ()
 
 
        act = reg_sens (editor_actions, "toggle-track-active", _("Toggle Active"), (sigc::mem_fun(*this, &Editor::toggle_tracks_active)));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::route_selection_sensitive_actions.push_back (act);
        act = reg_sens (editor_actions, "remove-track", _("Remove"), (sigc::mem_fun(*this, &Editor::remove_tracks)));
-       /* not selection sensitive? */
-
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
 
        act = reg_sens (editor_actions, "fit-selection", _("Fit Selection (Vertical)"), sigc::mem_fun(*this, &Editor::fit_selection));
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
 
        act = reg_sens (editor_actions, "track-height-largest", _("Largest"), sigc::bind (
                                sigc::mem_fun(*this, &Editor::set_track_height), HeightLargest));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
        act = reg_sens (editor_actions, "track-height-larger", _("Larger"), sigc::bind (
                                sigc::mem_fun(*this, &Editor::set_track_height), HeightLarger));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
        act = reg_sens (editor_actions, "track-height-large", _("Large"), sigc::bind (
                                sigc::mem_fun(*this, &Editor::set_track_height), HeightLarge));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
        act = reg_sens (editor_actions, "track-height-normal", _("Normal"), sigc::bind (
                                sigc::mem_fun(*this, &Editor::set_track_height), HeightNormal));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
        act = reg_sens (editor_actions, "track-height-small", _("Small"), sigc::bind (
                                sigc::mem_fun(*this, &Editor::set_track_height), HeightSmall));
-       ActionManager::track_selection_sensitive_actions.push_back (act);
+       ActionManager::stripable_selection_sensitive_actions.push_back (act);
 
        toggle_reg_sens (editor_actions, "sound-midi-notes", _("Sound Selected MIDI Notes"), sigc::mem_fun (*this, &Editor::toggle_sound_midi_notes));
 
@@ -475,12 +470,12 @@ Editor::register_actions ()
 
        myactions.register_action (editor_actions, X_("cycle-zoom-focus"), _("Next Zoom Focus"), sigc::mem_fun (*this, &Editor::cycle_zoom_focus));
 
-       act = reg_sens (editor_actions, "manage-action-scripts", _("Manage"),
-                               sigc::mem_fun(*this, &Editor::manage_action_scripts));
        for (int i = 1; i <= 9; ++i) {
                string const a = string_compose (X_("script-action-%1"), i);
                string const n = string_compose (_("Unset #%1"), i);
-               reg_sens (editor_actions, a.c_str(), n.c_str(), sigc::bind (sigc::mem_fun (*this, &Editor::trigger_script), i - 1));
+               act = myactions.register_action (editor_actions, a.c_str(), n.c_str(), sigc::bind (sigc::mem_fun (*this, &Editor::trigger_script), i - 1));
+               act->set_tooltip (_("no action bound"));
+               act->set_sensitive (false);
        }
 
        Glib::RefPtr<ActionGroup> mouse_mode_actions = myactions.create_action_group (X_("MouseMode"));
@@ -494,38 +489,38 @@ Editor::register_actions ()
 
        act = myactions.register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-object", _("Object Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
        mouse_move_button.set_related_action (act);
-       mouse_move_button.set_icon (Gtkmm2ext::ArdourIcon::ToolGrab);
+       mouse_move_button.set_icon (ArdourWidgets::ArdourIcon::ToolGrab);
        mouse_move_button.set_name ("mouse mode button");
 
        act = myactions.register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-range", _("Range Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
        mouse_select_button.set_related_action (act);
-       mouse_select_button.set_icon (Gtkmm2ext::ArdourIcon::ToolRange);
+       mouse_select_button.set_icon (ArdourWidgets::ArdourIcon::ToolRange);
        mouse_select_button.set_name ("mouse mode button");
 
        act = myactions.register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-draw", _("Note Drawing Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseDraw));
        mouse_draw_button.set_related_action (act);
-       mouse_draw_button.set_icon (Gtkmm2ext::ArdourIcon::ToolDraw);
+       mouse_draw_button.set_icon (ArdourWidgets::ArdourIcon::ToolDraw);
        mouse_draw_button.set_name ("mouse mode button");
 
        act = myactions.register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-audition", _("Audition Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
        mouse_audition_button.set_related_action (act);
-       mouse_audition_button.set_icon (Gtkmm2ext::ArdourIcon::ToolAudition);
+       mouse_audition_button.set_icon (ArdourWidgets::ArdourIcon::ToolAudition);
        mouse_audition_button.set_name ("mouse mode button");
 
        act = myactions.register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-timefx", _("Time FX Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
        mouse_timefx_button.set_related_action (act);
-       mouse_timefx_button.set_icon (Gtkmm2ext::ArdourIcon::ToolStretch);
+       mouse_timefx_button.set_icon (ArdourWidgets::ArdourIcon::ToolStretch);
        mouse_timefx_button.set_name ("mouse mode button");
 
        act = myactions.register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-content", _("Content Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseContent));
        mouse_content_button.set_related_action (act);
-       mouse_content_button.set_icon (Gtkmm2ext::ArdourIcon::ToolContent);
+       mouse_content_button.set_icon (ArdourWidgets::ArdourIcon::ToolContent);
        mouse_content_button.set_name ("mouse mode button");
 
        if(!Profile->get_mixbus()) {
                act = myactions.register_radio_action (mouse_mode_actions, mouse_mode_group, "set-mouse-mode-cut", _("Cut Tool"), sigc::bind (sigc::mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseCut));
                mouse_cut_button.set_related_action (act);
-               mouse_cut_button.set_icon (Gtkmm2ext::ArdourIcon::ToolCut);
+               mouse_cut_button.set_icon (ArdourWidgets::ArdourIcon::ToolCut);
                mouse_cut_button.set_name ("mouse mode button");
        }
 
@@ -646,7 +641,7 @@ Editor::register_actions ()
                ruler_range_action->set_active (true);
                ruler_loop_punch_action->set_active (true);
                ruler_loop_punch_action->set_active (true);
-               ruler_bbt_action->set_active (false);
+               ruler_bbt_action->set_active (true);
                ruler_cd_marker_action->set_active (true);
                ruler_timecode_action->set_active (true);
                ruler_minsec_action->set_active (false);
@@ -726,9 +721,6 @@ Editor::register_actions ()
 
        /* the next two are duplicate items with different names for use in two different contexts */
 
-       act = reg_sens (editor_actions, X_("addExistingAudioFiles"), _("Import"), sigc::mem_fun (*this, &Editor::external_audio_dialog));
-       ActionManager::write_sensitive_actions.push_back (act);
-
        act = reg_sens (editor_actions, X_("addExternalAudioToRegionList"), _("Import to Region List..."), sigc::bind (sigc::mem_fun(*this, &Editor::add_external_audio_action), ImportAsRegion));
        ActionManager::write_sensitive_actions.push_back (act);
 
@@ -746,13 +738,18 @@ Editor::register_actions ()
        myactions.register_toggle_action (editor_actions, X_("ToggleMeasureVisibility"), _("Show Measure Lines"), sigc::mem_fun (*this, &Editor::toggle_measure_visibility));
 
        myactions.register_action (editor_actions, X_("toggle-midi-input-active"), _("Toggle MIDI Input Active for Editor-Selected Tracks/Busses"),
-                                  sigc::bind (sigc::mem_fun (*this, &Editor::toggle_midi_input_active), false));
+                                  sigc::bind (sigc::mem_fun (*this, &Editor::toggle_midi_input_active), false));
+
+
+       /* MIDI stuff */
+       reg_sens (editor_actions, "quantize", _("Quantize"), sigc::mem_fun (*this, &Editor::quantize_region));
+
 }
 
 void
 Editor::load_bindings ()
 {
-       bindings = Bindings::get_bindings (X_("editor"), myactions);
+       bindings = Bindings::get_bindings (X_("Editor"), myactions);
        global_hpacker.set_data ("ardour-bindings", bindings);
 }
 
@@ -981,6 +978,20 @@ Editor::toggle_measure_visibility ()
        }
 }
 
+void
+Editor::edit_current_meter ()
+{
+       ARDOUR::MeterSection* ms = const_cast<ARDOUR::MeterSection*>(&_session->tempo_map().meter_section_at_frame (ARDOUR_UI::instance()->primary_clock->absolute_time()));
+       edit_meter_section (ms);
+}
+
+void
+Editor::edit_current_tempo ()
+{
+       ARDOUR::TempoSection* ts = const_cast<ARDOUR::TempoSection*>(&_session->tempo_map().tempo_section_at_frame (ARDOUR_UI::instance()->primary_clock->absolute_time()));
+       edit_tempo_section (ts);
+}
+
 RefPtr<RadioAction>
 Editor::snap_type_action (SnapType type)
 {
@@ -1689,7 +1700,7 @@ Editor::parameter_changed (std::string p)
                        _group_tabs->hide ();
                }
 
-                reset_controls_layout_width ();
+               reset_controls_layout_width ();
 
                Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("ToggleGroupTabs"));
                if (act) {
@@ -1712,19 +1723,6 @@ Editor::parameter_changed (std::string p)
                }
        } else if (p == "show-region-gain") {
                set_gain_envelope_visibility ();
-       } else if (p == "remote-model") {
-               if (_routes) {
-                       _routes->reset_remote_control_ids ();
-               }
-       } else if (p == "use-tooltips") {
-
-               /* this doesn't really belong here but it has to go somewhere */
-
-               if (UIConfiguration::instance().get_use_tooltips()) {
-                       Gtkmm2ext::enable_tooltips ();
-               } else {
-                       Gtkmm2ext::disable_tooltips ();
-               }
        } else if (p == "skip-playback") {
                Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("toggle-skip-playback"));
 
@@ -1738,12 +1736,6 @@ Editor::parameter_changed (std::string p)
        }
 }
 
-void
-Editor::reset_focus ()
-{
-       _track_canvas->grab_focus();
-}
-
 void
 Editor::reset_canvas_action_sensitivity (bool onoff)
 {
@@ -1765,272 +1757,188 @@ Editor::register_region_actions ()
        /* PART 1: actions that operate on the selection, and for which the edit point type and location is irrelevant */
 
        /* Remove selected regions */
-       reg_sens (_region_actions, "remove-region", _("Remove"), sigc::mem_fun (*this, &Editor::remove_selected_regions));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "remove-region", _("Remove"), sigc::mem_fun (*this, &Editor::remove_selected_regions));
 
        /* Offer dialogue box to rename the first selected region */
-       reg_sens (_region_actions, "rename-region", _("Rename..."), sigc::mem_fun (*this, &Editor::rename_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "rename-region", _("Rename..."), sigc::mem_fun (*this, &Editor::rename_region));
 
        /* Raise all selected regions by 1 layer */
-       reg_sens (_region_actions, "raise-region", _("Raise"), sigc::mem_fun (*this, &Editor::raise_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "raise-region", _("Raise"), sigc::mem_fun (*this, &Editor::raise_region));
 
        /* Raise all selected regions to the top */
-       reg_sens (_region_actions, "raise-region-to-top", _("Raise to Top"), sigc::mem_fun (*this, &Editor::raise_region_to_top));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "raise-region-to-top", _("Raise to Top"), sigc::mem_fun (*this, &Editor::raise_region_to_top));
 
        /* Lower all selected regions by 1 layer */
-       reg_sens (_region_actions, "lower-region", _("Lower"), sigc::mem_fun (*this, &Editor::lower_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "lower-region", _("Lower"), sigc::mem_fun (*this, &Editor::lower_region));
 
        /* Lower all selected regions to the bottom */
-       reg_sens (_region_actions, "lower-region-to-bottom", _("Lower to Bottom"), sigc::mem_fun (*this, &Editor::lower_region_to_bottom));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "lower-region-to-bottom", _("Lower to Bottom"), sigc::mem_fun (*this, &Editor::lower_region_to_bottom));
 
        /* Move selected regions to their original (`natural') position */
-       reg_sens (_region_actions, "naturalize-region", _("Move to Original Position"), sigc::mem_fun (*this, &Editor::naturalize_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "naturalize-region", _("Move to Original Position"), sigc::mem_fun (*this, &Editor::naturalize_region));
 
        /* Toggle `locked' status of selected regions */
-       toggle_reg_sens (_region_actions, "toggle-region-lock", _("Lock"), sigc::mem_fun(*this, &Editor::toggle_region_lock));
-
-       toggle_reg_sens (_region_actions, "toggle-region-video-lock", _("Lock to Video"), sigc::mem_fun(*this, &Editor::toggle_region_video_lock));
-
-       toggle_reg_sens (
-               _region_actions,
-               "toggle-region-lock-style",
-               _("Glue to Bars and Beats"),
-               sigc::mem_fun (*this, &Editor::toggle_region_lock_style)
-               );
+       register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-lock", _("Lock"), sigc::mem_fun(*this, &Editor::toggle_region_lock));
+       register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-video-lock", _("Lock to Video"), sigc::mem_fun(*this, &Editor::toggle_region_video_lock));
+       register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-lock-style", _("Glue to Bars and Beats"), sigc::mem_fun (*this, &Editor::toggle_region_lock_style));
 
        /* Remove sync points from selected regions */
-       reg_sens (_region_actions, "remove-region-sync", _("Remove Sync"), sigc::mem_fun(*this, &Editor::remove_region_sync));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "remove-region-sync", _("Remove Sync"), sigc::mem_fun(*this, &Editor::remove_region_sync));
 
        /* Mute or unmute selected regions */
-       toggle_reg_sens (_region_actions, "toggle-region-mute", _("Mute"), sigc::mem_fun(*this, &Editor::toggle_region_mute));
+       register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-mute", _("Mute"), sigc::mem_fun(*this, &Editor::toggle_region_mute));
 
        /* Open the normalize dialogue to operate on the selected regions */
-       reg_sens (_region_actions, "normalize-region", _("Normalize..."), sigc::mem_fun(*this, &Editor::normalize_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "normalize-region", _("Normalize..."), sigc::mem_fun(*this, &Editor::normalize_region));
 
        /* Reverse selected regions */
-       reg_sens (_region_actions, "reverse-region", _("Reverse"), sigc::mem_fun (*this, &Editor::reverse_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "reverse-region", _("Reverse"), sigc::mem_fun (*this, &Editor::reverse_region));
 
        /* Split selected multi-channel regions into mono regions */
-       reg_sens (_region_actions, "split-multichannel-region", _("Make Mono Regions"), sigc::mem_fun (*this, &Editor::split_multichannel_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "split-multichannel-region", _("Make Mono Regions"), sigc::mem_fun (*this, &Editor::split_multichannel_region));
 
        /* Boost selected region gain */
-       reg_sens (_region_actions, "boost-region-gain", _("Boost Gain"), sigc::bind (sigc::mem_fun(*this, &Editor::adjust_region_gain), true));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "boost-region-gain", _("Boost Gain"), sigc::bind (sigc::mem_fun(*this, &Editor::adjust_region_gain), true));
 
        /* Cut selected region gain */
-       reg_sens (_region_actions, "cut-region-gain", _("Cut Gain"), sigc::bind (sigc::mem_fun(*this, &Editor::adjust_region_gain), false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "cut-region-gain", _("Cut Gain"), sigc::bind (sigc::mem_fun(*this, &Editor::adjust_region_gain), false));
+
+       /* Reset selected region gain */
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "reset-region-gain", _("Reset Gain"), sigc::mem_fun(*this, &Editor::reset_region_gain));
 
        /* Open the pitch shift dialogue for any selected audio regions */
-       reg_sens (_region_actions, "pitch-shift-region", _("Pitch Shift..."), sigc::mem_fun (*this, &Editor::pitch_shift_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "pitch-shift-region", _("Pitch Shift..."), sigc::mem_fun (*this, &Editor::pitch_shift_region));
 
        /* Open the transpose dialogue for any selected MIDI regions */
-       reg_sens (_region_actions, "transpose-region", _("Transpose..."), sigc::mem_fun (*this, &Editor::transpose_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "transpose-region", _("Transpose..."), sigc::mem_fun (*this, &Editor::transpose_region));
 
        /* Toggle selected region opacity */
-       toggle_reg_sens (_region_actions, "toggle-opaque-region", _("Opaque"), sigc::mem_fun (*this, &Editor::toggle_opaque_region));
+       register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-opaque-region", _("Opaque"), sigc::mem_fun (*this, &Editor::toggle_opaque_region));
 
        /* Toggle active status of selected regions' fade in */
-       toggle_reg_sens (
-               _region_actions, "toggle-region-fade-in", _("Fade In"), sigc::bind (sigc::mem_fun (*this, &Editor::toggle_region_fades), 1)
-               );
+       register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-fade-in", _("Fade In"), sigc::bind (sigc::mem_fun (*this, &Editor::toggle_region_fades), 1));
 
        /* Toggle active status of selected regions' fade out */
-       toggle_reg_sens (
-               _region_actions, "toggle-region-fade-out", _("Fade Out"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_region_fades), -1)
-               );
+       register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-fade-out", _("Fade Out"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_region_fades), -1));
 
        /* Toggle active status of selected regions' fade in and out */
-       toggle_reg_sens (
-               _region_actions, "toggle-region-fades", _("Fades"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_region_fades), 0)
-               );
+       register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-fades", _("Fades"), sigc::bind (sigc::mem_fun(*this, &Editor::toggle_region_fades), 0));
 
        /* Duplicate selected regions */
-       reg_sens (_region_actions, "duplicate-region", _("Duplicate"), sigc::bind (sigc::mem_fun (*this, &Editor::duplicate_range), false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "duplicate-region", _("Duplicate"), sigc::bind (sigc::mem_fun (*this, &Editor::duplicate_regions), 1));
 
        /* Open the dialogue to duplicate selected regions multiple times */
-       reg_sens (
-               _region_actions,
-               "multi-duplicate-region",
-               _("Multi-Duplicate..."),
-               sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_range), true)
-               );
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "multi-duplicate-region", _("Multi-Duplicate..."), sigc::bind (sigc::mem_fun(*this, &Editor::duplicate_range), true));
 
        /* Fill tracks with selected regions */
-       reg_sens (_region_actions, "region-fill-track", _("Fill Track"), sigc::mem_fun (*this, &Editor::region_fill_track));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "region-fill-track", _("Fill Track"), sigc::mem_fun (*this, &Editor::region_fill_track));
 
        /* Set up the loop range from the selected regions */
-       reg_sens (
-               _region_actions, "set-loop-from-region", _("Set Loop Range"), sigc::bind (sigc::mem_fun (*this, &Editor::set_loop_from_region), false)
-               );
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "set-loop-from-region", _("Set Loop Range"), sigc::bind (sigc::mem_fun (*this, &Editor::set_loop_from_region), false));
 
        /* Set up the loop range from the selected regions, and start playback of it */
-       reg_sens (_region_actions, "loop-region", _("Loop"), sigc::bind  (sigc::mem_fun(*this, &Editor::set_loop_from_region), true));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "loop-region", _("Loop"), sigc::bind  (sigc::mem_fun(*this, &Editor::set_loop_from_region), true));
 
        /* Set the punch range from the selected regions */
-       reg_sens (_region_actions, "set-punch-from-region", _("Set Punch"), sigc::mem_fun (*this, &Editor::set_punch_from_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "set-punch-from-region", _("Set Punch"), sigc::mem_fun (*this, &Editor::set_punch_from_region));
 
        /* Add a single range marker around all selected regions */
-       reg_sens (
-               _region_actions, "add-range-marker-from-region", _("Add Single Range Marker"), sigc::mem_fun (*this, &Editor::add_location_from_region)
-               );
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "add-range-marker-from-region", _("Add Single Range Marker"), sigc::mem_fun (*this, &Editor::add_location_from_region));
 
        /* Add a range marker around each selected region */
-       reg_sens (
-               _region_actions, "add-range-markers-from-region", _("Add Range Marker Per Region"), sigc::mem_fun (*this, &Editor::add_locations_from_region)
-               );
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "add-range-markers-from-region", _("Add Range Marker Per Region"), sigc::mem_fun (*this, &Editor::add_locations_from_region));
 
        /* Snap selected regions to the grid */
-       reg_sens (_region_actions, "snap-regions-to-grid", _("Snap Position to Grid"), sigc::mem_fun (*this, &Editor::snap_regions_to_grid));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "snap-regions-to-grid", _("Snap Position to Grid"), sigc::mem_fun (*this, &Editor::snap_regions_to_grid));
 
        /* Close gaps in selected regions */
-       reg_sens (_region_actions, "close-region-gaps", _("Close Gaps"), sigc::mem_fun (*this, &Editor::close_region_gaps));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "close-region-gaps", _("Close Gaps"), sigc::mem_fun (*this, &Editor::close_region_gaps));
 
        /* Open the Rhythm Ferret dialogue for the selected regions */
-       reg_sens (_region_actions, "show-rhythm-ferret", _("Rhythm Ferret..."), sigc::mem_fun (*this, &Editor::show_rhythm_ferret));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "show-rhythm-ferret", _("Rhythm Ferret..."), sigc::mem_fun (*this, &Editor::show_rhythm_ferret));
 
        /* Export the first selected region */
-       reg_sens (_region_actions, "export-region", _("Export..."), sigc::mem_fun (*this, &Editor::export_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "export-region", _("Export..."), sigc::mem_fun (*this, &Editor::export_region));
 
        /* Separate under selected regions: XXX not sure what this does */
-       reg_sens (
-               _region_actions,
-               "separate-under-region",
-               _("Separate Under"),
-               sigc::mem_fun (*this, &Editor::separate_under_selected_regions)
-               );
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "separate-under-region", _("Separate Under"), sigc::mem_fun (*this, &Editor::separate_under_selected_regions));
 
-       reg_sens (_region_actions, "set-fade-in-length", _("Set Fade In Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), true));
-       reg_sens (_region_actions, "alternate-set-fade-in-length", _("Set Fade In Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), true));
-       reg_sens (_region_actions, "set-fade-out-length", _("Set Fade Out Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), false));
-       reg_sens (_region_actions, "alternate-set-fade-out-length", _("Set Fade Out Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "set-fade-in-length", _("Set Fade In Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), true));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "alternate-set-fade-in-length", _("Set Fade In Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), true));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "set-fade-out-length", _("Set Fade Out Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "alternate-set-fade-out-length", _("Set Fade Out Length"), sigc::bind (sigc::mem_fun (*this, &Editor::set_fade_length), false));
 
-       reg_sens (_region_actions, "set-tempo-from-region", _("Set Tempo from Region = Bar"), sigc::mem_fun (*this, &Editor::set_tempo_from_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "set-tempo-from-region", _("Set Tempo from Region = Bar"), sigc::mem_fun (*this, &Editor::set_tempo_from_region));
 
-       reg_sens (
-               _region_actions,
-               "split-region-at-transients",
-               _("Split at Percussion Onsets"),
-               sigc::mem_fun(*this, &Editor::split_region_at_transients)
-               );
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "split-region-at-transients", _("Split at Percussion Onsets"), sigc::mem_fun(*this, &Editor::split_region_at_transients));
 
        /* Open the list editor dialogue for the selected regions */
-       reg_sens (_region_actions, "show-region-list-editor", _("List Editor..."), sigc::mem_fun (*this, &Editor::show_midi_list_editor));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "show-region-list-editor", _("List Editor..."), sigc::mem_fun (*this, &Editor::show_midi_list_editor));
 
        /* Open the region properties dialogue for the selected regions */
-       reg_sens (_region_actions, "show-region-properties", _("Properties..."), sigc::mem_fun (*this, &Editor::show_region_properties));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "show-region-properties", _("Properties..."), sigc::mem_fun (*this, &Editor::show_region_properties));
 
-       reg_sens (_region_actions, "play-selected-regions", _("Play"), sigc::mem_fun(*this, &Editor::play_selected_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "play-selected-regions", _("Play selected Regions"), sigc::mem_fun(*this, &Editor::play_selected_region));
 
-       reg_sens (_region_actions, "bounce-regions-processed", _("Bounce (with processing)"), (sigc::bind (sigc::mem_fun (*this, &Editor::bounce_region_selection), true)));
-       reg_sens (_region_actions, "bounce-regions-unprocessed", _("Bounce (without processing)"), (sigc::bind (sigc::mem_fun (*this, &Editor::bounce_region_selection), false)));
-       reg_sens (_region_actions, "combine-regions", _("Combine"), sigc::mem_fun (*this, &Editor::combine_regions));
-       reg_sens (_region_actions, "uncombine-regions", _("Uncombine"), sigc::mem_fun (*this, &Editor::uncombine_regions));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "bounce-regions-processed", _("Bounce (with processing)"), (sigc::bind (sigc::mem_fun (*this, &Editor::bounce_region_selection), true)));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "bounce-regions-unprocessed", _("Bounce (without processing)"), (sigc::bind (sigc::mem_fun (*this, &Editor::bounce_region_selection), false)));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "combine-regions", _("Combine"), sigc::mem_fun (*this, &Editor::combine_regions));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "uncombine-regions", _("Uncombine"), sigc::mem_fun (*this, &Editor::uncombine_regions));
 
-       reg_sens (_region_actions, "analyze-region", _("Spectral Analysis..."), sigc::mem_fun (*this, &Editor::analyze_region_selection));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "loudness-analyze-region", _("Loudness Analysis..."), sigc::mem_fun (*this, &Editor::loudness_analyze_region_selection));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "spectral-analyze-region", _("Spectral Analysis..."), sigc::mem_fun (*this, &Editor::spectral_analyze_region_selection));
 
-       reg_sens (_region_actions, "reset-region-gain-envelopes", _("Reset Envelope"), sigc::mem_fun (*this, &Editor::reset_region_gain_envelopes));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "reset-region-gain-envelopes", _("Reset Envelope"), sigc::mem_fun (*this, &Editor::reset_region_gain_envelopes));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "reset-region-scale-amplitude", _("Reset Gain"), sigc::mem_fun (*this, &Editor::reset_region_scale_amplitude));
 
-       reg_sens (_region_actions, "reset-region-scale-amplitude", _("Reset Gain"), sigc::mem_fun (*this, &Editor::reset_region_scale_amplitude));
+       register_toggle_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "toggle-region-gain-envelope-active", _("Envelope Active"), sigc::mem_fun (*this, &Editor::toggle_gain_envelope_active));
 
-       toggle_reg_sens (
-               _region_actions,
-               "toggle-region-gain-envelope-active",
-               _("Envelope Active"),
-               sigc::mem_fun (*this, &Editor::toggle_gain_envelope_active)
-               );
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "quantize-region", _("Quantize..."), sigc::mem_fun (*this, &Editor::quantize_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "legatize-region", _("Legatize"), sigc::bind(sigc::mem_fun (*this, &Editor::legatize_region), false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "transform-region", _("Transform..."), sigc::mem_fun (*this, &Editor::transform_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "remove-overlap", _("Remove Overlap"), sigc::bind(sigc::mem_fun (*this, &Editor::legatize_region), true));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "insert-patch-change", _("Insert Patch Change..."), sigc::bind (sigc::mem_fun (*this, &Editor::insert_patch_change), false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "insert-patch-change-context", _("Insert Patch Change..."), sigc::bind (sigc::mem_fun (*this, &Editor::insert_patch_change), true));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "fork-region", _("Unlink from other copies"), sigc::mem_fun (*this, &Editor::fork_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "strip-region-silence", _("Strip Silence..."), sigc::mem_fun (*this, &Editor::strip_region_silence));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions), "set-selection-from-region", _("Set Range Selection"), sigc::mem_fun (*this, &Editor::set_selection_from_region));
 
-       reg_sens (_region_actions, "quantize-region", _("Quantize..."), sigc::mem_fun (*this, &Editor::quantize_region));
-       reg_sens (_region_actions, "legatize-region", _("Legatize"), sigc::bind(sigc::mem_fun (*this, &Editor::legatize_region), false));
-       reg_sens (_region_actions, "transform-region", _("Transform..."), sigc::mem_fun (*this, &Editor::transform_region));
-       reg_sens (_region_actions, "remove-overlap", _("Remove Overlap"), sigc::bind(sigc::mem_fun (*this, &Editor::legatize_region), true));
-       reg_sens (_region_actions, "insert-patch-change", _("Insert Patch Change..."), sigc::bind (sigc::mem_fun (*this, &Editor::insert_patch_change), false));
-       reg_sens (_region_actions, "insert-patch-change-context", _("Insert Patch Change..."), sigc::bind (sigc::mem_fun (*this, &Editor::insert_patch_change), true));
-       reg_sens (_region_actions, "fork-region", _("Unlink from other copies"), sigc::mem_fun (*this, &Editor::fork_region));
-       reg_sens (_region_actions, "strip-region-silence", _("Strip Silence..."), sigc::mem_fun (*this, &Editor::strip_region_silence));
-       reg_sens (_region_actions, "set-selection-from-region", _("Set Range Selection"), sigc::mem_fun (*this, &Editor::set_selection_from_region));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "nudge-forward", _("Nudge Later"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_forward), false, false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "alternate-nudge-forward", _("Nudge Later"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_forward), false, false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "nudge-backward", _("Nudge Earlier"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_backward), false, false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "alternate-nudge-backward", _("Nudge Earlier"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_backward), false, false));
 
-       reg_sens (_region_actions, "nudge-forward", _("Nudge Later"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_forward), false, false));
-       reg_sens (_region_actions, "alternate-nudge-forward", _("Nudge Later"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_forward), false, false));
-       reg_sens (_region_actions, "nudge-backward", _("Nudge Earlier"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_backward), false, false));
-       reg_sens (_region_actions, "alternate-nudge-backward", _("Nudge Earlier"), sigc::bind (sigc::mem_fun (*this, &Editor::nudge_backward), false, false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "sequence-regions", _("Sequence Regions"), sigc::mem_fun (*this, &Editor::sequence_regions));
 
-       reg_sens (_region_actions, "sequence-regions", _("Sequence Regions"), sigc::mem_fun (*this, &Editor::sequence_regions));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "nudge-forward-by-capture-offset", _("Nudge Later by Capture Offset"), sigc::mem_fun (*this, &Editor::nudge_forward_capture_offset));
 
-       reg_sens (
-               _region_actions,
-               "nudge-forward-by-capture-offset",
-               _("Nudge Later by Capture Offset"),
-               sigc::mem_fun (*this, &Editor::nudge_forward_capture_offset)
-               );
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "nudge-backward-by-capture-offset", _("Nudge Earlier by Capture Offset"), sigc::mem_fun (*this, &Editor::nudge_backward_capture_offset));
 
-       reg_sens (
-               _region_actions,
-               "nudge-backward-by-capture-offset",
-               _("Nudge Earlier by Capture Offset"),
-               sigc::mem_fun (*this, &Editor::nudge_backward_capture_offset)
-               );
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "trim-region-to-loop", _("Trim to Loop"), sigc::mem_fun (*this, &Editor::trim_region_to_loop));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "trim-region-to-punch", _("Trim to Punch"), sigc::mem_fun (*this, &Editor::trim_region_to_punch));
 
-       reg_sens (_region_actions, "trim-region-to-loop", _("Trim to Loop"), sigc::mem_fun (*this, &Editor::trim_region_to_loop));
-       reg_sens (_region_actions, "trim-region-to-punch", _("Trim to Punch"), sigc::mem_fun (*this, &Editor::trim_region_to_punch));
-
-       reg_sens (_region_actions, "trim-to-previous-region", _("Trim to Previous"), sigc::mem_fun(*this, &Editor::trim_region_to_previous_region_end));
-       reg_sens (_region_actions, "trim-to-next-region", _("Trim to Next"), sigc::mem_fun(*this, &Editor::trim_region_to_next_region_start));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "trim-to-previous-region", _("Trim to Previous"), sigc::mem_fun(*this, &Editor::trim_region_to_previous_region_end));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EnteredRegions), "trim-to-next-region", _("Trim to Next"), sigc::mem_fun(*this, &Editor::trim_region_to_next_region_start));
 
        /* PART 2: actions that are not related to the selection, but for which the edit point type and location is important */
 
-       reg_sens (
-               _region_actions,
-               "insert-region-from-region-list",
-               _("Insert Region from Region List"),
-               sigc::bind (sigc::mem_fun (*this, &Editor::insert_region_list_selection), 1)
-               );
+       register_region_action (_region_actions, RegionActionTarget (ListSelection), "insert-region-from-region-list", _("Insert Region from Region List"), sigc::bind (sigc::mem_fun (*this, &Editor::insert_region_list_selection), 1));
 
        /* PART 3: actions that operate on the selection and also require the edit point location */
 
-       reg_sens (_region_actions, "set-region-sync-position", _("Set Sync Position"), sigc::mem_fun (*this, &Editor::set_region_sync_position));
-       reg_sens (_region_actions, "place-transient", _("Place Transient"), sigc::mem_fun (*this, &Editor::place_transient));
-       reg_sens (_region_actions, "split-region", _("Split/Separate"), sigc::mem_fun (*this, &Editor::split_region));
-       reg_sens (_region_actions, "trim-front", _("Trim Start at Edit Point"), sigc::mem_fun (*this, &Editor::trim_region_front));
-       reg_sens (_region_actions, "trim-back", _("Trim End at Edit Point"), sigc::mem_fun (*this, &Editor::trim_region_back));
-
-       reg_sens (
-               _region_actions,
-               "align-regions-start",
-               _("Align Start"),
-               sigc::bind (sigc::mem_fun(*this, &Editor::align_regions), ARDOUR::Start)
-               );
-
-       reg_sens (
-               _region_actions,
-               "align-regions-start-relative",
-               _("Align Start Relative"),
-               sigc::bind (sigc::mem_fun (*this, &Editor::align_regions_relative), ARDOUR::Start)
-               );
-
-       reg_sens (_region_actions, "align-regions-end", _("Align End"), sigc::bind (sigc::mem_fun (*this, &Editor::align_regions), ARDOUR::End));
-
-       reg_sens (
-               _region_actions,
-               "align-regions-end-relative",
-               _("Align End Relative"),
-               sigc::bind (sigc::mem_fun(*this, &Editor::align_regions_relative), ARDOUR::End)
-               );
-
-       reg_sens (
-               _region_actions,
-               "align-regions-sync",
-               _("Align Sync"),
-               sigc::bind (sigc::mem_fun(*this, &Editor::align_regions), ARDOUR::SyncPoint)
-               );
-
-       reg_sens (
-               _region_actions,
-               "align-regions-sync-relative",
-               _("Align Sync Relative"),
-               sigc::bind (sigc::mem_fun (*this, &Editor::align_regions_relative), ARDOUR::SyncPoint)
-               );
-
-       reg_sens (_region_actions, "choose-top-region", _("Choose Top..."), sigc::bind (sigc::mem_fun (*this, &Editor::change_region_layering_order), false));
-       reg_sens (_region_actions, "choose-top-region-context-menu", _("Choose Top..."), sigc::bind (sigc::mem_fun (*this, &Editor::change_region_layering_order), true));
-
-       _all_region_actions_sensitized = true;
-
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "set-region-sync-position", _("Set Sync Position"), sigc::mem_fun (*this, &Editor::set_region_sync_position));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "place-transient", _("Place Transient"), sigc::mem_fun (*this, &Editor::place_transient));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "trim-front", _("Trim Start at Edit Point"), sigc::mem_fun (*this, &Editor::trim_region_front));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "trim-back", _("Trim End at Edit Point"), sigc::mem_fun (*this, &Editor::trim_region_back));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "align-regions-start", _("Align Start"), sigc::bind (sigc::mem_fun(*this, &Editor::align_regions), ARDOUR::Start));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "align-regions-start-relative", _("Align Start Relative"), sigc::bind (sigc::mem_fun (*this, &Editor::align_regions_relative), ARDOUR::Start));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "align-regions-end", _("Align End"), sigc::bind (sigc::mem_fun (*this, &Editor::align_regions), ARDOUR::End));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "align-regions-end-relative", _("Align End Relative"), sigc::bind (sigc::mem_fun(*this, &Editor::align_regions_relative), ARDOUR::End));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "align-regions-sync", _("Align Sync"), sigc::bind (sigc::mem_fun(*this, &Editor::align_regions), ARDOUR::SyncPoint));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "align-regions-sync-relative", _("Align Sync Relative"), sigc::bind (sigc::mem_fun (*this, &Editor::align_regions_relative), ARDOUR::SyncPoint));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "choose-top-region", _("Choose Top..."), sigc::bind (sigc::mem_fun (*this, &Editor::change_region_layering_order), false));
+       register_region_action (_region_actions, RegionActionTarget (SelectedRegions|EditPointRegions), "choose-top-region-context-menu", _("Choose Top..."), sigc::bind (sigc::mem_fun (*this, &Editor::change_region_layering_order), true));
+
+       /* desensitize them all by default. region selection will change this */
+       sensitize_all_region_actions (false);
 }