changes to help strp silence
[ardour.git] / gtk2_ardour / mixer_ui.cc
index 16f3089825b6e7bd4dbfc8b3370181d87e547b3e..4b4a5b41b18fa135cc9b26ca5dd41c748e3a152f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2000-2004 Paul Davis 
+    Copyright (C) 2000-2004 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
 */
 
 #include <algorithm>
+#include <map>
 #include <sigc++/bind.h>
 
 #include <gtkmm/accelmap.h>
 
 #include "pbd/convert.h"
+#include "pbd/stacktrace.h"
 #include <glibmm/thread.h>
 
 #include <gtkmm2ext/gtk_ui.h>
@@ -55,7 +57,6 @@ using namespace PBD;
 using namespace Gtk;
 using namespace Glib;
 using namespace Gtkmm2ext;
-using namespace sigc;
 using namespace std;
 
 using PBD::atoi;
@@ -63,7 +64,6 @@ using PBD::atoi;
 Mixer_UI::Mixer_UI ()
        : Window (Gtk::WINDOW_TOPLEVEL)
 {
-       session = 0;
        _strip_width = Config->get_default_narrow_ms() ? Narrow : Wide;
        track_menu = 0;
        route_group_context_menu = 0;
@@ -74,11 +74,11 @@ Mixer_UI::Mixer_UI ()
        strip_redisplay_does_not_sync_order_keys = false;
        ignore_sync = false;
 
-       Route::SyncOrderKeys.connect (mem_fun (*this, &Mixer_UI::sync_order_keys));
+       Route::SyncOrderKeys.connect (*this, ui_bind (&Mixer_UI::sync_order_keys, this, _1), gui_context());
 
-       scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
-       scroller_base.set_name ("MixerWindow");
-       scroller_base.signal_button_release_event().connect (mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
+       scroller_base.add_events (Gdk::BUTTON_PRESS_MASK|Gdk::BUTTON_RELEASE_MASK);
+       scroller_base.set_name ("MixerWindow");
+       scroller_base.signal_button_release_event().connect (sigc::mem_fun(*this, &Mixer_UI::strip_scroller_button_release));
        // add as last item of strip packer
        strip_packer.pack_end (scroller_base, true, true);
 
@@ -104,15 +104,15 @@ Mixer_UI::Mixer_UI ()
        track_display.set_reorderable (true);
        track_display.set_headers_visible (true);
 
-       track_model->signal_row_deleted().connect (mem_fun (*this, &Mixer_UI::track_list_delete));
-       track_model->signal_row_changed().connect (mem_fun (*this, &Mixer_UI::track_list_change));
-       track_model->signal_rows_reordered().connect (mem_fun (*this, &Mixer_UI::track_list_reorder));
+       track_model->signal_row_deleted().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_delete));
+       track_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_change));
+       track_model->signal_rows_reordered().connect (sigc::mem_fun (*this, &Mixer_UI::track_list_reorder));
 
        CellRendererToggle* track_list_visible_cell = dynamic_cast<CellRendererToggle*>(track_display.get_column_cell_renderer (1));
        track_list_visible_cell->property_activatable() = true;
        track_list_visible_cell->property_radio() = false;
 
-       track_display.signal_button_press_event().connect (mem_fun (*this, &Mixer_UI::track_display_button_press), false);
+       track_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::track_display_button_press), false);
 
        track_display_scroller.add (track_display);
        track_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
@@ -135,7 +135,7 @@ Mixer_UI::Mixer_UI ()
 
        CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (0));
        name_cell->property_editable() = true;
-       name_cell->signal_edited().connect (mem_fun (*this, &Mixer_UI::route_group_name_edit));
+       name_cell->signal_edited().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_name_edit));
 
        /* use checkbox for the active column */
 
@@ -143,9 +143,9 @@ Mixer_UI::Mixer_UI ()
        active_cell->property_activatable() = true;
        active_cell->property_radio() = false;
 
-       group_model->signal_row_changed().connect (mem_fun (*this, &Mixer_UI::route_group_row_change));
+       group_model->signal_row_changed().connect (sigc::mem_fun (*this, &Mixer_UI::route_group_row_change));
 
-       group_display.signal_button_press_event().connect (mem_fun (*this, &Mixer_UI::group_display_button_press), false);
+       group_display.signal_button_press_event().connect (sigc::mem_fun (*this, &Mixer_UI::group_display_button_press), false);
 
        group_display_scroller.add (group_display);
        group_display_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
@@ -167,8 +167,8 @@ Mixer_UI::Mixer_UI ()
 
        route_group_display_button_box->set_homogeneous (true);
 
