Don't add auditioner and click to MIDI connection port matrices.
[ardour.git] / gtk2_ardour / editor.cc
index 93a69de8c3017b22c097cdb32f03536e9c08e9a0..c9c309c6c545a51fd682b322aa288563ea713ac3 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000-2007 Paul Davis 
+    Copyright (C) 2000-2009 Paul Davis 
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
@@ -36,6 +36,7 @@
 #include "pbd/error.h"
 #include "pbd/enumwriter.h"
 #include "pbd/memento_command.h"
+#include "pbd/unknown_type.h"
 
 #include <glibmm/miscutils.h>
 #include <gtkmm/image.h>
 #include "editor_drag.h"
 #include "editor_group_tabs.h"
 #include "automation_time_axis.h"
+#include "editor_routes.h"
+#include "midi_time_axis.h"
+#include "mixer_strip.h"
+#include "editor_route_groups.h"
+#include "editor_regions.h"
+#include "editor_snapshots.h"
 
 #include "i18n.h"
 
@@ -204,50 +211,47 @@ show_me_the_size (Requisition* r, const char* what)
 }
 
 Editor::Editor ()
-       : 
          /* time display buttons */
-
-         minsec_label (_("Mins:Secs")),
-         bbt_label (_("Bars:Beats")),
-         smpte_label (_("Timecode")),
-         frame_label (_("Samples")),
-         tempo_label (_("Tempo")),
-         meter_label (_("Meter")),
-         mark_label (_("Location Markers")),
-         range_mark_label (_("Range Markers")),
-         transport_mark_label (_("Loop/Punch Ranges")),
-         cd_mark_label (_("CD Markers")),
-         edit_packer (4, 4, true),
+       : minsec_label (_("Mins:Secs"))
+       , bbt_label (_("Bars:Beats"))
+       , smpte_label (_("Timecode"))
+       , frame_label (_("Samples"))
+       , tempo_label (_("Tempo"))
+       , meter_label (_("Meter"))
+       , mark_label (_("Location Markers"))
+       , range_mark_label (_("Range Markers"))
+       , transport_mark_label (_("Loop/Punch Ranges"))
+       , cd_mark_label (_("CD Markers"))
+       , edit_packer (4, 4, true)
 
          /* the values here don't matter: layout widgets
             reset them as needed.
          */
-
-         vertical_adjustment (0.0, 0.0, 10.0, 400.0),
-         horizontal_adjustment (0.0, 0.0, 20.0, 1200.0),
-
+         
+       , vertical_adjustment (0.0, 0.0, 10.0, 400.0)
+       , horizontal_adjustment (0.0, 0.0, 20.0, 1200.0)
+         
          /* tool bar related */
 
-         edit_point_clock (X_("editpoint"), false, X_("EditPointClock"), true),
-         zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true),
+       , edit_point_clock (X_("editpoint"), false, X_("EditPointClock"), true)
+       , zoom_range_clock (X_("zoomrange"), false, X_("ZoomRangeClock"), true, true)
          
-         toolbar_selection_clock_table (2,3),
+       , toolbar_selection_clock_table (2,3)
+         
+       , automation_mode_button (_("mode"))
+       , global_automation_button (_("automation"))
+         
+       , midi_panic_button (_("Panic"))
          
-         automation_mode_button (_("mode")),
-         global_automation_button (_("automation")),
-
-         midi_panic_button (_("Panic")),
-         midi_tools_tearoff (0),
-
 #ifdef WITH_CMT
-         image_socket_listener(0),
+       , image_socket_listener(0)
 #endif
-
+         
          /* nudge */
-
-         nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true),
-         meters_running(false),
-         _pending_locate_request (false)
+         
+       , nudge_clock (X_("nudge"), false, X_("NudgeClock"), true, true)
+       , meters_running(false)
+       , _pending_locate_request (false)
 
 {
        constructed = false;
@@ -298,24 +302,16 @@ Editor::Editor ()
        _show_measures = true;
        _show_waveforms_recording = true;
        show_gain_after_trim = false;
-       route_redisplay_does_not_sync_order_keys = false;
-       route_redisplay_does_not_reset_order_keys = false;
-       no_route_list_redisplay = false;
        verbose_cursor_on = true;
        route_removal = false;
-       show_automatic_regions_in_region_list = true;
        last_item_entered = 0;
        last_item_entered_n = 0;
 
-       region_list_sort_type = (Editing::RegionListSortType) 0;
        have_pending_keyboard_selection = false;
        _follow_playhead = true;
        _xfade_visibility = true;
        editor_ruler_menu = 0;
        no_ruler_shown_update = false;
-       route_group_menu = 0;
-       route_list_menu = 0;
-       region_list_menu = 0;
        marker_menu = 0;
        start_end_marker_menu = 0;
        range_marker_menu = 0;
@@ -329,8 +325,6 @@ Editor::Editor ()
        region_edit_menu_split_item = 0;
        temp_location = 0;
        leftmost_frame = 0;
-       ignore_mouse_mode_toggle = false;
-       ignore_midi_edit_mode_toggle = false;
        current_stepping_trackview = 0;
        entered_track = 0;
        entered_regionview = 0;
@@ -338,7 +332,6 @@ Editor::Editor ()
        clear_entered_track = false;
        _new_regionviews_show_envelope = false;
        current_timefx = 0;
-       in_route_group_row_change = false;
        playhead_cursor = 0;
        button_release_can_deselect = true;
        _dragging_playhead = false;
@@ -353,7 +346,6 @@ Editor::Editor ()
        }
        allow_vertical_scroll = false;
        no_save_visual = false;
-       no_region_list_redisplay = false;
        resize_idle_id = -1;
 
        scrubbing_direction = 0;
@@ -366,9 +358,9 @@ Editor::Editor ()
        location_loop_color = ARDOUR_UI::config()->canvasvar_LocationLoop.get();
        location_punch_color = ARDOUR_UI::config()->canvasvar_LocationPunch.get();
 
-       set_midi_edit_mode (MidiEditPencil, true);
        _edit_point = EditAtMouse;
-       set_mouse_mode (MouseObject, true);
+       _internal_editing = false;
+       current_canvas_cursor = 0;
 
        frames_per_unit = 2048; /* too early to use reset_zoom () */
        reset_hscrollbar_stepping ();
@@ -531,183 +523,11 @@ Editor::Editor ()
        bottom_hbox.set_border_width (2);
        bottom_hbox.set_spacing (3);
 
+       _route_groups = new EditorRouteGroups (this);
+       _routes = new EditorRoutes (this);
+       _regions = new EditorRegions (this);
+       _snapshots = new EditorSnapshots (this);
 