-       route_group_add_button->signal_clicked().connect (mem_fun (*this, &Mixer_UI::new_route_group));
-       route_group_remove_button->signal_clicked().connect (mem_fun (*this, &Mixer_UI::remove_selected_route_group));
+       route_group_add_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::new_route_group));
+       route_group_remove_button->signal_clicked().connect (sigc::mem_fun (*this, &Mixer_UI::remove_selected_route_group));
 
        route_group_display_button_box->add (*route_group_remove_button);
        route_group_display_button_box->add (*route_group_add_button);
@@ -199,16 +199,16 @@ Mixer_UI::Mixer_UI ()
        list_hpane.add1(list_vpacker);
        list_hpane.add2(global_hpacker);
 
-       rhs_pane1.signal_size_allocate().connect (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler), 
+       rhs_pane1.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::pane_allocation_handler),
                                                        static_cast<Gtk::Paned*> (&rhs_pane1)));
-       list_hpane.signal_size_allocate().connect (bind (mem_fun(*this, &Mixer_UI::pane_allocation_handler), 
+       list_hpane.signal_size_allocate().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::pane_allocation_handler),
                                                         static_cast<Gtk::Paned*> (&list_hpane)));
-       
+
        global_vpacker.pack_start (list_hpane, true, true);
 
        add (global_vpacker);
        set_name ("MixerWindow");
-       
+
        WindowTitle title(Glib::get_application_name());
        title += _("Mixer");
        set_title (title.get_string());
@@ -217,14 +217,12 @@ Mixer_UI::Mixer_UI ()
 
        add_accel_group (ActionManager::ui_manager->get_accel_group());
 
-       signal_delete_event().connect (mem_fun (*this, &Mixer_UI::hide_window));
+       signal_delete_event().connect (sigc::mem_fun (*this, &Mixer_UI::hide_window));
        add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
 
-       _plugin_selector = new PluginSelector (PluginManager::the_manager());
-
-       signal_configure_event().connect (mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
+       signal_configure_event().connect (sigc::mem_fun (*ARDOUR_UI::instance(), &ARDOUR_UI::configure_handler));
 
-       _selection.RoutesChanged.connect (mem_fun(*this, &Mixer_UI::follow_strip_selection));
+       _selection.RoutesChanged.connect (sigc::mem_fun(*this, &Mixer_UI::follow_strip_selection));
 
        route_group_display_button_box->show();
        route_group_add_button->show();
@@ -252,6 +250,12 @@ Mixer_UI::Mixer_UI ()
        group_display.show();
 
        auto_rebinding = FALSE;
+
+       MixerStrip::CatchDeletion.connect (*this, ui_bind (&Mixer_UI::remove_strip, this, _1), gui_context());
+
+#ifndef DEFER_PLUGIN_SELECTOR_LOAD
+       _plugin_selector = new PluginSelector (PluginManager::the_manager ());
+#endif
 }
 
 Mixer_UI::~Mixer_UI ()
@@ -273,10 +277,10 @@ Mixer_UI::show_window ()
 
                /* now reset each strips width so the right widgets are shown */
                MixerStrip* ms;
-               
+
                TreeModel::Children rows = track_model->children();
                TreeModel::Children::iterator ri;
-               
+
                for (ri = rows.begin(); ri != rows.end(); ++ri) {
                        ms = (*ri)[track_columns.strip];
                        ms->set_width_enum (ms->get_width_enum (), ms->width_owner());
@@ -298,8 +302,8 @@ Mixer_UI::hide_window (GdkEventAny *ev)
 void
 Mixer_UI::add_strip (RouteList& routes)
 {
-       ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::add_strip), routes));
-       
+       ENSURE_GUI_THREAD (*this, &Mixer_UI::add_strip, routes)
+
        MixerStrip* strip;
 
        no_track_list_redisplay = true;
@@ -311,11 +315,9 @@ Mixer_UI::add_strip (RouteList& routes)
                if (route->is_hidden()) {
                        return;
                }
-               
-               strip = new MixerStrip (*this, *session, route);
+
+               strip = new MixerStrip (*this, _session, route);
                strips.push_back (strip);
-               
-               Config->get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
 
                Config->get_default_narrow_ms() ? _strip_width = Narrow : _strip_width = Wide;
 
@@ -324,7 +326,7 @@ Mixer_UI::add_strip (RouteList& routes)
                }
 
                show_strip (strip);
-               
+
                TreeModel::Row row = *(track_model->append());
                row[track_columns.text] = route->name();
                row[track_columns.visible] = strip->marked_for_display();
@@ -334,25 +336,31 @@ Mixer_UI::add_strip (RouteList& routes)
                if (route->order_key (N_("signal")) == -1) {
                        route->set_order_key (N_("signal"), track_model->children().size()-1);
                }
-               
-               route->NameChanged.connect (bind (mem_fun(*this, &Mixer_UI::strip_name_changed), strip));
 
-               strip->GoingAway.connect (bind (mem_fun(*this, &Mixer_UI::remove_strip), strip));
-               strip->WidthChanged.connect (mem_fun(*this, &Mixer_UI::strip_width_changed));
-               strip->signal_button_release_event().connect (bind (mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
+               route->PropertyChanged.connect (*this, ui_bind (&Mixer_UI::strip_property_changed, this, _1, strip), gui_context());
+
+               strip->WidthChanged.connect (sigc::mem_fun(*this, &Mixer_UI::strip_width_changed));
+               strip->signal_button_release_event().connect (sigc::bind (sigc::mem_fun(*this, &Mixer_UI::strip_button_release_event), strip));
        }
 
        no_track_list_redisplay = false;
 
        redisplay_track_list ();
-       
+
        strip_redisplay_does_not_sync_order_keys = false;
 }
 
 void
 Mixer_UI::remove_strip (MixerStrip* strip)
 {
-       ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::remove_strip), strip));
+       if (_session && _session->deletion_in_progress()) {
+               /* its all being taken care of */
+               return;
+       }
+
+       ENSURE_GUI_THREAD (*this, &Mixer_UI::remove_strip, strip);
+
+       cerr << "Mixer UI removing strip for " << strip << endl;
 
        TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator ri;