-       CellRendererPixbufToggle* rec_col_renderer = Gtk::manage( new CellRendererPixbufToggle() );
-
-       rec_col_renderer->set_active_pixbuf(::get_icon("record_normal_red"));
-       rec_col_renderer->set_inactive_pixbuf(::get_icon("record_disabled_grey"));
-
-       rec_col_renderer->signal_toggled().connect(mem_fun(*this, &Editor::on_tv_rec_enable_toggled));
-
-       Gtk::TreeViewColumn* rec_state_column = Gtk::manage(new Gtk::TreeViewColumn("Rec", *rec_col_renderer));
-       rec_state_column->add_attribute(rec_col_renderer->property_active(), route_display_columns.rec_enabled);
-       rec_state_column->add_attribute(rec_col_renderer->property_visible(), route_display_columns.is_track);
-
-       route_display_model = ListStore::create(route_display_columns);
-       route_list_display.set_model (route_display_model);
-       
-       route_list_display.append_column (*rec_state_column);
-       route_list_display.append_column (_("Show"), route_display_columns.visible);
-       route_list_display.append_column (_("Name"), route_display_columns.text);
-       
-       route_list_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
-       route_list_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
-       route_list_display.get_column (2)->set_data (X_("colnum"), GUINT_TO_POINTER(2));
-       
-       route_list_display.set_headers_visible (true);
-       route_list_display.set_name ("TrackListDisplay");
-       route_list_display.get_selection()->set_mode (SELECTION_NONE);
-       route_list_display.set_reorderable (true);
-       route_list_display.set_size_request (100,-1);
-       route_list_display.add_object_drag (route_display_columns.route.index(), "routes");
-
-       CellRendererToggle* route_list_visible_cell = dynamic_cast<CellRendererToggle*>(route_list_display.get_column_cell_renderer (1));
-       
-       route_list_visible_cell->property_activatable() = true;
-       route_list_visible_cell->property_radio() = false;
-
-       route_display_model->signal_row_deleted().connect (mem_fun (*this, &Editor::route_list_delete));
-       route_display_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_list_change));
-       route_display_model->signal_rows_reordered().connect (mem_fun (*this, &Editor::route_list_reordered));
-
-       route_list_display.signal_button_press_event().connect (mem_fun (*this, &Editor::route_list_display_button_press), false);
-
-       route_list_scroller.add (route_list_display);
-       route_list_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
-
-       group_model = ListStore::create(group_columns);
-       route_group_display.set_model (group_model);
-       route_group_display.append_column (_("Name"), group_columns.text);
-       route_group_display.append_column (_("Show"), group_columns.is_visible);
-       route_group_display.get_column (0)->set_data (X_("colnum"), GUINT_TO_POINTER(0));
-       route_group_display.get_column (1)->set_data (X_("colnum"), GUINT_TO_POINTER(1));
-       route_group_display.get_column (0)->set_expand (true);
-       route_group_display.get_column (1)->set_expand (false);
-       route_group_display.set_headers_visible (true);
-
-       /* name is directly editable */
-
-       CellRendererText* name_cell = dynamic_cast<CellRendererText*>(route_group_display.get_column_cell_renderer (0));
-       name_cell->property_editable() = true;
-       name_cell->signal_edited().connect (mem_fun (*this, &Editor::route_group_name_edit));
-
-       /* use checkbox for the active + visible columns */
-
-       CellRendererToggle* active_cell = dynamic_cast<CellRendererToggle*>(route_group_display.get_column_cell_renderer (1));
-       active_cell->property_activatable() = true;
-       active_cell->property_radio() = false;
-
-       active_cell = dynamic_cast<CellRendererToggle*>(route_group_display.get_column_cell_renderer (1));
-       active_cell->property_activatable() = true;
-       active_cell->property_radio() = false;
-
-       group_model->signal_row_changed().connect (mem_fun (*this, &Editor::route_group_row_change));
-
-       route_group_display.set_name ("EditGroupList");
-       route_group_display.get_selection()->set_mode (SELECTION_SINGLE);
-       route_group_display.set_headers_visible (true);
-       route_group_display.set_reorderable (false);
-       route_group_display.set_rules_hint (true);
-       route_group_display.set_size_request (75, -1);
-
-       route_group_display_scroller.add (route_group_display);
-       route_group_display_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
-
-       route_group_display.signal_button_press_event().connect (mem_fun(*this, &Editor::route_group_list_button_press_event), false);
-
-       VBox* route_group_display_packer = manage (new VBox());
-       HBox* route_group_display_button_box = manage (new HBox());
-       route_group_display_button_box->set_homogeneous (true);
-
-       Button* route_group_add_button = manage (new Button ());
-       Button* route_group_remove_button = manage (new Button ());
-
-       Widget* w;
-
-       w = manage (new Image (Stock::ADD, ICON_SIZE_BUTTON));
-       w->show();
-       route_group_add_button->add (*w);
-
-       w = manage (new Image (Stock::REMOVE, ICON_SIZE_BUTTON));
-       w->show();
-       route_group_remove_button->add (*w);
-
-       route_group_add_button->signal_clicked().connect (mem_fun (*this, &Editor::new_route_group));
-       route_group_remove_button->signal_clicked().connect (mem_fun (*this, &Editor::remove_selected_route_group));
-       
-       route_group_display_button_box->pack_start (*route_group_add_button);
-       route_group_display_button_box->pack_start (*route_group_remove_button);
-
-       route_group_display_packer->pack_start (route_group_display_scroller, true, true);
-       route_group_display_packer->pack_start (*route_group_display_button_box, false, false);
-
-       region_list_display.set_size_request (100, -1);
-       region_list_display.set_name ("RegionListDisplay");
-       /* Try to prevent single mouse presses from initiating edits.
-          This relies on a hack in gtktreeview.c:gtk_treeview_button_press()
-       */
-       region_list_display.set_data ("mouse-edits-require-mod1", (gpointer) 0x1);
-
-       region_list_model = TreeStore::create (region_list_columns);
-       region_list_model->set_sort_func (0, mem_fun (*this, &Editor::region_list_sorter));
-       region_list_model->set_sort_column (0, SORT_ASCENDING);
-
-       region_list_display.set_model (region_list_model);
-       region_list_display.append_column (_("Regions"), region_list_columns.name);
-       region_list_display.append_column (_("Start"), region_list_columns.start);
-       region_list_display.append_column (_("End"), region_list_columns.end);
-       region_list_display.append_column (_("Length"), region_list_columns.length);
-       region_list_display.append_column (_("Sync"), region_list_columns.sync);
-       region_list_display.append_column (_("Fade In"), region_list_columns.fadein);
-       region_list_display.append_column (_("Fade Out"), region_list_columns.fadeout);
-       region_list_display.append_column (_("L"), region_list_columns.locked);
-       region_list_display.append_column (_("G"), region_list_columns.glued);
-       region_list_display.append_column (_("M"), region_list_columns.muted);
-       region_list_display.append_column (_("O"), region_list_columns.opaque);
-       region_list_display.append_column (_("Used"), region_list_columns.used);
-       region_list_display.append_column (_("Path"), region_list_columns.path);
-       region_list_display.set_headers_visible (true);
-       //region_list_display.set_grid_lines (TREE_VIEW_GRID_LINES_BOTH);
-       
-       CellRendererText* region_name_cell = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
-       region_name_cell->property_editable() = true;
-       region_name_cell->signal_edited().connect (mem_fun (*this, &Editor::region_name_edit));
-
-       region_list_display.get_selection()->set_select_function (mem_fun (*this, &Editor::region_list_selection_filter));
-       
-       TreeViewColumn* tv_col = region_list_display.get_column(0);
-       CellRendererText* renderer = dynamic_cast<CellRendererText*>(region_list_display.get_column_cell_renderer (0));
-       tv_col->add_attribute(renderer->property_text(), region_list_columns.name);
-       tv_col->add_attribute(renderer->property_foreground_gdk(), region_list_columns.color_);
-       
-       region_list_display.get_selection()->set_mode (SELECTION_MULTIPLE);
-       region_list_display.add_object_drag (region_list_columns.region.index(), "regions");
-       
-       /* setup DnD handling */
-       
-       list<TargetEntry> region_list_target_table;
-       
-       region_list_target_table.push_back (TargetEntry ("text/plain"));
-       region_list_target_table.push_back (TargetEntry ("text/uri-list"));
-       region_list_target_table.push_back (TargetEntry ("application/x-rootwin-drop"));
-       
-       region_list_display.add_drop_targets (region_list_target_table);
-       region_list_display.signal_drag_data_received().connect (mem_fun(*this, &Editor::region_list_display_drag_data_received));
-
-       region_list_scroller.add (region_list_display);
-       region_list_scroller.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
-       
-       region_list_display.signal_key_press_event().connect (mem_fun(*this, &Editor::region_list_display_key_press));
-       region_list_display.signal_key_release_event().connect (mem_fun(*this, &Editor::region_list_display_key_release));
-       region_list_display.signal_button_press_event().connect (mem_fun(*this, &Editor::region_list_display_button_press), false);
-       region_list_display.signal_button_release_event().connect (mem_fun(*this, &Editor::region_list_display_button_release));
-       region_list_change_connection = region_list_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::region_list_selection_changed));
-       // region_list_display.signal_popup_menu().connect (bind (mem_fun (*this, &Editor::show_region_list_display_context_menu), 1, 0));
-       
-       //ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (mem_fun(*this, &Editor::redisplay_regions));
-       ARDOUR_UI::instance()->secondary_clock.mode_changed.connect (mem_fun(*this, &Editor::update_all_region_rows));
-       ARDOUR::Region::RegionPropertyChanged.connect (mem_fun(*this, &Editor::update_region_row));
-       
        named_selection_scroller.add (named_selection_display);
        named_selection_scroller.set_policy (POLICY_NEVER, POLICY_AUTOMATIC);
 