@@ -377,34 +385,42 @@ Mixer_UI::remove_strip (MixerStrip* strip)
 void
 Mixer_UI::sync_order_keys (string const & src)
 {
-       vector<int> neworder;
        TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator ri;
 
-       if (src == N_("signal") || !session || (session->state_of_the_state() & Session::Loading) || rows.empty()) {
+       if (src == N_("signal") || !_session || (_session->state_of_the_state() & (Session::Loading|Session::Deletion)) || rows.empty()) {
                return;
        }
 
-       for (ri = rows.begin(); ri != rows.end(); ++ri) {
-               neworder.push_back (0);
-       }
+       std::map<int,int> keys;
 
        bool changed = false;
-       int order;
 
-       for (order = 0, ri = rows.begin(); ri != rows.end(); ++ri, ++order) {
+       unsigned order = 0;
+       for (ri = rows.begin(); ri != rows.end(); ++ri, ++order) {
                boost::shared_ptr<Route> route = (*ri)[track_columns.route];
-               int old_key = order;
-               int new_key = route->order_key (N_("signal"));
+               unsigned int old_key = order;
+               unsigned int new_key = route->order_key (N_("signal"));
 
-               assert (new_key < neworder.size());
-               neworder[new_key] = old_key;
+               keys[new_key] = old_key;
 
                if (new_key != old_key) {
                        changed = true;
                }
        }
 
+       if (keys.size() != rows.size()) {
+               PBD::stacktrace (cerr, 20);
+       }
+       assert(keys.size() == rows.size());
+
+       // Remove any gaps in keys caused by automation children tracks
+       vector<int> neworder;
+       for (std::map<int,int>::const_iterator i = keys.begin(); i != keys.end(); ++i) {
+               neworder.push_back(i->second);
+       }
+       assert(neworder.size() == rows.size());
+
        if (changed) {
                strip_redisplay_does_not_reset_order_keys = true;
                track_model->reorder (neworder);
@@ -429,7 +445,7 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
                   editing. XXX it needs improving so that we don't select the strip
                   at the same time.
                */
-               
+
                if (_selection.selected (strip->route())) {
                        _selection.remove (strip->route());
                } else {
@@ -445,14 +461,24 @@ Mixer_UI::strip_button_release_event (GdkEventButton *ev, MixerStrip *strip)
 }
 
 void
-Mixer_UI::connect_to_session (Session* sess)
+Mixer_UI::set_session (Session* sess)
 {
-       session = sess;
+       SessionHandlePtr::set_session (sess);
+
+       if (_plugin_selector) {
+               _plugin_selector->set_session (_session);
+       }
+
+       _group_tabs->set_session (sess);
+
+       if (!_session) {
+               return;
+       }
 
        XMLNode* node = ARDOUR_UI::instance()->mixer_settings();
        set_state (*node);
 
-       WindowTitle title(session->name());
+       WindowTitle title(_session->name());
        title += _("Mixer");
        title += Glib::get_application_name();
 
@@ -460,38 +486,41 @@ Mixer_UI::connect_to_session (Session* sess)
 
        initial_track_display ();
 
-       session->GoingAway.connect (mem_fun(*this, &Mixer_UI::disconnect_from_session));
-       session->RouteAdded.connect (mem_fun(*this, &Mixer_UI::add_strip));
-       session->route_group_added.connect (mem_fun(*this, &Mixer_UI::add_route_group));
-       session->route_group_removed.connect (mem_fun(*this, &Mixer_UI::route_groups_changed));
-       session->config.ParameterChanged.connect (mem_fun (*this, &Mixer_UI::parameter_changed));
+       _session->RouteAdded.connect (_session_connections, ui_bind (&Mixer_UI::add_strip, this, _1), gui_context());
+       _session->route_group_added.connect (_session_connections, ui_bind (&Mixer_UI::add_route_group, this, _1), gui_context());
+       _session->route_group_removed.connect (_session_connections, boost::bind (&Mixer_UI::route_groups_changed, this), gui_context());
+       _session->config.ParameterChanged.connect (_session_connections, ui_bind (&Mixer_UI::parameter_changed, this, _1), gui_context());
 
        route_groups_changed ();
-       
-       _plugin_selector->set_session (session);
 
        if (_visible) {
-              show_window();
+               show_window();
        }
 
-       _group_tabs->connect_to_session (sess);
-
        start_updating ();
 }
 
 void
-Mixer_UI::disconnect_from_session ()
+Mixer_UI::session_going_away ()
 {
-       ENSURE_GUI_THREAD(mem_fun(*this, &Mixer_UI::disconnect_from_session));
-       
+       ENSURE_GUI_THREAD (*this, &Mixer_UI::session_going_away)
+
        group_model->clear ();
        _selection.clear ();
+       track_model->clear ();
+
+       for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
+               delete (*i);
+       }
+       strips.clear ();
 
        WindowTitle title(Glib::get_application_name());
        title += _("Mixer");
        set_title (title.get_string());
-       
+
        stop_updating ();
+
+       SessionHandlePtr::session_going_away ();
 }
 
 void
@@ -499,9 +528,9 @@ Mixer_UI::show_strip (MixerStrip* ms)
 {
        TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator i;
-       
+
        for (i = rows.begin(); i != rows.end(); ++i) {
-       
+
                MixerStrip* strip = (*i)[track_columns.strip];
                if (strip == ms) {
                        (*i)[track_columns.visible] = true;
@@ -515,9 +544,9 @@ Mixer_UI::hide_strip (MixerStrip* ms)
 {
        TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator i;
-       
+
        for (i = rows.begin(); i != rows.end(); ++i) {
-               
+
                MixerStrip* strip = (*i)[track_columns.strip];
                if (strip == ms) {
                        (*i)[track_columns.visible] = false;
@@ -529,7 +558,7 @@ Mixer_UI::hide_strip (MixerStrip* ms)
 gint
 Mixer_UI::start_updating ()
 {
-    fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (mem_fun(*this, &Mixer_UI::fast_update_strips));
+    fast_screen_update_connection = ARDOUR_UI::instance()->SuperRapidScreenUpdate.connect (sigc::mem_fun(*this, &Mixer_UI::fast_update_strips));
     return 0;
 }
 
@@ -543,7 +572,7 @@ Mixer_UI::stop_updating ()
 void
 Mixer_UI::fast_update_strips ()
 {
-       if (is_mapped () && session) {
+       if (is_mapped () && _session) {
                for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
                        (*i)->fast_update ();
                }
@@ -562,11 +591,11 @@ Mixer_UI::set_all_strips_visibility (bool yn)
 
                TreeModel::Row row = (*i);
                MixerStrip* strip = row[track_columns.strip];
-               
+
                if (strip == 0) {
                        continue;
                }
-               
+
                if (strip->route()->is_master() || strip->route()->is_control()) {
                        continue;
                }
@@ -580,9 +609,9 @@ Mixer_UI::set_all_strips_visibility (bool yn)
 
 
 void
-Mixer_UI::set_all_audio_visibility (int tracks, bool yn) 
+Mixer_UI::set_all_audio_visibility (int tracks, bool yn)
 {
-        TreeModel::Children rows = track_model->children();
+       TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator i;
 
        no_track_list_redisplay = true;
@@ -605,13 +634,13 @@ Mixer_UI::set_all_audio_visibility (int tracks, bool yn)
                case 0:
                        (*i)[track_columns.visible] = yn;
                        break;
-                       
+
                case 1:
                        if (at) { /* track */
                                (*i)[track_columns.visible] = yn;
                        }
                        break;
-                       
+
                case 2:
                        if (!at) { /* bus */
                                (*i)[track_columns.visible] = yn;
@@ -662,7 +691,7 @@ void
 Mixer_UI::track_list_reorder (const TreeModel::Path&, const TreeModel::iterator&, int* /*new_order*/)
 {
        strip_redisplay_does_not_sync_order_keys = true;
-       session->set_remote_control_ids();
+       _session->set_remote_control_ids();
        redisplay_track_list ();
        strip_redisplay_does_not_sync_order_keys = false;
 }
@@ -671,8 +700,8 @@ void
 Mixer_UI::track_list_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator&)
 {
        // never reset order keys because of a property change
-       strip_redisplay_does_not_reset_order_keys = true; 
-       session->set_remote_control_ids();
+       strip_redisplay_does_not_reset_order_keys = true;
+       _session->set_remote_control_ids();
        redisplay_track_list ();
        strip_redisplay_does_not_reset_order_keys = false;
 }
@@ -681,8 +710,10 @@ void
 Mixer_UI::track_list_delete (const Gtk::TreeModel::Path&)
 {
        /* this could require an order sync */
-       session->set_remote_control_ids();
-       redisplay_track_list ();
+       if (_session && !_session->deletion_in_progress()) {
+               _session->set_remote_control_ids();
+               redisplay_track_list ();
+       }
 }
 
 void
@@ -712,7 +743,7 @@ Mixer_UI::redisplay_track_list ()
 
                        if (!strip_redisplay_does_not_reset_order_keys) {
                                strip->route()->set_order_key (N_("signal"), order);
-                       } 
+                       }
 
                        if (strip->packed()) {
 
@@ -747,13 +778,13 @@ Mixer_UI::redisplay_track_list ()
                        }
                }
        }
-       
+
        if (!strip_redisplay_does_not_reset_order_keys && !strip_redisplay_does_not_sync_order_keys) {
-               session->sync_order_keys (N_("signal"));
+               _session->sync_order_keys (N_("signal"));
        }
 
-       // Rebind all of the midi controls automatically
-       
+       // Resigc::bind all of the midi controls automatically
+
        if (auto_rebinding)
                auto_rebind_midi_controls ();
 
@@ -764,7 +795,7 @@ void
 Mixer_UI::strip_width_changed ()
 {
        _group_tabs->set_dirty ();
-       
+
 #ifdef GTKOSX
        TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator i;
@@ -778,13 +809,13 @@ Mixer_UI::strip_width_changed ()
                }
 
                bool visible = (*i)[track_columns.visible];
-               
+
                if (visible) {
                        strip->queue_draw();
                }
        }
 #endif
-       
+
 }
 
 void
@@ -802,14 +833,14 @@ Mixer_UI::set_auto_rebinding( bool val )
        }
 }
 
-void 
-Mixer_UI::toggle_auto_rebinding() 
+void
+Mixer_UI::toggle_auto_rebinding()
 {
        if (auto_rebinding)
        {
                set_auto_rebinding( FALSE );
        }
-       
+
        else
        {
                set_auto_rebinding( TRUE );
@@ -818,8 +849,8 @@ Mixer_UI::toggle_auto_rebinding()
        auto_rebind_midi_controls();
 }
 
-void 
-Mixer_UI::auto_rebind_midi_controls () 
+void
+Mixer_UI::auto_rebind_midi_controls ()
 {
        TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator i;
@@ -829,7 +860,7 @@ Mixer_UI::auto_rebind_midi_controls ()
        pos = 1;  // 0 is reserved for the master strip
        for (i = rows.begin(); i != rows.end(); ++i) {
                MixerStrip* strip = (*i)[track_columns.strip];
-    
+
                if ( (*i)[track_columns.visible] == true ) {  // add bindings for
                        // make the actual binding
                        //cout<<"Auto Binding:  Visible Strip Found: "<<strip->name()<<endl;
@@ -866,7 +897,7 @@ Mixer_UI::auto_rebind_midi_controls ()
                }
 
        } // for
-  
+
 }
 
 struct SignalOrderRouteSorter {
@@ -879,12 +910,12 @@ struct SignalOrderRouteSorter {
 void
 Mixer_UI::initial_track_display ()
 {
-       boost::shared_ptr<RouteList> routes = session->get_routes();
+       boost::shared_ptr<RouteList> routes = _session->get_routes();
        RouteList copy (*routes);
        SignalOrderRouteSorter sorter;
 
        copy.sort (sorter);
-       
+
        no_track_list_redisplay = true;
 
        track_model->clear ();
@@ -919,7 +950,7 @@ Mixer_UI::track_display_button_press (GdkEventButton* ev)
        TreeViewColumn* column;
        int cellx;
        int celly;
-       
+
        if (!track_display.get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
                return false;
        }
@@ -963,30 +994,34 @@ Mixer_UI::build_track_menu ()
        track_menu = new Menu;
        track_menu->set_name ("ArdourContextMenu");
        MenuList& items = track_menu->items();
-       
-       items.push_back (MenuElem (_("Show All"), mem_fun(*this, &Mixer_UI::show_all_routes)));
-       items.push_back (MenuElem (_("Hide All"), mem_fun(*this, &Mixer_UI::hide_all_routes)));
-       items.push_back (MenuElem (_("Show All Audio Tracks"), mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
-       items.push_back (MenuElem (_("Hide All Audio Tracks"), mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
-       items.push_back (MenuElem (_("Show All Audio Busses"), mem_fun(*this, &Mixer_UI::show_all_audiobus)));
-       items.push_back (MenuElem (_("Hide All Audio Busses"), mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
+
+       items.push_back (MenuElem (_("Show All"), sigc::mem_fun(*this, &Mixer_UI::show_all_routes)));
+       items.push_back (MenuElem (_("Hide All"), sigc::mem_fun(*this, &Mixer_UI::hide_all_routes)));
+       items.push_back (MenuElem (_("Show All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiotracks)));
+       items.push_back (MenuElem (_("Hide All Audio Tracks"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiotracks)));
+       items.push_back (MenuElem (_("Show All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::show_all_audiobus)));
+       items.push_back (MenuElem (_("Hide All Audio Busses"), sigc::mem_fun(*this, &Mixer_UI::hide_all_audiobus)));
 
 }
 
 void
-Mixer_UI::strip_name_changed (MixerStrip* mx)
+Mixer_UI::strip_property_changed (const PropertyChange& what_changed, MixerStrip* mx)
 {
-       ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::strip_name_changed), mx));
-       
+       if (!what_changed.contains (ARDOUR::Properties::name)) {
+               return;
+       }
+
+       ENSURE_GUI_THREAD (*this, &Mixer_UI::strip_name_changed, what_changed, mx)
+
        TreeModel::Children rows = track_model->children();
        TreeModel::Children::iterator i;
-       
+
        for (i = rows.begin(); i != rows.end(); ++i) {
                if ((*i)[track_columns.strip] == mx) {
                        (*i)[track_columns.text] = mx->route()->name();
                        return;
                }
-       } 
+       }
 
        error << _("track display list item for renamed strip not found!") << endmsg;
 }
@@ -1001,11 +1036,11 @@ Mixer_UI::build_route_group_context_menu ()
        route_group_context_menu->set_name ("ArdourContextMenu");
        MenuList& items = route_group_context_menu->items();
 
-       items.push_back (MenuElem (_("Activate All"), mem_fun(*this, &Mixer_UI::activate_all_route_groups)));
-       items.push_back (MenuElem (_("Disable All"), mem_fun(*this, &Mixer_UI::disable_all_route_groups)));
+       items.push_back (MenuElem (_("Activate All"), sigc::mem_fun(*this, &Mixer_UI::activate_all_route_groups)));
+       items.push_back (MenuElem (_("Disable All"), sigc::mem_fun(*this, &Mixer_UI::disable_all_route_groups)));
        items.push_back (SeparatorElem());
-       items.push_back (MenuElem (_("Add group"), mem_fun(*this, &Mixer_UI::new_route_group)));
-       
+       items.push_back (MenuElem (_("Add group"), sigc::mem_fun(*this, &Mixer_UI::new_route_group)));
+
 }
 
 bool
@@ -1043,8 +1078,8 @@ Mixer_UI::group_display_button_press (GdkEventButton* ev)
                                        return true;
                                }
                        }
-                       
-               } 
+
+               }
                break;
 
        case 1:
@@ -1061,26 +1096,26 @@ Mixer_UI::group_display_button_press (GdkEventButton* ev)
        default:
                break;
        }
-       
+
        return false;
  }
 
 void
 Mixer_UI::activate_all_route_groups ()
 {
-       session->foreach_route_group (bind (mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
+       _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), true));
 }
 
 void
 Mixer_UI::disable_all_route_groups ()
 {
-       session->foreach_route_group (bind (mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
+       _session->foreach_route_group (sigc::bind (sigc::mem_fun (*this, &Mixer_UI::set_route_group_activation), false));
 }
 
 void
 Mixer_UI::route_groups_changed ()
 {
-       ENSURE_GUI_THREAD (mem_fun (*this, &Mixer_UI::route_groups_changed));
+       ENSURE_GUI_THREAD (*this, &Mixer_UI::route_groups_changed)
 
        /* just rebuild the while thing */
 
@@ -1094,13 +1129,23 @@ Mixer_UI::route_groups_changed ()
                row[group_columns.group] = 0;
        }
 
-       session->foreach_route_group (mem_fun (*this, &Mixer_UI::add_route_group));
+       _session->foreach_route_group (sigc::mem_fun (*this, &Mixer_UI::add_route_group));
 }
 
 void
 Mixer_UI::new_route_group ()
 {
-       session->add_route_group (new RouteGroup (*session, "", RouteGroup::Active, (RouteGroup::Property) (RouteGroup::Gain |RouteGroup::Mute | RouteGroup::Solo)));
+       PropertyList plist;
+
+       plist.add (Properties::active, true);
+       plist.add (Properties::gain, true);
+       plist.add (Properties::mute, true);
+       plist.add (Properties::solo, true);
+
+       RouteGroup* g = new RouteGroup (*_session, "");
+       g->set_properties (plist);
+
+       _session->add_route_group (g);
 }
 
 void
@@ -1115,7 +1160,7 @@ Mixer_UI::remove_selected_route_group ()
 
        TreeView::Selection::ListHandle_Path::iterator i = rows.begin();
        TreeIter iter;
-       
+
        /* selection mode is single, so rows.begin() is it */
 
        if ((iter = group_model->get_iter (*i))) {
@@ -1123,7 +1168,7 @@ Mixer_UI::remove_selected_route_group ()
                RouteGroup* rg = (*iter)[group_columns.group];
 
                if (rg) {
-                       session->remove_route_group (*rg);
+                       _session->remove_route_group (*rg);
                }
        }
 }
@@ -1135,24 +1180,24 @@ Mixer_UI::group_flags_changed (void* src, RouteGroup* group)
                return;
        }
 
-       ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::group_flags_changed), src, group));
+       ENSURE_GUI_THREAD (*this, &Mixer_UI::group_flags_changed, src, group)
 
        /* force an update of any mixer strips that are using this group,
-          otherwise mix group names don't change in mixer strips 
+          otherwise mix group names don't change in mixer strips
        */
 
        for (list<MixerStrip *>::iterator i = strips.begin(); i != strips.end(); ++i) {
                if ((*i)->route_group() == group) {
-                       (*i)->route_group_changed(0);
+                       (*i)->route_group_changed();
                }
        }
-       
+
        TreeModel::iterator i;
        TreeModel::Children rows = group_model->children();
        Glib::RefPtr<TreeSelection> selection = group_display.get_selection();
 
        in_group_row_change = true;
-       
+
        for (i = rows.begin(); i != rows.end(); ++i) {
                if ((*i)[group_columns.group] == group) {
                        (*i)[group_columns.visible] = !group->is_hidden ();
@@ -1173,18 +1218,18 @@ Mixer_UI::route_group_name_edit (const Glib::ustring& path, const Glib::ustring&
        TreeIter iter;
 
        if ((iter = group_model->get_iter (path))) {
-       
+
                if ((group = (*iter)[group_columns.group]) == 0) {
                        return;
                }
-               
+
                if (new_text != group->name()) {
                        group->set_name (new_text);
                }
        }
 }
 
-void 
+void
 Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeModel::iterator& iter)
 {
        RouteGroup* group;
@@ -1209,7 +1254,7 @@ Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeMo
                                hide_strip (*i);
                        }
                }
-       } 
+       }
 
        Glib::ustring name = (*iter)[group_columns.text];
 
@@ -1222,7 +1267,7 @@ Mixer_UI::route_group_row_change (const Gtk::TreeModel::Path&, const Gtk::TreeMo
 void
 Mixer_UI::add_route_group (RouteGroup* group)
 {
-       ENSURE_GUI_THREAD(bind (mem_fun(*this, &Mixer_UI::add_route_group), group));
+       ENSURE_GUI_THREAD (*this, &Mixer_UI::add_route_group, group)
        bool focus = false;
 
        in_group_row_change = true;
@@ -1237,8 +1282,8 @@ Mixer_UI::add_route_group (RouteGroup* group)
                focus = true;
        }
 
-       group->FlagsChanged.connect (bind (mem_fun(*this, &Mixer_UI::group_flags_changed), group));
-       
+       group->FlagsChanged.connect (*this, ui_bind (&Mixer_UI::group_flags_changed, this, _1, group), gui_context());
+
        if (focus) {
                TreeViewColumn* col = group_display.get_column (0);
                CellRendererText* name_cell = dynamic_cast<CellRendererText*>(group_display.get_column_cell_renderer (0));
@@ -1290,12 +1335,12 @@ Mixer_UI::set_state (const XMLNode& node)
 {
        const XMLProperty* prop;
        XMLNode* geometry;
-       
+
        m_width = default_width;
        m_height = default_height;
        m_root_x = 1;
        m_root_y = 1;
-       
+
        if ((geometry = find_named_node (node, "geometry")) != 0) {
 
                XMLProperty* prop;
@@ -1318,7 +1363,7 @@ Mixer_UI::set_state (const XMLNode& node)
                }
                if (prop) {
                        m_root_x = atoi (prop->value());
-                       
+
                }
                if ((prop = geometry->property ("y_pos")) == 0) {
                        prop = geometry->property ("y-pos");
@@ -1331,7 +1376,7 @@ Mixer_UI::set_state (const XMLNode& node)
        set_window_pos_and_size ();
 
        if ((prop = node.property ("narrow-strips"))) {
-               if (prop->value() == "yes") {
+               if (string_is_affirmative (prop->value())) {
                        set_strip_width (Narrow);
                } else {
                        set_strip_width (Wide);
@@ -1339,7 +1384,7 @@ Mixer_UI::set_state (const XMLNode& node)
        }
 
        if ((prop = node.property ("show-mixer"))) {
-               if (prop->value() == "yes") {
+               if (string_is_affirmative (prop->value())) {
                       _visible = true;
                }
        }
@@ -1354,7 +1399,7 @@ Mixer_UI::get_state (void)
 
        if (is_realized()) {
                Glib::RefPtr<Gdk::Window> win = get_window();
-       
+
                get_window_pos_and_size ();
 
                XMLNode* geometry = new XMLNode ("geometry");
@@ -1367,7 +1412,7 @@ Mixer_UI::get_state (void)
                geometry->add_property(X_("x_pos"), string(buf));
                snprintf(buf, sizeof(buf), "%d", m_root_y);
                geometry->add_property(X_("y_pos"), string(buf));
-               
+
                // written only for compatibility, they are not used.
                snprintf(buf, sizeof(buf), "%d", 0);
                geometry->add_property(X_("x_off"), string(buf));
@@ -1390,7 +1435,7 @@ Mixer_UI::get_state (void)
 }
 
 
-void 
+void
 Mixer_UI::pane_allocation_handler (Allocation&, Gtk::Paned* which)
 {
        int pos;
@@ -1456,10 +1501,38 @@ Mixer_UI::pane_allocation_handler (Allocation&, Gtk::Paned* which)
                }
        }
 }
+void
+Mixer_UI::scroll_left () 
+{
+       Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
+       /* stupid GTK: can't rely on clamping across versions */
+       scroller.get_hscrollbar()->set_value (max (adj->get_lower(), adj->get_value() - adj->get_step_increment()));
+}
+
+void
+Mixer_UI::scroll_right ()
+{
+       Adjustment* adj = scroller.get_hscrollbar()->get_adjustment();
+       /* stupid GTK: can't rely on clamping across versions */
+       scroller.get_hscrollbar()->set_value (min (adj->get_upper(), adj->get_value() + adj->get_step_increment()));
+}
 
 bool
 Mixer_UI::on_key_press_event (GdkEventKey* ev)
 {
+       switch (ev->keyval) {
+       case GDK_Left:
+               scroll_left ();
+               return true;
+
+       case GDK_Right:
+               scroll_right ();
+               return true;
+
+       default:
+               break;
+       }
+
        return key_press_focus_accelerator_handler (*this, ev);
 }
 
@@ -1470,11 +1543,42 @@ Mixer_UI::on_key_release_event (GdkEventKey* ev)
        // return key_press_focus_accelerator_handler (*this, ev);
 }
 
+
+bool
+Mixer_UI::on_scroll_event (GdkEventScroll* ev)
+{
+       switch (ev->direction) {
+       case GDK_SCROLL_LEFT:
+               scroll_left ();
+               return true;
+       case GDK_SCROLL_UP:
+               if (ev->state & Keyboard::TertiaryModifier) {
+                       scroll_left ();
+                       return true;
+               }
+               return false;
+
+       case GDK_SCROLL_RIGHT:
+               scroll_right ();
+               return true;
+
+       case GDK_SCROLL_DOWN:
+               if (ev->state & Keyboard::TertiaryModifier) {
+                       scroll_right ();
+                       return true;
+               }
+               return false;
+       }
+
+       return false;
+}
+
+
 void
 Mixer_UI::parameter_changed (string const & p)
 {
        if (p == "show-group-tabs") {
-               bool const s = session->config.get_show_group_tabs ();
+               bool const s = _session->config.get_show_group_tabs ();
                if (s) {
                        _group_tabs->show ();
                } else {
@@ -1482,10 +1586,20 @@ Mixer_UI::parameter_changed (string const & p)
                }
        }
 }
-               
+
 void
 Mixer_UI::set_route_group_activation (RouteGroup* g, bool a)
 {
        g->set_active (a, this);
 }
-               
+
+PluginSelector*
+Mixer_UI::plugin_selector()
+{
+#ifdef DEFER_PLUGIN_SELECTOR_LOAD
+       if (!_plugin_selector)
+               _plugin_selector = new PluginSelector (PluginManager::the_manager ());
+#endif
+
+       return _plugin_selector;
+}