@@ -724,35 +544,20 @@ Editor::Editor ()
        named_selection_display.signal_key_release_event().connect (mem_fun(*this, &Editor::named_selection_display_key_release), false);
        named_selection_display.get_selection()->signal_changed().connect (mem_fun (*this, &Editor::named_selection_display_selection_changed));
 
-       /* SNAPSHOTS */
-
-       snapshot_display_model = ListStore::create (snapshot_display_columns);
-       snapshot_display.set_model (snapshot_display_model);
-       snapshot_display.append_column (X_("snapshot"), snapshot_display_columns.visible_name);
-       snapshot_display.set_name ("SnapshotDisplay");
-       snapshot_display.set_size_request (75, -1);
-       snapshot_display.set_headers_visible (false);
-       snapshot_display.set_reorderable (false);
-       snapshot_display_scroller.add (snapshot_display);
-       snapshot_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
-
-       snapshot_display.get_selection()->signal_changed().connect (mem_fun(*this, &Editor::snapshot_display_selection_changed));
-       snapshot_display.signal_button_press_event().connect (mem_fun (*this, &Editor::snapshot_display_button_press), false);
-
        Gtk::Label* nlabel;
 
        nlabel = manage (new Label (_("Regions")));
        nlabel->set_angle (-90);
-       the_notebook.append_page (region_list_scroller, *nlabel);
+       the_notebook.append_page (_regions->widget (), *nlabel);
        nlabel = manage (new Label (_("Tracks/Busses")));
        nlabel->set_angle (-90);
-       the_notebook.append_page (route_list_scroller, *nlabel);
+       the_notebook.append_page (_routes->widget (), *nlabel);
        nlabel = manage (new Label (_("Snapshots")));
        nlabel->set_angle (-90);
-       the_notebook.append_page (snapshot_display_scroller, *nlabel);
+       the_notebook.append_page (_snapshots->widget (), *nlabel);
        nlabel = manage (new Label (_("Route Groups")));
        nlabel->set_angle (-90);
-       the_notebook.append_page (*route_group_display_packer, *nlabel);
+       the_notebook.append_page (_route_groups->widget (), *nlabel);
        
        if (!Profile->get_sae()) {
                nlabel = manage (new Label (_("Chunks")));
@@ -779,7 +584,6 @@ Editor::Editor ()
        edit_pane.signal_size_allocate().connect (bind (mem_fun(*this, &Editor::pane_allocation_handler), static_cast<Paned*> (&edit_pane)));
 
        top_hbox.pack_start (toolbar_frame, false, true);
-       top_hbox.pack_start (midi_toolbar_frame, false, true);
 
        HBox *hbox = manage (new HBox);
        hbox->pack_start (edit_pane, true, true);
@@ -805,6 +609,7 @@ Editor::Editor ()
        set_snap_to (snap_type);
        snap_mode = SnapOff;
        set_snap_mode (snap_mode);
+       set_mouse_mode (MouseObject, true);
        set_edit_point_preference (EditAtMouse, true);
 
        XMLNode* node = ARDOUR_UI::instance()->editor_settings();
@@ -870,7 +675,6 @@ Editor::Editor ()
        BasicUI::AccessAction.connect (mem_fun (*this, &Editor::access_action));
 
        Config->ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed));
-       Route::SyncOrderKeys.connect (mem_fun (*this, &Editor::sync_order_keys));
 
        _last_normalization_value = 0;
 
@@ -892,25 +696,12 @@ Editor::~Editor()
        }
 #endif
 
+       delete _routes;
+       delete _route_groups;
        delete track_canvas;
        delete _drag;
 }
 
-void 
-Editor::on_tv_rec_enable_toggled(const Glib::ustring& path_string){
-
-       // Get the model row that has been toggled.
-       Gtk::TreeModel::Row row = *route_display_model->get_iter(Gtk::TreeModel::Path(path_string));
-
-       TimeAxisView *tv = row[route_display_columns.tv];
-       AudioTimeAxisView *atv = dynamic_cast<AudioTimeAxisView*> (tv);
-
-       if(atv != 0 && atv->is_audio_track()){
-             atv->get_diskstream()->set_record_enabled(!atv->get_diskstream()->record_enabled());
-       }
-}
-
-
 void
 Editor::add_toplevel_controls (Container& cont)
 {
@@ -1115,7 +906,7 @@ Editor::control_scroll (float fraction)
 }
 
 bool
-Editor::deferred_control_scroll (nframes64_t target)
+Editor::deferred_control_scroll (nframes64_t /*target*/)
 {
        session->request_locate (*_control_scroll_target, session->transport_rolling());
        // reset for next stream
@@ -1288,17 +1079,12 @@ Editor::connect_to_session (Session *t)
        session_connections.push_back (session->TransportStateChange.connect (mem_fun(*this, &Editor::map_transport_state)));
        session_connections.push_back (session->PositionChanged.connect (mem_fun(*this, &Editor::map_position_change)));
        session_connections.push_back (session->RouteAdded.connect (mem_fun(*this, &Editor::handle_new_route)));
-       session_connections.push_back (session->RegionsAdded.connect (mem_fun(*this, &Editor::handle_new_regions)));
-       session_connections.push_back (session->RegionRemoved.connect (mem_fun(*this, &Editor::handle_region_removed)));
        session_connections.push_back (session->DurationChanged.connect (mem_fun(*this, &Editor::handle_new_duration)));
-       session_connections.push_back (session->route_group_added.connect (mem_fun(*this, &Editor::add_route_group)));
-       session_connections.push_back (session->route_group_removed.connect (mem_fun(*this, &Editor::route_groups_changed)));
        session_connections.push_back (session->NamedSelectionAdded.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
        session_connections.push_back (session->NamedSelectionRemoved.connect (mem_fun(*this, &Editor::handle_new_named_selection)));
        session_connections.push_back (session->DirtyChanged.connect (mem_fun(*this, &Editor::update_title)));
        session_connections.push_back (session->StateSaved.connect (mem_fun(*this, &Editor::update_title_s)));
        session_connections.push_back (session->AskAboutPlaylistDeletion.connect (mem_fun(*this, &Editor::playlist_deletion_dialog)));
-       session_connections.push_back (session->RegionHiddenChange.connect (mem_fun(*this, &Editor::region_hidden)));
 
        session_connections.push_back (session->SMPTEOffsetChanged.connect (mem_fun(*this, &Editor::update_just_smpte)));
 
@@ -1307,8 +1093,6 @@ Editor::connect_to_session (Session *t)
        session_connections.push_back (session->Located.connect (mem_fun (*this, &Editor::located)));
        session_connections.push_back (session->config.ParameterChanged.connect (mem_fun (*this, &Editor::parameter_changed)));
 
-       route_groups_changed ();
-
        edit_point_clock.set_mode(AudioClock::BBT);
        edit_point_clock.set_session (session);
        zoom_range_clock.set_session (session);
@@ -1380,46 +1164,18 @@ Editor::connect_to_session (Session *t)
 
        handle_new_duration ();
 
-       redisplay_regions ();
        redisplay_named_selections ();
-       redisplay_snapshots ();
 
        restore_ruler_visibility ();
        //tempo_map_changed (Change (0));
        session->tempo_map().apply_with_metrics (*this, &Editor::draw_metric_marks);
 
-       initial_route_list_display ();
-
        for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
                (static_cast<TimeAxisView*>(*i))->set_samples_per_unit (frames_per_unit);
        }
 
        start_scrolling ();
 
-       /* don't show master bus in a new session */
-
-       if (ARDOUR_UI::instance()->session_is_new ()) {
-
-               TreeModel::Children rows = route_display_model->children();
-               TreeModel::Children::iterator i;
-       
-               no_route_list_redisplay = true;
-               
-               for (i = rows.begin(); i != rows.end(); ++i) {
-                       TimeAxisView *tv =  (*i)[route_display_columns.tv];
-                       RouteTimeAxisView *rtv;
-                       
-                       if ((rtv = dynamic_cast<RouteTimeAxisView*>(tv)) != 0) {
-                               if (rtv->route()->is_master()) {
-                                       route_list_display.get_selection()->unselect (i);
-                               }
-                       }
-               }
-               
-               no_route_list_redisplay = false;
-               redisplay_route_list ();
-       }
-       
        switch (snap_type) {
        case SnapToRegionStart:
        case SnapToRegionEnd:
@@ -1435,8 +1191,12 @@ Editor::connect_to_session (Session *t)
        /* register for undo history */
        session->register_with_memento_command_factory(_id, this);
 
-       _summary->set_session (session);
-       _group_tabs->set_session (session);
+       _summary->connect_to_session (session);
+       _group_tabs->connect_to_session (session);
+       _route_groups->connect_to_session (session);
+       _regions->connect_to_session (session);
+       _snapshots->connect_to_session (session);
+       _routes->connect_to_session (session);
        
        start_updating ();
 }
@@ -1703,7 +1463,7 @@ Editor::popup_track_context_menu (int button, int32_t time, ItemType item_type,
 }
 
 Menu*
-Editor::build_track_context_menu (nframes64_t ignored)
+Editor::build_track_context_menu (nframes64_t)
 {
        using namespace Menu_Helpers;
 
@@ -1715,7 +1475,7 @@ Editor::build_track_context_menu (nframes64_t ignored)
 }
 
 Menu*
-Editor::build_track_bus_context_menu (nframes64_t ignored)
+Editor::build_track_bus_context_menu (nframes64_t)
 {
        using namespace Menu_Helpers;
 
@@ -1847,7 +1607,7 @@ Editor::analyze_range_selection()
 }
 
 Menu*
-Editor::build_track_selection_context_menu (nframes64_t ignored)
+Editor::build_track_selection_context_menu (nframes64_t)
 {
        using namespace Menu_Helpers;
        MenuList& edit_items  = track_selection_context_menu.items();
@@ -1864,7 +1624,7 @@ Editor::build_track_selection_context_menu (nframes64_t ignored)
  * @param edit_items List to add the items to.
  */
 void
-Editor::add_crossfade_context_items (AudioStreamView* view, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
+Editor::add_crossfade_context_items (AudioStreamView* /*view*/, boost::shared_ptr<Crossfade> xfade, Menu_Helpers::MenuList& edit_items, bool many)
 {
        using namespace Menu_Helpers;
        Menu     *xfade_menu = manage (new Menu);
@@ -1920,20 +1680,6 @@ Editor::xfade_edit_right_region ()
        }
 }
 
-/** Add an element to a menu, settings its sensitivity.
- * @param m Menu to add to.
- * @param e Element to add.
- * @param s true to make sensitive, false to make insensitive
- */
-void
-Editor::add_item_with_sensitivity (Menu_Helpers::MenuList& m, Menu_Helpers::MenuElem e, bool s) const
-{
-       m.push_back (e);
-       if (!s) {
-               m.back().set_sensitive (false);
-       }
-}
-
 void
 Editor::add_region_context_items (StreamView* sv, boost::shared_ptr<Region> region, Menu_Helpers::MenuList& edit_items)
 {
@@ -2169,40 +1915,44 @@ Editor::add_selection_context_items (Menu_Helpers::MenuList& edit_items)
 {
        using namespace Menu_Helpers;
 
-       edit_items.push_back (MenuElem (_("Play range"), mem_fun(*this, &Editor::play_selection)));
-       edit_items.push_back (MenuElem (_("Loop range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
+       edit_items.push_back (MenuElem (_("Play Range"), mem_fun(*this, &Editor::play_selection)));
+       edit_items.push_back (MenuElem (_("Loop Range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), true)));
 
        edit_items.push_back (SeparatorElem());
        edit_items.push_back (MenuElem (_("Spectral Analysis"), mem_fun(*this, &Editor::analyze_range_selection)));
-       
-       edit_items.push_back (SeparatorElem());
-       edit_items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
-       edit_items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
+
+       if (!selection->regions.empty()) {
+               edit_items.push_back (SeparatorElem());
+               edit_items.push_back (MenuElem (_("Extend Range to End of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_end_of_region), false)));
+               edit_items.push_back (MenuElem (_("Extend Range to Start of Region"), bind (mem_fun(*this, &Editor::extend_selection_to_start_of_region), false)));
+       }
 
        edit_items.push_back (SeparatorElem());
-       edit_items.push_back (MenuElem (_("Convert to region in-place"), mem_fun(*this, &Editor::separate_region_from_selection)));
-       edit_items.push_back (MenuElem (_("Convert to region in region list"), mem_fun(*this, &Editor::new_region_from_selection)));
+       edit_items.push_back (MenuElem (_("Silence Range"), mem_fun(*this, &Editor::separate_region_from_selection)));
+       edit_items.push_back (MenuElem (_("Convert to Region in Region List"), mem_fun(*this, &Editor::new_region_from_selection)));
        
        edit_items.push_back (SeparatorElem());
-       edit_items.push_back (MenuElem (_("Select all in range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
+       edit_items.push_back (MenuElem (_("Select All in Range"), mem_fun(*this, &Editor::select_all_selectables_using_time_selection)));
 
        edit_items.push_back (SeparatorElem());
-       edit_items.push_back (MenuElem (_("Set loop from selection"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
-       edit_items.push_back (MenuElem (_("Set punch from selection"), mem_fun(*this, &Editor::set_punch_from_selection)));
+       edit_items.push_back (MenuElem (_("Set Loop from Range"), bind (mem_fun(*this, &Editor::set_loop_from_selection), false)));
+       edit_items.push_back (MenuElem (_("Set Punch from Range"), mem_fun(*this, &Editor::set_punch_from_selection)));
        
        edit_items.push_back (SeparatorElem());
        edit_items.push_back (MenuElem (_("Add Range Markers"), mem_fun (*this, &Editor::add_location_from_selection)));
+       
        edit_items.push_back (SeparatorElem());
-       edit_items.push_back (MenuElem (_("Crop region to range"), mem_fun(*this, &Editor::crop_region_to_selection)));
-       edit_items.push_back (MenuElem (_("Fill range with region"), mem_fun(*this, &Editor::region_fill_selection)));
-       edit_items.push_back (MenuElem (_("Duplicate range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
-       edit_items.push_back (MenuElem (_("Create chunk from range"), mem_fun(*this, &Editor::create_named_selection)));
+       edit_items.push_back (MenuElem (_("Crop Region to Range"), mem_fun(*this, &Editor::crop_region_to_selection)));
+       edit_items.push_back (MenuElem (_("Fill Range with Region"), mem_fun(*this, &Editor::region_fill_selection)));
+       edit_items.push_back (MenuElem (_("Duplicate Range"), bind (mem_fun(*this, &Editor::duplicate_dialog), false)));
+       edit_items.push_back (MenuElem (_("Create Chunk from Range"), mem_fun(*this, &Editor::create_named_selection)));
+       
        edit_items.push_back (SeparatorElem());
-       edit_items.push_back (MenuElem (_("Consolidate range"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, false)));
-       edit_items.push_back (MenuElem (_("Consolidate range with processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, true)));
-       edit_items.push_back (MenuElem (_("Bounce range to region list"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, false)));
-       edit_items.push_back (MenuElem (_("Bounce range to region list with processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, true)));
-       edit_items.push_back (MenuElem (_("Export range"), mem_fun(*this, &Editor::export_range)));
+       edit_items.push_back (MenuElem (_("Consolidate Range"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, false)));
+       edit_items.push_back (MenuElem (_("Consolidate Range With Processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), true, true)));
+       edit_items.push_back (MenuElem (_("Bounce Range to Region List"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, false)));
+       edit_items.push_back (MenuElem (_("Bounce Range to Region List With Processing"), bind (mem_fun(*this, &Editor::bounce_range_selection), false, true)));
+       edit_items.push_back (MenuElem (_("Export Range"), mem_fun(*this, &Editor::export_range)));
 }
 
        
@@ -2575,10 +2325,6 @@ Editor::set_state (const XMLNode& node)
                set_snap_mode ((SnapMode) atoi (prop->value()));
        }
 
-       if ((prop = node.property ("edit-point"))) {
-               set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
-       }
-
        if ((prop = node.property ("mouse-mode"))) {
                MouseMode m = str2mousemode(prop->value());
                mouse_mode = MouseMode ((int) m + 1); /* lie, force mode switch */
@@ -2588,6 +2334,10 @@ Editor::set_state (const XMLNode& node)
                set_mouse_mode (MouseObject, true);
        }
 
+       if ((prop = node.property ("edit-point"))) {
+               set_edit_point_preference ((EditPoint) string_2_enum (prop->value(), _edit_point), true);
+       }
+
        if ((prop = node.property ("show-waveforms-recording"))) {
                bool yn = (prop->value() == "yes");
                _show_waveforms_recording = !yn;
@@ -2625,8 +2375,7 @@ Editor::set_state (const XMLNode& node)
        }
 
        if ((prop = node.property ("region-list-sort-type"))) {
-               region_list_sort_type = (Editing::RegionListSortType) -1; // force change 
-               reset_region_list_sort_type(str2regionlistsorttype(prop->value()));
+               _regions->reset_sort_type (str2regionlistsorttype(prop->value()), true);
        }
 
        if ((prop = node.property ("xfades-visible"))) {
@@ -2727,7 +2476,7 @@ Editor::get_state ()
        node->add_property ("show-measures", _show_measures ? "yes" : "no");
        node->add_property ("follow-playhead", _follow_playhead ? "yes" : "no");
        node->add_property ("xfades-visible", _xfade_visibility ? "yes" : "no");
-       node->add_property ("region-list-sort-type", enum2str(region_list_sort_type));
+       node->add_property ("region-list-sort-type", enum2str (_regions->sort_type ()));
        node->add_property ("mouse-mode", enum2str(mouse_mode));
        
        Glib::RefPtr<Action> act = ActionManager::get_action (X_("Editor"), X_("show-editor-mixer"));
@@ -3031,36 +2780,13 @@ Editor::setup_toolbar ()
 
        /* Mode Buttons (tool selection) */
 
-       vector<ToggleButton *> mouse_mode_buttons;
-
-       mouse_move_button.add (*(manage (new Image (::get_icon("tool_object")))));
        mouse_move_button.set_relief(Gtk::RELIEF_NONE);
-       mouse_mode_buttons.push_back (&mouse_move_button);
-
-       if (!Profile->get_sae()) {
-               mouse_select_button.add (*(manage (new Image (get_xpm("tool_range.xpm")))));
-               mouse_select_button.set_relief(Gtk::RELIEF_NONE);
-               mouse_mode_buttons.push_back (&mouse_select_button);
-
-               mouse_gain_button.add (*(manage (new Image (::get_icon("tool_gain")))));
-               mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
-               mouse_mode_buttons.push_back (&mouse_gain_button);
-       }
-
-       mouse_zoom_button.add (*(manage (new Image (::get_icon("tool_zoom")))));
+       mouse_select_button.set_relief(Gtk::RELIEF_NONE);
+       mouse_gain_button.set_relief(Gtk::RELIEF_NONE);
        mouse_zoom_button.set_relief(Gtk::RELIEF_NONE);
-       mouse_mode_buttons.push_back (&mouse_zoom_button);
-       mouse_timefx_button.add (*(manage (new Image (::get_icon("tool_stretch")))));
        mouse_timefx_button.set_relief(Gtk::RELIEF_NONE);
-       mouse_mode_buttons.push_back (&mouse_timefx_button);
-       mouse_audition_button.add (*(manage (new Image (::get_icon("tool_audition")))));
        mouse_audition_button.set_relief(Gtk::RELIEF_NONE);
-       mouse_note_button.add (*(manage (new Image (::get_icon("tool_note")))));
-       mouse_note_button.set_relief(Gtk::RELIEF_NONE);
-       mouse_mode_buttons.push_back (&mouse_note_button);
-       mouse_mode_buttons.push_back (&mouse_audition_button);
-       
-       mouse_mode_button_set = new GroupedButtons (mouse_mode_buttons);
+       // internal_edit_button.set_relief(Gtk::RELIEF_NONE);
 
        HBox* mode_box = manage(new HBox);
        mode_box->set_border_width (2);
@@ -3076,7 +2802,7 @@ Editor::setup_toolbar ()
        }
        mouse_mode_button_box.pack_start(mouse_timefx_button, true, true);
        mouse_mode_button_box.pack_start(mouse_audition_button, true, true);
-       mouse_mode_button_box.pack_start(mouse_note_button, true, true);
+       mouse_mode_button_box.pack_start(internal_edit_button, true, true);
        mouse_mode_button_box.set_homogeneous(true);
 
        vector<string> edit_mode_strings;
@@ -3109,21 +2835,21 @@ Editor::setup_toolbar ()
        mouse_mode_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&toolbar_hbox), 
                                                   &mouse_mode_tearoff->tearoff_window(), 1));
 
+       mouse_move_button.set_mode (false);
+       mouse_select_button.set_mode (false);
+       mouse_gain_button.set_mode (false);
+       mouse_zoom_button.set_mode (false);
+       mouse_timefx_button.set_mode (false);
+       mouse_audition_button.set_mode (false);
+
        mouse_move_button.set_name ("MouseModeButton");
        mouse_select_button.set_name ("MouseModeButton");
        mouse_gain_button.set_name ("MouseModeButton");
        mouse_zoom_button.set_name ("MouseModeButton");
        mouse_timefx_button.set_name ("MouseModeButton");
        mouse_audition_button.set_name ("MouseModeButton");
-       mouse_note_button.set_name ("MouseModeButton");
 
-       ARDOUR_UI::instance()->tooltips().set_tip (mouse_move_button, _("Select/Move Objects"));
-       ARDOUR_UI::instance()->tooltips().set_tip (mouse_select_button, _("Select/Move Ranges"));
-       ARDOUR_UI::instance()->tooltips().set_tip (mouse_gain_button, _("Draw Gain Automation"));
-       ARDOUR_UI::instance()->tooltips().set_tip (mouse_zoom_button, _("Select Zoom Range"));
-       ARDOUR_UI::instance()->tooltips().set_tip (mouse_timefx_button, _("Stretch/Shrink Regions"));
-       ARDOUR_UI::instance()->tooltips().set_tip (mouse_audition_button, _("Listen to Specific Regions"));
-       ARDOUR_UI::instance()->tooltips().set_tip (mouse_note_button, _("Edit MIDI Notes"));
+       internal_edit_button.set_name ("MouseModeButton");
 
        mouse_move_button.unset_flags (CAN_FOCUS);
        mouse_select_button.unset_flags (CAN_FOCUS);
@@ -3131,20 +2857,7 @@ Editor::setup_toolbar ()
        mouse_zoom_button.unset_flags (CAN_FOCUS);
        mouse_timefx_button.unset_flags (CAN_FOCUS);
        mouse_audition_button.unset_flags (CAN_FOCUS);
-       mouse_note_button.unset_flags (CAN_FOCUS);
-
-       mouse_select_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseRange));
-       mouse_select_button.signal_button_release_event().connect (mem_fun(*this, &Editor::mouse_select_button_release));
-
-       mouse_move_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseObject));
-       mouse_gain_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseGain));
-       mouse_zoom_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseZoom));
-       mouse_timefx_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseTimeFX));
-       mouse_audition_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseAudition));
-       mouse_note_button.signal_toggled().connect (bind (mem_fun(*this, &Editor::mouse_mode_toggled), Editing::MouseNote));
-
-       // mouse_move_button.set_active (true);
-       
+       internal_edit_button.unset_flags (CAN_FOCUS);
 
        /* Zoom */
        
@@ -3246,11 +2959,10 @@ Editor::setup_toolbar ()
 
        toolbar_hbox.pack_start (*mouse_mode_tearoff, false, false);
        toolbar_hbox.pack_start (*tools_tearoff, false, false);
-
        
        hbox->pack_start (snap_box, false, false);
-       // hbox->pack_start (zoom_box, false, false); 
        hbox->pack_start (*nudge_box, false, false);
+       hbox->pack_start (panic_box, false, false);
 
        hbox->show_all ();
        
@@ -3273,12 +2985,7 @@ Editor::midi_panic_button_pressed ()
 void
 Editor::setup_midi_toolbar ()
 {
-       string pixmap_path;
-
-       /* Mode Buttons (tool selection) */
-
-       vector<ToggleButton *> midi_tool_buttons;
-
+#if 0
        midi_tool_pencil_button.add (*(manage (new Image (::get_icon("midi_tool_pencil")))));
        midi_tool_pencil_button.set_relief(Gtk::RELIEF_NONE);
        midi_tool_buttons.push_back (&midi_tool_pencil_button);
@@ -3292,42 +2999,11 @@ Editor::setup_midi_toolbar ()
        midi_tool_erase_button.set_relief(Gtk::RELIEF_NONE);
        midi_tool_buttons.push_back (&midi_tool_erase_button);
 
-       midi_tool_pencil_button.set_active(true);
-       
-       midi_tool_button_set = new GroupedButtons (midi_tool_buttons);
-
-       midi_tool_button_box.set_border_width (2);
-       midi_tool_button_box.set_spacing(1);
-       midi_tool_button_box.pack_start(midi_tool_pencil_button, true, true);
-       midi_tool_button_box.pack_start(midi_tool_select_button, true, true);
-       midi_tool_button_box.pack_start(midi_tool_resize_button, true, true);
-       midi_tool_button_box.pack_start(midi_tool_erase_button , true, true);
-       midi_tool_button_box.set_homogeneous(true);
-
-       midi_tool_pencil_button.set_name ("MouseModeButton");
-       midi_tool_select_button.set_name ("MouseModeButton");
-       midi_tool_resize_button.set_name ("MouseModeButton");
-       midi_tool_erase_button .set_name ("MouseModeButton");
-
        ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_pencil_button, _("Add/Move/Stretch Notes"));
        ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_select_button, _("Select/Move Notes"));
        ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_resize_button, _("Resize Notes"));
        ARDOUR_UI::instance()->tooltips().set_tip (midi_tool_erase_button,  _("Erase Notes"));
-
-       midi_tool_pencil_button.unset_flags (CAN_FOCUS);
-       midi_tool_select_button.unset_flags (CAN_FOCUS);
-       midi_tool_resize_button.unset_flags (CAN_FOCUS);
-       midi_tool_erase_button.unset_flags (CAN_FOCUS);
-       
-       midi_tool_pencil_button.signal_toggled().connect (bind (mem_fun(*this,
-                               &Editor::midi_edit_mode_toggled), Editing::MidiEditPencil));
-       midi_tool_select_button.signal_toggled().connect (bind (mem_fun(*this,
-                               &Editor::midi_edit_mode_toggled), Editing::MidiEditSelect));
-       midi_tool_resize_button.signal_toggled().connect (bind (mem_fun(*this,
-                               &Editor::midi_edit_mode_toggled), Editing::MidiEditResize));
-       midi_tool_erase_button.signal_toggled().connect (bind (mem_fun(*this,
-                               &Editor::midi_edit_mode_toggled), Editing::MidiEditErase));
-
+#endif
        
        /* Midi sound notes */
        midi_sound_notes.add (*(manage (new Image (::get_icon("midi_sound_notes")))));
@@ -3337,57 +3013,22 @@ Editor::setup_midi_toolbar ()
        
        /* Panic */
        
-       HBox* panic_box = manage (new HBox);
        midi_panic_button.set_name("MidiPanicButton");
-       midi_panic_button.signal_pressed().connect (
-                       mem_fun(this, &Editor::midi_panic_button_pressed));
-       panic_box->pack_start (midi_sound_notes , true, true);
-       panic_box->pack_start (midi_panic_button, true, true);
-       
-       /* Pack everything in... */
-
-       midi_tools_tearoff = manage (new TearOff (midi_tool_button_box));
-       midi_tools_tearoff->set_name ("MouseModeBase");
-
-       /*
-       midi_tools_tearoff->Detach.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&midi_toolbar_hbox), 
-                                            &midi_tools_tearoff->tearoff_window()));
-       midi_tools_tearoff->Attach.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&midi_toolbar_hbox), 
-                                            &midi_tools_tearoff->tearoff_window(), 0));
-       midi_tools_tearoff->Hidden.connect (bind (mem_fun(*this, &Editor::detach_tearoff), static_cast<Box*>(&midi_toolbar_hbox), 
-                                            &midi_tools_tearoff->tearoff_window()));
-       midi_tools_tearoff->Visible.connect (bind (mem_fun(*this, &Editor::reattach_tearoff), static_cast<Box*> (&midi_toolbar_hbox), 
-                                             &midi_tools_tearoff->tearoff_window(), 0));
-       */
-
-       midi_toolbar_hbox.set_spacing (10);
-       midi_toolbar_hbox.set_border_width (1);
-
-       midi_toolbar_hbox.pack_start (*midi_tools_tearoff, false, true);
-       
-       midi_toolbar_hbox.pack_start(*panic_box, false, true, 4);
+       midi_panic_button.signal_pressed().connect (mem_fun(this, &Editor::midi_panic_button_pressed));
 
-       midi_tool_button_box.show_all ();
-       midi_toolbar_hbox.show_all();
-       midi_tools_tearoff->show_all();
-       
-       midi_toolbar_base.set_name ("ToolBarBase");
-       midi_toolbar_base.add (midi_toolbar_hbox);
-
-       midi_toolbar_frame.set_shadow_type (SHADOW_OUT);
-       midi_toolbar_frame.set_name ("BaseFrame");
-       midi_toolbar_frame.add (midi_toolbar_base);
+       panic_box.pack_start (midi_sound_notes , true, true);
+       panic_box.pack_start (midi_panic_button, true, true);
 }
 
 int
 Editor::convert_drop_to_paths (
                vector<ustring>&                paths, 
-               const RefPtr<Gdk::DragContext>& context,
-               gint                            x,
-               gint                            y,
+               const RefPtr<Gdk::DragContext>& /*context*/,
+               gint                            /*x*/,
+               gint                            /*y*/,
                const SelectionData&            data,
-               guint                           info,
-               guint                           time)
+               guint                           /*info*/,
+               guint                           /*time*/)
 {      
        if (session == 0) {
                return -1;
@@ -4056,8 +3697,10 @@ Editor::pane_allocation_handler (Allocation &alloc, Paned* which)
 }
 
 void
-Editor::detach_tearoff (Box* b, Window* w)
+Editor::detach_tearoff (Box* /*b*/, Window* /*w*/)
 {
+       cerr << "remove tearoff\n";
+
        if (tools_tearoff->torn_off() && 
            mouse_mode_tearoff->torn_off()) {
                top_hbox.remove (toolbar_frame);
@@ -4065,8 +3708,9 @@ Editor::detach_tearoff (Box* b, Window* w)
 }
 
 void
-Editor::reattach_tearoff (Box* b, Window* w, int32_t n)
+Editor::reattach_tearoff (Box* /*b*/, Window* /*w*/, int32_t /*n*/)
 {
+       cerr << "reattach tearoff\n";
        if (toolbar_frame.get_parent() == 0) {
                top_hbox.pack_end (toolbar_frame);
        }
@@ -4234,14 +3878,13 @@ Editor::prepare_for_cleanup ()
        selection->clear_regions ();
        selection->clear_playlists ();
 
-       no_region_list_redisplay = true;
+       _regions->suspend_redisplay ();
 }
 
 void
 Editor::finish_cleanup ()
 {
-       no_region_list_redisplay = false;
-       redisplay_regions ();
+       _regions->resume_redisplay ();
 }
 
 Location*
@@ -4285,161 +3928,12 @@ Editor::control_layout_scroll (GdkEventScroll* ev)
        return false;
 }
 
-
-/** A new snapshot has been selected.
- */
-void
-Editor::snapshot_display_selection_changed ()
-{
-       if (snapshot_display.get_selection()->count_selected_rows() > 0) {
-
-               TreeModel::iterator i = snapshot_display.get_selection()->get_selected();
-               
-               Glib::ustring snap_name = (*i)[snapshot_display_columns.real_name];
-
-               if (snap_name.length() == 0) {
-                       return;
-               }
-               
-               if (session->snap_name() == snap_name) {
-                       return;
-               }
-               
-               ARDOUR_UI::instance()->load_session(session->path(), string (snap_name));
-       }
-}
-
-bool
-Editor::snapshot_display_button_press (GdkEventButton* ev)
-{
-       if (ev->button == 3) {
-               /* Right-click on the snapshot list. Work out which snapshot it
-                  was over. */
-               Gtk::TreeModel::Path path;
-               Gtk::TreeViewColumn* col;
-               int cx;
-               int cy;
-               snapshot_display.get_path_at_pos ((int) ev->x, (int) ev->y, path, col, cx, cy);
-               Gtk::TreeModel::iterator iter = snapshot_display_model->get_iter (path);
-               if (iter) {
-                       Gtk::TreeModel::Row row = *iter;
-                       popup_snapshot_context_menu (ev->button, ev->time, row[snapshot_display_columns.real_name]);
-               }
-               return true;
-       }
-
-       return false;
-}
-
-
-/** Pop up the snapshot display context menu.
- * @param button Button used to open the menu.
- * @param time Menu open time.
- * @snapshot_name Name of the snapshot that the menu click was over.
- */
-
-void
-Editor::popup_snapshot_context_menu (int button, int32_t time, Glib::ustring snapshot_name)
-{
-       using namespace Menu_Helpers;
-
-       MenuList& items (snapshot_context_menu.items());
-       items.clear ();
-
-       const bool modification_allowed = (session->snap_name() != snapshot_name && session->name() != snapshot_name);
-
-       add_item_with_sensitivity (items, MenuElem (_("Remove"), bind (mem_fun (*this, &Editor::remove_snapshot), snapshot_name)), modification_allowed);
-
-       add_item_with_sensitivity (items, MenuElem (_("Rename"), bind (mem_fun (*this, &Editor::rename_snapshot), snapshot_name)), modification_allowed);
-
-       snapshot_context_menu.popup (button, time);
-}
-
-void
-Editor::rename_snapshot (Glib::ustring old_name)
-{
-       ArdourPrompter prompter(true);
-
-       string new_name;
-
-       prompter.set_name ("Prompter");
-       prompter.add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_ACCEPT);
-       prompter.set_prompt (_("New name of snapshot"));
-       prompter.set_initial_text (old_name);
-       
-       if (prompter.run() == RESPONSE_ACCEPT) {
-               prompter.get_result (new_name);
-               if (new_name.length()) {
-                       session->rename_state (old_name, new_name);
-                       redisplay_snapshots ();
-               }
-       }
-}
-
-
-void
-Editor::remove_snapshot (Glib::ustring name)
-{
-       vector<string> choices;
-
-       std::string prompt  = string_compose (_("Do you really want to remove snapshot \"%1\" ?\n(cannot be undone)"), name);
-
-       choices.push_back (_("No, do nothing."));
-       choices.push_back (_("Yes, remove it."));
-
-       Gtkmm2ext::Choice prompter (prompt, choices);
-
-       if (prompter.run () == 1) {
-               session->remove_state (name);
-               redisplay_snapshots ();
-       }
-}
-
-void
-Editor::redisplay_snapshots ()
-{
-       if (session == 0) {
-               return;
-       }
-
-       vector<sys::path> state_file_paths;
-
-       get_state_files_in_directory (session->session_directory().root_path(),
-                       state_file_paths);
-
-       if (state_file_paths.empty()) return;
-
-       vector<string> state_file_names(get_file_names_no_extension(state_file_paths));
-
-       snapshot_display_model->clear ();
-
-       for (vector<string>::iterator i = state_file_names.begin();
-                       i != state_file_names.end(); ++i)
-       {
-               string statename = (*i);
-               TreeModel::Row row = *(snapshot_display_model->append());
-               
-               /* this lingers on in case we ever want to change the visible
-                  name of the snapshot.
-               */
-               
-               string display_name;
-               display_name = statename;
-
-               if (statename == session->snap_name()) {
-                       snapshot_display.get_selection()->select(row);
-               } 
-               
-               row[snapshot_display_columns.visible_name] = display_name;
-               row[snapshot_display_columns.real_name] = statename;
-       }
-}
-
 void
 Editor::session_state_saved (string snap_name)
 {
        ENSURE_GUI_THREAD (bind (mem_fun(*this, &Editor::session_state_saved), snap_name));
-       redisplay_snapshots ();
+       
+       _snapshots->redisplay ();
 }
 
 void
@@ -4543,7 +4037,7 @@ Editor::mapped_use_copy_playlist (RouteTimeAxisView& atv, uint32_t sz, vector<bo
 }
 
 void 
-Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t sz)
+Editor::mapped_clear_playlist (RouteTimeAxisView& atv, uint32_t /*sz*/)
 {
        atv.clear_playlist ();
 }
@@ -4651,7 +4145,8 @@ void
 Editor::use_visual_state (VisualState& vs)
 {
        no_save_visual = true;
-       no_route_list_redisplay = true;
+
+       _routes->suspend_redisplay ();
 
        vertical_adjustment.set_value (vs.y_position);
 
@@ -4671,11 +4166,10 @@ Editor::use_visual_state (VisualState& vs)
 
 
        if (!vs.track_states.empty()) {
-               update_route_visibility ();
+               _routes->update_visibility ();
        } 
 
-       no_route_list_redisplay = false;
-       redisplay_route_list ();
+       _routes->resume_redisplay ();
 
        no_save_visual = false;
 }
@@ -4753,6 +4247,7 @@ Editor::post_zoom ()
                playhead_cursor->set_position (playhead_cursor->current_frame);
        }
 
+       refresh_location_display();
        _summary->set_overlays_dirty ();
 
        instant_save ();
@@ -4989,6 +4484,11 @@ Editor::set_punch_range (nframes64_t start, nframes64_t end, string cmd)
        commit_reversible_command ();
 }
 
+/** Find regions which exist at a given time, and optionally on a given list of tracks.
+ *  @param rs List to which found regions are added.
+ *  @param where Time to look at.
+ *  @param ts Tracks to look on; if this is empty, all tracks are examined.
+ */
 void
 Editor::get_regions_at (RegionSelection& rs, nframes64_t where, const TrackSelection& ts) const
 {
@@ -5061,11 +4561,21 @@ Editor::get_regions_after (RegionSelection& rs, nframes64_t where, const TrackSe
        }
 }
 
+/** Find all regions which are either:
+ *      - selected or
+ *      - the entered_regionview (if allow_entered == true) or
+ *      - under the preferred edit position AND on a selected track, or on a track
+ *        which is in the same active edit-enable route group as a selected region.
+ *  @param rs Returned region list.
+ *  @param allow_entered true to include the entered_regionview in the list.
+ */
 void
 Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered)
 {
+       /* Start with selected regions */
        rs = selection->regions;
 
+       /* Add the entered_regionview, if requested */
        if (allow_entered && entered_regionview) {
                rs.add (entered_regionview);
        }
@@ -5074,13 +4584,19 @@ Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered)
 
        RegionSelection to_map = rs;
 
+       /* tracks is currently the set of selected tracks; add any other tracks that
+        * have regions that are in the same edit-activated route group as one of
+        * our regions */
        for (RegionSelection::iterator i = to_map.begin (); i != to_map.end(); ++i) {
 
                RouteGroup* g = (*i)->get_time_axis_view().route_group ();
                if (g && g->active_property (RouteGroup::Edit)) {
                        tracks.add (axis_views_from_routes (g->route_list()));
                }
+       }
 
+       /* now find regions that are at the edit position on those tracks */
+       for (RegionSelection::iterator i = to_map.begin (); i != to_map.end(); ++i) {
                nframes64_t const where = get_preferred_edit_position ();
                get_regions_at (rs, where, tracks);
        }
@@ -5089,7 +4605,6 @@ Editor::get_regions_for_action (RegionSelection& rs, bool allow_entered)
 void
 Editor::get_regions_corresponding_to (boost::shared_ptr<Region> region, vector<RegionView*>& regions)
 {
-
        for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
                
                RouteTimeAxisView* tatv;
@@ -5172,7 +4687,7 @@ Editor::first_idle ()
        }
 
        // first idle adds route children (automation tracks), so we need to redisplay here
-       redisplay_route_list();
+       _routes->redisplay ();
        
        delete dialog;
 
@@ -5262,22 +4777,223 @@ Editor::streamview_height_changed ()
        _summary->set_dirty ();
 }
 
+TimeAxisView*
+Editor::axis_view_from_route (Route* r) const
+{
+       TrackViewList::const_iterator j = track_views.begin ();
+       while (j != track_views.end()) {
+               RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j);
+               if (rtv && rtv->route().get() == r) {
+                       return rtv;
+               }
+               ++j;
+       }
+
+       return 0;
+}
+
+
 TrackSelection
 Editor::axis_views_from_routes (list<Route*> r) const
 {
        TrackSelection t;
        
        for (list<Route*>::const_iterator i = r.begin(); i != r.end(); ++i) {
-               TrackViewList::const_iterator j = track_views.begin ();
-               while (j != track_views.end()) {
-                       RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (*j);
-                       if (rtv && rtv->route().get() == *i) {
-                               t.push_back (rtv);
-                       }
-                       ++j;
+               TimeAxisView* tv = axis_view_from_route (*i);
+               if (tv) {
+                       t.push_back (tv);
                }
        }
 
        return t;
 }
 
+
+void
+Editor::handle_new_route (RouteList& routes)
+{
+       ENSURE_GUI_THREAD (bind (mem_fun (*this, &Editor::handle_new_route), routes));
+       
+       RouteTimeAxisView *rtv;
+       list<RouteTimeAxisView*> new_views;
+
+       for (RouteList::iterator x = routes.begin(); x != routes.end(); ++x) {
+               boost::shared_ptr<Route> route = (*x);
+
+               if (route->is_hidden()) {
+                       continue;
+               }
+
+               DataType dt = route->input()->default_type();
+
+               if (dt == ARDOUR::DataType::AUDIO) {
+                       rtv = new AudioTimeAxisView (*this, *session, route, *track_canvas);
+               } else if (dt == ARDOUR::DataType::MIDI) {
+                       rtv = new MidiTimeAxisView (*this, *session, route, *track_canvas);
+               } else {
+                       throw unknown_type();
+               }
+
+               new_views.push_back (rtv);
+               track_views.push_back (rtv);
+               
+               rtv->effective_gain_display ();
+               
+               rtv->view()->RegionViewAdded.connect (mem_fun (*this, &Editor::region_view_added));
+               rtv->view()->HeightChanged.connect (mem_fun (*this, &Editor::streamview_height_changed));
+               
+               rtv->GoingAway.connect (bind (mem_fun(*this, &Editor::remove_route), rtv));
+       }
+
+       _routes->routes_added (new_views);
+
+       if (show_editor_mixer_when_tracks_arrive) {
+               show_editor_mixer (true);
+       }
+
+       editor_list_button.set_sensitive (true);
+
+       _summary->set_dirty ();
+}
+
+void
+Editor::remove_route (TimeAxisView *tv)
+{
+       ENSURE_GUI_THREAD(bind (mem_fun(*this, &Editor::remove_route), tv));
+
+       TrackViewList::iterator i;
+       boost::shared_ptr<Route> route;
+       TimeAxisView* next_tv;
+
+       if (tv == entered_track) {
+               entered_track = 0;
+       }
+
+       if ((i = find (track_views.begin(), track_views.end(), tv)) != track_views.end()) {
+
+               i = track_views.erase (i);
+
+               if (track_views.empty()) {
+                       next_tv = 0;
+               } else if (i == track_views.end()) {
+                       next_tv = track_views.front();
+               } else {
+                      next_tv = (*i);
+               }
+       }
+       
+       if (current_mixer_strip && current_mixer_strip->route() == route) {
+
+               if (next_tv) {
+                       set_selected_mixer_strip (*next_tv);
+               } else {
+                       /* make the editor mixer strip go away setting the
+                        * button to inactive (which also unticks the menu option)
+                        */
+
+                       ActionManager::uncheck_toggleaction ("<Actions>/Editor/show-editor-mixer");
+               }
+       } 
+}
+
+void
+Editor::hide_track_in_display (TimeAxisView& tv, bool /*temponly*/)
+{
+       RouteTimeAxisView* rtv = dynamic_cast<RouteTimeAxisView*> (&tv);
+
+       if (rtv && current_mixer_strip && (rtv->route() == current_mixer_strip->route())) {
+               // this will hide the mixer strip
+               set_selected_mixer_strip (tv);
+       }
+
+       _routes->hide_track_in_display (tv);
+}
+
+bool
+Editor::sync_track_view_list_and_routes ()
+{
+       track_views = TrackSelection (_routes->views ());
+       
+       _summary->set_dirty ();
+       _group_tabs->set_dirty ();
+       
+       return false; // do not call again (until needed)
+}
+
+void
+Editor::foreach_time_axis_view (sigc::slot<void,TimeAxisView&> theslot)
+{
+       for (TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
+               theslot (**i);
+       }
+}
+
+RouteTimeAxisView*
+Editor::get_route_view_by_id (PBD::ID& id)
+{
+       RouteTimeAxisView* v;
+
+       for(TrackViewList::iterator i = track_views.begin(); i != track_views.end(); ++i) {
+               if((v = dynamic_cast<RouteTimeAxisView*>(*i)) != 0) {
+                       if(v->route()->id() == id) {
+                               return v;
+                       }
+               }
+       }
+
+       return 0;
+}
+
+void
+Editor::fit_route_group (RouteGroup *g)
+{
+       TrackSelection ts = axis_views_from_routes (g->route_list ());
+       fit_tracks (ts);
+}
+
+void
+Editor::consider_auditioning (boost::shared_ptr<Region> region)
+{
+       boost::shared_ptr<AudioRegion> r = boost::dynamic_pointer_cast<AudioRegion> (region);
+
+       if (r == 0) {
+               session->cancel_audition ();
+               return;
+       }
+
+       if (session->is_auditioning()) {
+               session->cancel_audition ();
+               if (r == last_audition_region) {
+                       return;
+               }
+       }
+
+       session->audition_region (r);
+       last_audition_region = r;
+}
+
+
+void
+Editor::hide_a_region (boost::shared_ptr<Region> r)
+{
+       r->set_hidden (true);
+}
+
+void
+Editor::remove_a_region (boost::shared_ptr<Region> r)
+{
+       session->remove_region_from_region_list (r);
+}
+
+void
+Editor::audition_region_from_region_list ()
+{
+       _regions->selection_mapover (mem_fun (*this, &Editor::consider_auditioning));
+}
+
+void
+Editor::hide_region_from_region_list ()
+{
+       _regions->selection_mapover (mem_fun (*this, &Editor::hide_a_region));
+}
+