replace ::cast_dynamic() with relevant ActionManager::get_*_action() calls
[ardour.git] / gtk2_ardour / monitor_section.cc
index 6f7caf99e6e5f966a25de992bc13a4d7be199954..7a304d96ace37b62b72902175c81be3f32c2ecc9 100644 (file)
@@ -1,19 +1,19 @@
 /*
-    Copyright (C) 2012 Paul Davis
+  Copyright (C) 2012 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
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
+  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
+  the Free Software Foundation; either version 2 of the License, or
+  (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
 
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+  You should have received a copy of the GNU General Public License
+  along with this program; if not, write to the Free Software
+  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 */
 
 #include "pbd/error.h"
 #include "pbd/replace_all.h"
 
-#include "gtkmm2ext/bindable_button.h"
-#include "gtkmm2ext/tearoff.h"
 #include "gtkmm2ext/actions.h"
-#include "gtkmm2ext/motionfeedback.h"
 #include "gtkmm2ext/utils.h"
 
 #include <gtkmm/menu.h>
 #include <gtkmm/menuitem.h>
 
+#include "widgets/tearoff.h"
+#include "widgets/tooltips.h"
+
+#include "ardour/amp.h"
 #include "ardour/audioengine.h"
 #include "ardour/monitor_processor.h"
 #include "ardour/port.h"
 #include "ardour/route.h"
+#include "ardour/solo_isolate_control.h"
 #include "ardour/user_bundle.h"
 #include "ardour/plugin_manager.h"
 
+#include "ardour_ui.h"
 #include "gui_thread.h"
+#include "mixer_ui.h"
 #include "monitor_section.h"
 #include "public_editor.h"
 #include "timers.h"
-#include "tooltips.h"
-#include "volume_controller.h"
 #include "ui_config.h"
 #include "utils.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace ARDOUR;
+using namespace ArdourWidgets;
 using namespace ARDOUR_UI_UTILS;
 using namespace Gtk;
 using namespace Gtkmm2ext;
 using namespace PBD;
 using namespace std;
 
-Glib::RefPtr<ActionGroup> MonitorSection::monitor_actions;
-
 #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
 
-MonitorSection::MonitorSection (Session* s)
-       : AxisView (s)
-       , RouteUI (s)
+MonitorSection::MonitorSection ()
+       : RouteUI ((Session*) 0)
        , _tearoff (0)
+       , channel_table (0)
        , channel_table_viewport (*channel_table_scroller.get_hadjustment()
-       , *channel_table_scroller.get_vadjustment ())
+                                 , *channel_table_scroller.get_vadjustment ())
        , gain_control (0)
        , dim_control (0)
        , solo_boost_control (0)
@@ -81,20 +82,25 @@ MonitorSection::MonitorSection (Session* s)
        , pfl_button (_("PFL"), ArdourButton::led_default_elements)
        , exclusive_solo_button (ArdourButton::led_default_elements)
        , solo_mute_override_button (ArdourButton::led_default_elements)
+       , toggle_processorbox_button (ArdourButton::default_elements)
        , _inhibit_solo_model_update (false)
+       , _rr_selection ()
+       , _ui_initialized (false)
 {
-
+       /* note that although this a RouteUI, we never called ::set_route() so
+        * we do not need to worry about self-destructing when the Route (the
+        * monitor out) is destroyed.
+        */
+       
        using namespace Menu_Helpers;
 
        Glib::RefPtr<Action> act;
 
-       if (!monitor_actions) {
+       load_bindings ();
+       register_actions ();
+       set_data ("ardour-bindings", bindings);
 
-               /* do some static stuff */
-
-               register_actions ();
-
-       }
+       channel_size_group = SizeGroup::create (SIZE_GROUP_HORIZONTAL);
 
        _plugin_selector = new PluginSelector (PluginManager::instance());
        insert_box = new ProcessorBox (_session, boost::bind (&MonitorSection::plugin_selector, this), _rr_selection, 0);
@@ -102,8 +108,6 @@ MonitorSection::MonitorSection (Session* s)
        insert_box->show ();
        // TODO allow keyboard shortcuts in ProcessorBox
 
-       set_session (s);
-
        /* Rude Solo  & Solo Isolated */
        rude_solo_button.set_text (_("Soloing"));
        rude_solo_button.set_name ("rude solo");
@@ -119,8 +123,6 @@ MonitorSection::MonitorSection (Session* s)
 
        Timers::blink_connect (sigc::mem_fun (*this, &MonitorSection::do_blink));
 
-       act = ActionManager::get_action (X_("Main"), X_("cancel-solo"));
-       rude_solo_button.set_related_action (act);
        UI::instance()->set_tip (rude_solo_button, _("When active, something is soloed.\nClick to de-solo everything"));
 
        rude_iso_button.signal_button_press_event().connect (sigc::mem_fun(*this, &MonitorSection::cancel_isolate), false);
@@ -163,23 +165,27 @@ MonitorSection::MonitorSection (Session* s)
 
        /* Solo option buttons */
        exclusive_solo_button.set_text (_("Excl. Solo"));
-       exclusive_solo_button.set_name (X_("monitor solo exclusive"));
+       exclusive_solo_button.set_name (X_("monitor section solo option"));
        set_tooltip (&exclusive_solo_button, _("Exclusive solo means that only 1 solo is active at a time"));
 
-       act = ActionManager::get_action (X_("Monitor"), X_("toggle-exclusive-solo"));
+       act = ActionManager::get_action (X_("Solo"), X_("toggle-exclusive-solo"));
        if (act) {
                exclusive_solo_button.set_related_action (act);
        }
 
        solo_mute_override_button.set_text (_("Solo ยป Mute"));
-       solo_mute_override_button.set_name (X_("monitor solo override"));
+       solo_mute_override_button.set_name (X_("monitor section solo option"));
        set_tooltip (&solo_mute_override_button, _("If enabled, solo will override mute\n(a soloed & muted track or bus will be audible)"));
 
-       act = ActionManager::get_action (X_("Monitor"), X_("toggle-mute-overrides-solo"));
-       if (act) {
-               solo_mute_override_button.set_related_action (act);
-       }
+       solo_mute_override_button.set_related_action (ActionManager::get_action (X_("Solo"), X_("toggle-mute-overrides-solo")));
+
+       /* Processor Box hide/shos */
+       toggle_processorbox_button.set_text (_("Processors"));
+       toggle_processorbox_button.set_name (X_("monitor section processors toggle"));
+       set_tooltip (&toggle_processorbox_button, _("Allow one to add monitor effect processors"));
 
+       proctoggle = ActionManager::get_toggle_action (X_("Monitor"), X_("toggle-monitor-processor-box"));
+       toggle_processorbox_button.set_related_action (proctoggle);
 
        /* Knobs */
        Label* solo_boost_label;
@@ -189,12 +195,11 @@ MonitorSection::MonitorSection (Session* s)
        /* Solo Boost Knob */
 
        solo_boost_control = new ArdourKnob ();
-       solo_boost_control->set_name("monitor knob");
+       solo_boost_control->set_name("monitor section knob");
        solo_boost_control->set_size_request (PX_SCALE(36), PX_SCALE(36));
        set_tooltip (*solo_boost_control, _("Gain increase for soloed signals (0dB is normal)"));
 
        solo_boost_display = new ArdourDisplay ();
-       solo_boost_display->set_name("monitor section cut");
        solo_boost_display->set_size_request (PX_SCALE(68), PX_SCALE(20));
        solo_boost_display->add_controllable_preset(_("0 dB"), 0.0);
        solo_boost_display->add_controllable_preset(_("3 dB"), 3.0);
@@ -206,12 +211,12 @@ MonitorSection::MonitorSection (Session* s)
        /* Solo (SiP) cut */
 
        solo_cut_control = new ArdourKnob ();
-       solo_cut_control->set_name ("monitor knob");
+       solo_cut_control->set_name ("monitor section knob");
        solo_cut_control->set_size_request (PX_SCALE(36), PX_SCALE(36));
        set_tooltip (*solo_cut_control, _("Gain reduction non-soloed signals\nA value above -inf dB causes \"solo-in-front\""));
 
        solo_cut_display = new ArdourDisplay ();
-       solo_cut_display->set_name("monitor section cut");
+       solo_cut_display->set_name("monitor section dropdown"); // XXX
        solo_cut_display->set_size_request (PX_SCALE(68), PX_SCALE(20));
        solo_cut_display->add_controllable_preset(_("0 dB"), 0.0);
        solo_cut_display->add_controllable_preset(_("-6 dB"), -6.0);
@@ -224,12 +229,11 @@ MonitorSection::MonitorSection (Session* s)
        /* Dim */
 
        dim_control = new ArdourKnob (ArdourKnob::default_elements, ArdourKnob::Detent);
-       dim_control->set_name ("monitor knob");
+       dim_control->set_name ("monitor section knob");
        dim_control->set_size_request (PX_SCALE(36), PX_SCALE(36));
        set_tooltip (*dim_control, _("Gain reduction to use when dimming monitor outputs"));
 
        dim_display = new ArdourDisplay ();
-       dim_display->set_name("monitor section cut");
        dim_display->set_size_request (PX_SCALE(68), PX_SCALE(20));
        dim_display->add_controllable_preset(_("0 dB"), 0.0);
        dim_display->add_controllable_preset(_("-3 dB"), -3.0);
@@ -241,8 +245,7 @@ MonitorSection::MonitorSection (Session* s)
 
        // mute button
        cut_all_button.set_text (_("Mute"));
-       cut_all_button.set_name ("monitor section cut");
-       cut_all_button.set_name (X_("monitor section cut"));
+       cut_all_button.set_name ("mute button");
        cut_all_button.set_size_request (-1, PX_SCALE(30));
        cut_all_button.show ();
 
@@ -254,7 +257,7 @@ MonitorSection::MonitorSection (Session* s)
        // dim button
        dim_all_button.set_text (_("Dim"));
        dim_all_button.set_name ("monitor section dim");
-       dim_all_button.set_size_request (-1, PX_SCALE(30));
+       dim_all_button.set_size_request (-1, PX_SCALE(25));
        act = ActionManager::get_action (X_("Monitor"), X_("monitor-dim-all"));
        if (act) {
                dim_all_button.set_related_action (act);
@@ -263,7 +266,7 @@ MonitorSection::MonitorSection (Session* s)
        // mono button
        mono_button.set_text (_("Mono"));
        mono_button.set_name ("monitor section mono");
-       mono_button.set_size_request (-1, PX_SCALE(30));
+       mono_button.set_size_request (-1, PX_SCALE(25));
        act = ActionManager::get_action (X_("Monitor"), X_("monitor-mono"));
        if (act) {
                mono_button.set_related_action (act);
@@ -272,11 +275,10 @@ MonitorSection::MonitorSection (Session* s)
        /* Gain */
 
        gain_control = new ArdourKnob (ArdourKnob::default_elements, ArdourKnob::Detent);
-       gain_control->set_name("monitor knob");
+       gain_control->set_name("monitor section knob");
        gain_control->set_size_request (PX_SCALE(60), PX_SCALE(60));
 
        gain_display = new ArdourDisplay ();
-       gain_display->set_name("monitor section cut");
        gain_display->set_size_request (PX_SCALE(68), PX_SCALE(20));
        gain_display->add_controllable_preset(_("0 dB"), 0.0);
        gain_display->add_controllable_preset(_("-3 dB"), -3.0);
@@ -290,7 +292,7 @@ MonitorSection::MonitorSection (Session* s)
 
        output_button = new ArdourButton ();
        output_button->set_text (_("Output"));
-       output_button->set_name (X_("monitor section cut"));
+       output_button->set_name (X_("monitor section cut")); // XXX
        output_button->set_text_ellipsize (Pango::ELLIPSIZE_MIDDLE);
        output_button->set_layout_ellipsize_width (PX_SCALE(128) * PANGO_SCALE);
 
@@ -300,10 +302,7 @@ MonitorSection::MonitorSection (Session* s)
        channel_table_scroller.show ();
        channel_table_scroller.add (channel_table_viewport);
 
-       channel_size_group  = SizeGroup::create (SIZE_GROUP_HORIZONTAL);
        channel_size_group->add_widget (channel_table_header);
-       channel_size_group->add_widget (channel_table);
-
        channel_table_header.resize (1, 5);
 
        Label* l1 = manage (new Label (X_("  ")));
@@ -347,6 +346,9 @@ MonitorSection::MonitorSection (Session* s)
        HBox* tbx2 = manage (new HBox);
        tbx2->pack_end (solo_mute_override_button, false, false);
 
+       HBox* tbx3 = manage (new HBox);
+       tbx3->pack_end (toggle_processorbox_button, false, false);
+
        HBox* tbx0 = manage (new HBox); // space
 
        // combined solo mode (Sip, AFL, PFL) & solo options
@@ -355,8 +357,9 @@ MonitorSection::MonitorSection (Session* s)
        solo_tbl->attach (pfl_button,             0, 1, 1, 2, EXPAND|FILL, SHRINK, 0, 2);
        solo_tbl->attach (afl_button,             0, 1, 2, 3, EXPAND|FILL, SHRINK, 0, 2);
        solo_tbl->attach (*tbx0,                  1, 2, 0, 3, EXPAND|FILL, SHRINK, 2, 2);
-       solo_tbl->attach (*tbx1,                  2, 3, 1, 2, EXPAND|FILL, SHRINK, 0, 2);
-       solo_tbl->attach (*tbx2,                  2, 3, 2, 3, EXPAND|FILL, SHRINK, 0, 2);
+       solo_tbl->attach (*tbx1,                  2, 3, 0, 1, EXPAND|FILL, SHRINK, 0, 2);
+       solo_tbl->attach (*tbx2,                  2, 3, 1, 2, EXPAND|FILL, SHRINK, 0, 2);
+       solo_tbl->attach (*tbx3,                  2, 3, 2, 3, EXPAND|FILL, SHRINK, 0, 2);
 
        // boost, cut, dim  volume control
        Table *level_tbl = manage (new Table);
@@ -372,10 +375,6 @@ MonitorSection::MonitorSection (Session* s)
        level_tbl->attach (*dim_control,         1, 3, 4, 5, EXPAND|FILL, SHRINK, 1, 2);
        level_tbl->attach (*dim_display,         1, 3, 5, 6, EXPAND     , SHRINK, 1, 2);
 
-       /* note that we don't pack the table_hpacker till later
-        * -> top level channel_table_packer */
-       table_hpacker.pack_start (channel_table, true, true);
-
        // mono, dim
        HBox* mono_dim_box = manage (new HBox);
        mono_dim_box->set_spacing (PX_SCALE(4));
@@ -383,7 +382,7 @@ MonitorSection::MonitorSection (Session* s)
        mono_dim_box->pack_start (mono_button, true, true);
        mono_dim_box->pack_end (dim_all_button, true, true);
 
-       // master gain 
+       // master gain
        Label* spin_label = manage (new Label (_("Monitor")));
        VBox* spin_packer = manage (new VBox);
        spin_packer->set_spacing (PX_SCALE(2));
@@ -391,19 +390,28 @@ MonitorSection::MonitorSection (Session* s)
        spin_packer->pack_start (*gain_control, false, false);
        spin_packer->pack_start (*gain_display, false, false);
 
-       HBox* master_box = manage (new HBox);
-       master_box->pack_start (*spin_packer, true, false);
+       master_packer.pack_start (*spin_packer, true, false);
 
-       // combined gain section (channels, mute, dim, master)
+       // combined gain section (channels, mute, dim)
        VBox* lower_packer = manage (new VBox);
-       lower_packer->set_spacing (PX_SCALE(8));
-       lower_packer->pack_start (channel_table_header, false, false);
-       lower_packer->pack_start (channel_table_packer, false, false);
-       lower_packer->pack_start (*mono_dim_box, false, false);
-       lower_packer->pack_start (cut_all_button, false, false);
-       lower_packer->pack_start (*master_box, false, false, PX_SCALE(10));
-
-               // output port select
+       lower_packer->pack_start (channel_table_header, false, false, PX_SCALE(0));
+       lower_packer->pack_start (channel_table_packer, false, false, PX_SCALE(8));
+       lower_packer->pack_start (*mono_dim_box,        false, false, PX_SCALE(2));
+       lower_packer->pack_start (cut_all_button,       false, false, PX_SCALE(2));
+
+       // calc height of mixer scrollbar
+       int scrollbar_height = 0;
+       {
+               Gtk::Window window (WINDOW_TOPLEVEL);
+               HScrollbar scrollbar;
+               window.add (scrollbar);
+               scrollbar.set_name ("MixerWindow");
+               scrollbar.ensure_style();
+               Gtk::Requisition requisition(scrollbar.size_request ());
+               scrollbar_height = requisition.height;
+       }
+
+       // output port select
        VBox* out_packer = manage (new VBox);
        out_packer->set_spacing (PX_SCALE(2));
        out_packer->pack_start (*output_label, false, false);
@@ -412,18 +420,26 @@ MonitorSection::MonitorSection (Session* s)
        /****************************************************************************
         * TOP LEVEL LAYOUT
         */
-       VBox* vpacker = manage (new VBox);
-       vpacker->set_border_width (PX_SCALE(3));
-       vpacker->set_spacing (PX_SCALE(10));
-       vpacker->pack_start (*rude_box, false, false, PX_SCALE(3));
-       vpacker->pack_start (*solo_tbl, false, false);
-       vpacker->pack_start (*level_tbl, false, false);
-       vpacker->pack_start (*lower_packer, false, false);
-       vpacker->pack_start (*insert_box, true, true);
-       vpacker->pack_end   (*out_packer, false, false);
+       vpacker.set_border_width (PX_SCALE(3));
+       vpacker.pack_start (*rude_box,            false, false, PX_SCALE(3));
+       vpacker.pack_start (rude_audition_button, false, false, 0);
+       vpacker.pack_start (*solo_tbl,            false, false, PX_SCALE(8));
+       vpacker.pack_start (*insert_box,          true,  true,  PX_SCALE(8));
+       vpacker.pack_start (*level_tbl,           false, false, PX_SCALE(8));
+       vpacker.pack_start (*lower_packer,        false, false, PX_SCALE(8));
+       vpacker.pack_start (master_packer,        false, false, PX_SCALE(10));
+       vpacker.pack_end   (*out_packer,          false, false,
+#ifdef MIXBUS
+                       scrollbar_height - 2 /* no outer sample */
+#else
+                       scrollbar_height + 2 /* sample borders */
+#endif
+                       );
 
        hpacker.set_spacing (0);
-       hpacker.pack_start (*vpacker, true, true);
+       hpacker.pack_start (vpacker, true, true);
+
+       add (hpacker);
 
        gain_control->show_all ();
        gain_display->show_all ();
@@ -434,8 +450,7 @@ MonitorSection::MonitorSection (Session* s)
 
        mono_dim_box->show ();
        spin_packer->show ();
-       master_box->show ();
-       channel_table.show ();
+       master_packer.show ();
 
        rude_box->show();
        solo_tbl->show_all();
@@ -443,17 +458,20 @@ MonitorSection::MonitorSection (Session* s)
        lower_packer->show ();
        out_packer->show ();
 
-       vpacker->show ();
+       vpacker.show ();
        hpacker.show ();
 
-       populate_buttons ();
        map_state ();
        assign_controllables ();
 
        output_button->signal_button_press_event().connect (sigc::mem_fun(*this, &MonitorSection::output_press), false);
        output_button->signal_button_release_event().connect (sigc::mem_fun(*this, &MonitorSection::output_release), false);
 
-       _tearoff = new TearOff (hpacker);
+       signal_enter_notify_event().connect (sigc::mem_fun (*this, &MonitorSection::enter_handler));
+       signal_leave_notify_event().connect (sigc::mem_fun (*this, &MonitorSection::leave_handler));
+       set_flags (CAN_FOCUS);
+
+       _tearoff = new TearOff (*this);
 
        if (!UIConfiguration::instance().get_floating_monitor_section()) {
                /* if torn off, make this a normal window
@@ -462,9 +480,11 @@ MonitorSection::MonitorSection (Session* s)
                _tearoff->tearoff_window().set_type_hint (Gdk::WINDOW_TYPE_HINT_NORMAL);
        }
        _tearoff->tearoff_window().set_title (X_("Monitor"));
-       _tearoff->tearoff_window().signal_key_press_event().connect (sigc::ptr_fun (forward_key_press), false);
+       _tearoff->tearoff_window().signal_key_press_event().connect (sigc::bind (sigc::ptr_fun (relay_key_press), (Gtk::Window*) &_tearoff->tearoff_window()), false);
 
-       update_output_display();
+       update_output_display ();
+       update_processor_box ();
+       _ui_initialized = true;
 
        /* catch changes that affect us */
        AudioEngine::instance()->PortConnectedOrDisconnected.connect (
@@ -480,107 +500,172 @@ MonitorSection::~MonitorSection ()
        }
 
        _channel_buttons.clear ();
-       _output_changed_connection.disconnect ();
-
-       delete insert_box;
-       delete output_button;
-       delete gain_control;
-       delete gain_display;
-       delete dim_control;
-       delete dim_display;
-       delete solo_boost_control;
-       delete solo_boost_display;
-       delete solo_cut_control;
-       delete solo_cut_display;
-       delete _tearoff;
-       delete _output_selector;
-       _output_selector = 0;
+       output_changed_connections.drop_connections ();
+
+       delete insert_box; insert_box = 0;
+       delete output_button; output_button = 0;
+       delete gain_control; gain_control = 0;
+       delete gain_display; gain_display = 0;
+       delete dim_control; dim_control = 0;
+       delete dim_display; dim_display = 0;
+       delete solo_boost_control; solo_boost_control = 0;
+       delete solo_boost_display; solo_boost_display = 0;
+       delete solo_cut_control; solo_cut_control = 0;
+       delete solo_cut_display; solo_cut_display = 0;
+       delete _tearoff; _tearoff = 0;
+       delete _output_selector; _output_selector = 0;
+       delete channel_table; channel_table = 0;
+}
+
+bool
+MonitorSection::enter_handler (GdkEventCrossing* ev)
+{
+       grab_focus ();
+       return false;
+}
+
+bool
+MonitorSection::leave_handler (GdkEventCrossing* ev)
+{
+       switch (ev->detail) {
+       case GDK_NOTIFY_INFERIOR:
+               return false;
+       default:
+               break;
+       }
+
+       /* cancel focus if we're not torn off. With X11 WM's that do
+        * focus-follows-mouse, focus will be taken from us anyway.
+        */
+
+       Widget* top = get_toplevel();
+
+       if (top->is_toplevel() && top != &_tearoff->tearoff_window()) {
+               Window* win = dynamic_cast<Window*> (top);
+               gtk_window_set_focus (win->gobj(), 0);
+       }
+
+       return false;
+}
+
+void
+MonitorSection::update_processor_box ()
+{
+       bool show_processor_box = proctoggle->get_active ();
+
+       if (count_processors () > 0 && !show_processor_box) {
+               toggle_processorbox_button.set_name (X_("monitor section processors present"));
+       } else {
+               toggle_processorbox_button.set_name (X_("monitor section processors toggle"));
+       }
+
+       if (insert_box->is_visible() == show_processor_box) {
+               return;
+       }
+
+       if (show_processor_box) {
+               if (master_packer.get_parent()) {
+                       master_packer.get_parent()->remove (master_packer);
+               }
+               insert_box->show();
+               vpacker.pack_start (master_packer,        false, false, PX_SCALE(10));
+       } else {
+               if (master_packer.get_parent()) {
+                       master_packer.get_parent()->remove (master_packer);
+               }
+               insert_box->hide();
+               vpacker.pack_start (master_packer,        true,  false, PX_SCALE(10));
+       }
 }
 
 void
 MonitorSection::set_session (Session* s)
 {
-       AxisView::set_session (s);
+       RouteUI::set_session (s);
        _plugin_selector->set_session (_session);
 
        if (_session) {
 
+               /* These are not actually dependent on the Session, but they
+                * need to be set after construction, not during, and
+                * this is as good a place as any.
+                */
+
+               ActionManager::get_toggle_action (X_("Solo"), X_("toggle-exclusive-solo"))->set_active (Config->get_exclusive_solo());
+               ActionManager::get_toggle_action (X_("Solo"), X_("toggle-mute-overrides-solo"))->set_active (Config->get_solo_mute_override());
+
                _route = _session->monitor_out ();
 
                if (_route) {
                        /* session with monitor section */
                        _monitor = _route->monitor_control ();
                        assign_controllables ();
-                       _route->output()->changed.connect (_output_changed_connection, invalidator (*this),
+                       _route->output()->changed.connect (output_changed_connections, invalidator (*this),
                                                                                        boost::bind (&MonitorSection::update_output_display, this),
                                                                                        gui_context());
                        insert_box->set_route (_route);
+                       _route->processors_changed.connect (*this, invalidator (*this), boost::bind (&MonitorSection::processors_changed, this, _1), gui_context());
+                       _route->output()->PortCountChanged.connect (output_changed_connections, invalidator (*this), boost::bind (&MonitorSection::populate_buttons, this), gui_context());
+                       _route->DropReferences.connect (*this, invalidator (*this), boost::bind (&MonitorSection::drop_route, this), gui_context());
+
+                       if (_ui_initialized) {
+                               update_processor_box ();
+                       }
+
+                       ActionManager::set_sensitive (monitor_actions, true);
+                       ActionManager::set_sensitive (solo_actions, true);
+
                } else {
                        /* session with no monitor section */
-                       _output_changed_connection.disconnect();
+                       output_changed_connections.drop_connections();
                        _monitor.reset ();
                        _route.reset ();
                        delete _output_selector;
                        _output_selector = 0;
-               }
 
-               if (channel_table_scroller.get_parent()) {
-                       /* scroller is packed, so remove it */
-                       channel_table_packer.remove (channel_table_scroller);
+                       ActionManager::set_sensitive (monitor_actions, false);
+                       /* this action needs to always be true in this * scenaro, so that we can turn it back on*/
+                       ActionManager::get_toggle_action (X_("Monitor"), X_("UseMonitorSection"))->set_sensitive (true);
+                       ActionManager::set_sensitive (solo_actions, true);
                }
 
-               if (table_hpacker.get_parent () == &channel_table_packer) {
-                       /* this occurs when the table hpacker is directly
-                                packed, so remove it.
-                                */
-                       channel_table_packer.remove (table_hpacker);
-               } else if (table_hpacker.get_parent()) {
-                       channel_table_viewport.remove ();
-               }
+               /* make sure the state of this action reflects reality */
+               ActionManager::get_toggle_action (X_("Monitor"), X_("UseMonitorSection"))->set_active (_route != 0);
 
-               if (_monitor->output_streams().n_audio() > 7) {
-                       /* put the table into a scrolled window, and then put
-                        * that into the channel vpacker, after the table header
-                        */
-                       channel_table_viewport.add (table_hpacker);
-                       channel_table_packer.pack_start (channel_table_scroller, true, true);
-                       channel_table_viewport.show ();
-                       channel_table_scroller.show ();
+               populate_buttons ();
 
-               } else {
-                       /* just put the channel table itself into the channel
-                        * vpacker, after the table header
-                        */
-
-                       channel_table_packer.pack_start (table_hpacker, true, true);
-                       channel_table_scroller.hide ();
-               }
-
-               table_hpacker.show ();
-               channel_table.show ();
 
        } else {
-               /* no session */
 
-               _output_changed_connection.disconnect();
-               _monitor.reset ();
-               _route.reset ();
-               control_connections.drop_connections ();
-               rude_iso_button.unset_active_state ();
-               rude_solo_button.unset_active_state ();
-               delete _output_selector;
-               _output_selector = 0;
+               /* no session */
 
+               drop_route ();
                assign_controllables ();
+
+               ActionManager::set_sensitive (monitor_actions, false);
+               ActionManager::set_sensitive (solo_actions, false);
        }
 }
 
+void
+MonitorSection::drop_route ()
+{
+       output_changed_connections.drop_connections();
+       _monitor.reset ();
+       _route.reset ();
+       control_connections.drop_connections ();
+       rude_iso_button.unset_active_state ();
+       rude_solo_button.unset_active_state ();
+       delete _output_selector;
+       _output_selector = 0;
+}
+
 MonitorSection::ChannelButtonSet::ChannelButtonSet ()
 {
-       cut.set_name (X_("monitor section cut"));
+       cut.set_name (X_("mute button"));
        dim.set_name (X_("monitor section dim"));
-       solo.set_name (X_("monitor section solo"));
-       invert.set_name (X_("monitor section invert"));
+       solo.set_name (X_("solo button"));
+       invert.set_name (X_("invert button"));
 
        cut.unset_flags (Gtk::CAN_FOCUS);
        dim.unset_flags (Gtk::CAN_FOCUS);
@@ -588,20 +673,37 @@ MonitorSection::ChannelButtonSet::ChannelButtonSet ()
        invert.unset_flags (Gtk::CAN_FOCUS);
 }
 
-       void
+void
 MonitorSection::populate_buttons ()
 {
        if (!_monitor) {
                return;
        }
 
+       if (channel_table) {
+               channel_size_group->remove_widget (*channel_table);
+               delete channel_table;
+       }
+
+       channel_table = new Gtk::Table();
+
+       channel_table->set_col_spacings (6);
+       channel_table->set_row_spacings (6);
+       channel_table->set_homogeneous (true);
+
+       channel_size_group->add_widget (*channel_table);
+       channel_table->show ();
+       table_hpacker.pack_start (*channel_table, true, true);
+
+       for (ChannelButtons::iterator i = _channel_buttons.begin(); i != _channel_buttons.end(); ++i) {
+               delete *i;
+       }
+       _channel_buttons.clear ();
+
        Glib::RefPtr<Action> act;
        uint32_t nchans = _monitor->output_streams().n_audio();
 
-       channel_table.resize (nchans, 5);
-       channel_table.set_col_spacings (6);
-       channel_table.set_row_spacings (6);
-       channel_table.set_homogeneous (true);
+       channel_table->resize (nchans, 5);
 
        const uint32_t row_offset = 0;
 
@@ -623,43 +725,76 @@ MonitorSection::populate_buttons ()
                }
 
                Label* label = manage (new Label (l));
-               channel_table.attach (*label, 0, 1, i+row_offset, i+row_offset+1, EXPAND|FILL);
+               channel_table->attach (*label, 0, 1, i+row_offset, i+row_offset+1, EXPAND|FILL);
 
                ChannelButtonSet* cbs = new ChannelButtonSet;
 
                _channel_buttons.push_back (cbs);
 
-               channel_table.attach (cbs->cut, 1, 2, i+row_offset, i+row_offset+1, EXPAND|FILL);
-               channel_table.attach (cbs->dim, 2, 3, i+row_offset, i+row_offset+1, EXPAND|FILL);
-               channel_table.attach (cbs->solo, 3, 4, i+row_offset, i+row_offset+1, EXPAND|FILL);
-               channel_table.attach (cbs->invert, 4, 5, i+row_offset, i+row_offset+1, EXPAND|FILL);
+               channel_table->attach (cbs->cut, 1, 2, i+row_offset, i+row_offset+1, EXPAND|FILL);
+               channel_table->attach (cbs->dim, 2, 3, i+row_offset, i+row_offset+1, EXPAND|FILL);
+               channel_table->attach (cbs->solo, 3, 4, i+row_offset, i+row_offset+1, EXPAND|FILL);
+               channel_table->attach (cbs->invert, 4, 5, i+row_offset, i+row_offset+1, EXPAND|FILL);
 
-               snprintf (buf, sizeof (buf), "monitor-cut-%u", i+1);
+               snprintf (buf, sizeof (buf), "monitor-cut-%u", i);
                act = ActionManager::get_action (X_("Monitor"), buf);
                if (act) {
                        cbs->cut.set_related_action (act);
                }
 
-               snprintf (buf, sizeof (buf), "monitor-dim-%u", i+1);
+               snprintf (buf, sizeof (buf), "monitor-dim-%u", i);
                act = ActionManager::get_action (X_("Monitor"), buf);
                if (act) {
                        cbs->dim.set_related_action (act);
                }
 
-               snprintf (buf, sizeof (buf), "monitor-solo-%u", i+1);
+               snprintf (buf, sizeof (buf), "monitor-solo-%u", i);
                act = ActionManager::get_action (X_("Monitor"), buf);
                if (act) {
                        cbs->solo.set_related_action (act);
                }
 
-               snprintf (buf, sizeof (buf), "monitor-invert-%u", i+1);
+               snprintf (buf, sizeof (buf), "monitor-invert-%u", i);
                act = ActionManager::get_action (X_("Monitor"), buf);
                if (act) {
                        cbs->invert.set_related_action (act);
                }
        }
 
-       channel_table.show_all ();
+       channel_table->show_all ();
+
+       if (channel_table_scroller.get_parent()) {
+               /* scroller is packed, so remove it */
+               channel_table_packer.remove (channel_table_scroller);
+       }
+
+       if (table_hpacker.get_parent () == &channel_table_packer) {
+               /* this occurs when the table hpacker is directly
+                        packed, so remove it.
+                        */
+               channel_table_packer.remove (table_hpacker);
+       } else if (table_hpacker.get_parent()) {
+               channel_table_viewport.remove ();
+       }
+
+       if (nchans > 7) {
+               /* put the table into a scrolled window, and then put
+                * that into the channel vpacker, after the table header
+                */
+               channel_table_viewport.add (table_hpacker);
+               channel_table_packer.pack_start (channel_table_scroller, true, true);
+               channel_table_viewport.show ();
+               channel_table_scroller.show ();
+
+       } else {
+               /* just put the channel table itself into the channel
+                * vpacker, after the table header
+                */
+               channel_table_packer.pack_start (table_hpacker, true, true);
+               channel_table_scroller.hide ();
+       }
+       table_hpacker.show ();
+       channel_table->show ();
 }
 
 void
@@ -669,12 +804,7 @@ MonitorSection::toggle_exclusive_solo ()
                return;
        }
 
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Monitor"), "toggle-exclusive-solo");
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               Config->set_exclusive_solo (tact->get_active());
-       }
-
+       Config->set_exclusive_solo (ActionManager::get_toggle_action (X_("Solo"), "toggle-exclusive-solo")->get_active());
 }
 
 void
@@ -684,11 +814,8 @@ MonitorSection::toggle_mute_overrides_solo ()
                return;
        }
 
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Monitor"), "toggle-mute-overrides-solo");
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               Config->set_solo_mute_override (tact->get_active());
-       }
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Solo"), "toggle-mute-overrides-solo");
+       Config->set_solo_mute_override (tact->get_active());
 }
 
 void
@@ -698,12 +825,8 @@ MonitorSection::dim_all ()
                return;
        }
 
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Monitor"), "monitor-dim-all");
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               _monitor->set_dim_all (tact->get_active());
-       }
-
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), "monitor-dim-all");
+       _monitor->set_dim_all (tact->get_active());
 }
 
 void
@@ -713,11 +836,8 @@ MonitorSection::cut_all ()
                return;
        }
 
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Monitor"), "monitor-cut-all");
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               _monitor->set_cut_all (tact->get_active());
-       }
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), "monitor-cut-all");
+       _monitor->set_cut_all (tact->get_active());
 }
 
 void
@@ -727,11 +847,8 @@ MonitorSection::mono ()
                return;
        }
 
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Monitor"), "monitor-mono");
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               _monitor->set_mono (tact->get_active());
-       }
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), "monitor-mono");
+       _monitor->set_mono (tact->get_active());
 }
 
 void
@@ -744,13 +861,8 @@ MonitorSection::cut_channel (uint32_t chn)
        char buf[64];
        snprintf (buf, sizeof (buf), "monitor-cut-%u", chn);
 
-       --chn; // 0-based in backend
-
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Monitor"), buf);
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               _monitor->set_cut (chn, tact->get_active());
-       }
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), buf);
+       _monitor->set_cut (chn, tact->get_active());
 }
 
 void
@@ -763,14 +875,8 @@ MonitorSection::dim_channel (uint32_t chn)
        char buf[64];
        snprintf (buf, sizeof (buf), "monitor-dim-%u", chn);
 
-       --chn; // 0-based in backend
-
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Monitor"), buf);
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               _monitor->set_dim (chn, tact->get_active());
-       }
-
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), buf);
+       _monitor->set_dim (chn, tact->get_active());
 }
 
 void
@@ -783,13 +889,8 @@ MonitorSection::solo_channel (uint32_t chn)
        char buf[64];
        snprintf (buf, sizeof (buf), "monitor-solo-%u", chn);
 
-       --chn; // 0-based in backend
-
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Monitor"), buf);
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               _monitor->set_solo (chn, tact->get_active());
-       }
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), buf);
+       _monitor->set_solo (chn, tact->get_active());
 
 }
 
@@ -803,13 +904,8 @@ MonitorSection::invert_channel (uint32_t chn)
        char buf[64];
        snprintf (buf, sizeof (buf), "monitor-invert-%u", chn);
 
-       --chn; // 0-based in backend
-
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Monitor"), buf);
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-               _monitor->set_polarity (chn, tact->get_active());
-       }
+       Glib::RefPtr<ToggleAction> tact = ActionManager::get_toggle_action (X_("Monitor"), buf);
+       _monitor->set_polarity (chn, tact->get_active());
 }
 
 void
@@ -819,69 +915,58 @@ MonitorSection::register_actions ()
        string action_descr;
        Glib::RefPtr<Action> act;
 
-       monitor_actions = ActionGroup::create (X_("Monitor"));
-       ActionManager::add_action_group (monitor_actions);
+       /* ...will get sensitized if a mon-session is added */
 
-       ActionManager::register_toggle_action (monitor_actions, "monitor-mono", "", _("Switch monitor to mono"),
-                       sigc::mem_fun (*this, &MonitorSection::mono));
+       monitor_actions = ActionManager::create_action_group (bindings, X_("Monitor"));
+       solo_actions = ActionManager::create_action_group (bindings, X_("Monitor"));
 
-       ActionManager::register_toggle_action (monitor_actions, "monitor-cut-all", "", _("Cut monitor"),
-                       sigc::mem_fun (*this, &MonitorSection::cut_all));
+       ActionManager::register_toggle_action (monitor_actions, X_("UseMonitorSection"), _("Use Monitor Section"), sigc::mem_fun(*this, &MonitorSection::toggle_use_monitor_section));
+       ActionManager::register_toggle_action (monitor_actions, "monitor-mono", _("Monitor Section: Mono"), sigc::mem_fun (*this, &MonitorSection::mono));
+       ActionManager::register_toggle_action (monitor_actions, "monitor-cut-all", _("Monitor Section: Mute"), sigc::mem_fun (*this, &MonitorSection::cut_all));
+       ActionManager::register_toggle_action (monitor_actions, "monitor-dim-all", _("Monitor Section: Dim"), sigc::mem_fun (*this, &MonitorSection::dim_all));
 
-       ActionManager::register_toggle_action (monitor_actions, "monitor-dim-all", "", _("Dim monitor"),
-                       sigc::mem_fun (*this, &MonitorSection::dim_all));
+       ActionManager::register_toggle_action (monitor_actions, "toggle-monitor-processor-box", _("Toggle Monitor Section Processor Box"),
+                                              sigc::mem_fun (*this, &MonitorSection::update_processor_box));
 
-       act = ActionManager::register_toggle_action (monitor_actions, "toggle-exclusive-solo", "", _("Toggle exclusive solo mode"),
-                       sigc::mem_fun (*this, &MonitorSection::toggle_exclusive_solo));
 
-       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-       tact->set_active (Config->get_exclusive_solo());
-
-       act = ActionManager::register_toggle_action (monitor_actions, "toggle-mute-overrides-solo", "", _("Toggle mute overrides solo mode"),
-                       sigc::mem_fun (*this, &MonitorSection::toggle_mute_overrides_solo));
-
-       tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-       tact->set_active (Config->get_solo_mute_override());
-
-
-       /* note the 1-based counting (for naming - backend uses 0-based) */
-
-       for (uint32_t chn = 1; chn <= 16; ++chn) {
+       for (uint32_t chn = 0; chn < 16; ++chn) {
 
                action_name = string_compose (X_("monitor-cut-%1"), chn);
                action_descr = string_compose (_("Cut monitor channel %1"), chn);
-               ActionManager::register_toggle_action (monitor_actions, action_name.c_str(), "", action_descr.c_str(),
-                               sigc::bind (sigc::mem_fun (*this, &MonitorSection::cut_channel), chn));
+               ActionManager::register_toggle_action (monitor_actions, action_name.c_str(), action_descr.c_str(),
+                                                      sigc::bind (sigc::mem_fun (*this, &MonitorSection::cut_channel), chn));
 
                action_name = string_compose (X_("monitor-dim-%1"), chn);
                action_descr = string_compose (_("Dim monitor channel %1"), chn);
-               ActionManager::register_toggle_action (monitor_actions, action_name.c_str(), "", action_descr.c_str(),
-                               sigc::bind (sigc::mem_fun (*this, &MonitorSection::dim_channel), chn));
+               ActionManager::register_toggle_action (monitor_actions, action_name.c_str(), action_descr.c_str(),
+                                                      sigc::bind (sigc::mem_fun (*this, &MonitorSection::dim_channel), chn));
 
                action_name = string_compose (X_("monitor-solo-%1"), chn);
                action_descr = string_compose (_("Solo monitor channel %1"), chn);
-               ActionManager::register_toggle_action (monitor_actions, action_name.c_str(), "", action_descr.c_str(),
-                               sigc::bind (sigc::mem_fun (*this, &MonitorSection::solo_channel), chn));
+               ActionManager::register_toggle_action (monitor_actions, action_name.c_str(), action_descr.c_str(),
+                                                      sigc::bind (sigc::mem_fun (*this, &MonitorSection::solo_channel), chn));
 
                action_name = string_compose (X_("monitor-invert-%1"), chn);
                action_descr = string_compose (_("Invert monitor channel %1"), chn);
-               ActionManager::register_toggle_action (monitor_actions, action_name.c_str(), "", action_descr.c_str(),
-                               sigc::bind (sigc::mem_fun (*this, &MonitorSection::invert_channel), chn));
+               ActionManager::register_toggle_action (monitor_actions, action_name.c_str(), action_descr.c_str(),
+                                                      sigc::bind (sigc::mem_fun (*this, &MonitorSection::invert_channel), chn));
 
        }
 
-
-       Glib::RefPtr<ActionGroup> solo_actions = ActionGroup::create (X_("Solo"));
+       solo_actions = ActionManager::create_action_group (bindings, X_("Solo"));
        RadioAction::Group solo_group;
 
-       ActionManager::register_radio_action (solo_actions, solo_group, "solo-use-in-place", "", _("In-place solo"),
-                       sigc::mem_fun (*this, &MonitorSection::solo_use_in_place));
-       ActionManager::register_radio_action (solo_actions, solo_group, "solo-use-afl", "", _("After Fade Listen (AFL) solo"),
-                       sigc::mem_fun (*this, &MonitorSection::solo_use_afl));
-       ActionManager::register_radio_action (solo_actions, solo_group, "solo-use-pfl", "", _("Pre Fade Listen (PFL) solo"),
-                       sigc::mem_fun (*this, &MonitorSection::solo_use_pfl));
-
-       ActionManager::add_action_group (solo_actions);
+       ActionManager::register_radio_action (solo_actions, solo_group, "solo-use-in-place", _("In-place solo"),
+                                             sigc::mem_fun (*this, &MonitorSection::solo_use_in_place));
+       ActionManager::register_radio_action (solo_actions, solo_group, "solo-use-afl", _("After Fade Listen (AFL) solo"),
+                                             sigc::mem_fun (*this, &MonitorSection::solo_use_afl));
+       ActionManager::register_radio_action (solo_actions, solo_group, "solo-use-pfl", _("Pre Fade Listen (PFL) solo"),
+                                             sigc::mem_fun (*this, &MonitorSection::solo_use_pfl));
+
+       ActionManager::register_toggle_action (solo_actions, "toggle-exclusive-solo", _("Toggle exclusive solo mode"),
+                                              sigc::mem_fun (*this, &MonitorSection::toggle_exclusive_solo));
+       ActionManager::register_toggle_action (solo_actions, "toggle-mute-overrides-solo", _("Toggle mute overrides solo mode"),
+                                              sigc::mem_fun (*this, &MonitorSection::toggle_mute_overrides_solo));
 }
 
 void
@@ -892,23 +977,17 @@ MonitorSection::solo_use_in_place ()
                 active.
                 */
 
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Solo"), X_("solo-use-in-place"));
-
-       if (act) {
-               Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic (act);
-               if (ract) {
-                       if (!ract->get_active ()) {
-                               /* We are turning SiP off, which means that AFL or PFL will be turned on
-                                        shortly; don't update the solo model in the mean time, as if the currently
-                                        configured listen position is not the one that is about to be turned on,
-                                        things will go wrong.
-                                        */
-                               _inhibit_solo_model_update = true;
-                       }
-                       Config->set_solo_control_is_listen_control (!ract->get_active());
-                       _inhibit_solo_model_update = false;
-               }
-       }
+       Glib::RefPtr<RadioAction> ract = ActionManager::get_radio_action (X_("Solo"), X_("solo-use-in-place"));
+       if (!ract->get_active ()) {
+               /* We are turning SiP off, which means that AFL or PFL will be turned on
+                  shortly; don't update the solo model in the mean time, as if the currently
+                  configured listen position is not the one that is about to be turned on,
+                  things will go wrong.
+               */
+               _inhibit_solo_model_update = true;
+       }
+       Config->set_solo_control_is_listen_control (!ract->get_active());
+       _inhibit_solo_model_update = false;
 }
 
 void
@@ -919,15 +998,10 @@ MonitorSection::solo_use_afl ()
                 active.
                 */
 
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Solo"), X_("solo-use-afl"));
-       if (act) {
-               Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic (act);
-               if (ract) {
-                       if (ract->get_active()) {
-                               Config->set_solo_control_is_listen_control (true);
-                               Config->set_listen_position (AfterFaderListen);
-                       }
-               }
+       Glib::RefPtr<RadioAction> ract = ActionManager::get_radio_action (X_("Solo"), X_("solo-use-afl"));
+       if (ract->get_active()) {
+               Config->set_solo_control_is_listen_control (true);
+               Config->set_listen_position (AfterFaderListen);
        }
 }
 
@@ -939,15 +1013,10 @@ MonitorSection::solo_use_pfl ()
           active.
        */
 
-       Glib::RefPtr<Action> act = ActionManager::get_action (X_("Solo"), X_("solo-use-pfl"));
-       if (act) {
-               Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic (act);
-               if (ract) {
-                       if (ract->get_active()) {
-                               Config->set_solo_control_is_listen_control (true);
-                               Config->set_listen_position (PreFaderListen);
-                       }
-               }
+       Glib::RefPtr<RadioAction> ract = ActionManager::get_radio_action (X_("Solo"), X_("solo-use-pfl"));
+       if (ract->get_active()) {
+               Config->set_solo_control_is_listen_control (true);
+               Config->set_listen_position (PreFaderListen);
        }
 }
 
@@ -959,7 +1028,7 @@ MonitorSection::update_solo_model ()
        }
 
        const char* action_name = 0;
-       Glib::RefPtr<Action> act;
+       Glib::RefPtr<RadioAction> ract;
 
        if (Config->get_solo_control_is_listen_control()) {
                switch (Config->get_listen_position()) {
@@ -974,22 +1043,18 @@ MonitorSection::update_solo_model ()
                action_name = X_("solo-use-in-place");
        }
 
-       act = ActionManager::get_action (X_("Solo"), action_name);
-       if (act) {
+       ract = ActionManager::get_radio_action (X_("Solo"), action_name);
 
-               Glib::RefPtr<RadioAction> ract = Glib::RefPtr<RadioAction>::cast_dynamic (act);
-               if (ract) {
-                       /* because these are radio buttons, one of them will be
-                                active no matter what. to trigger a change in the
-                                action so that the view picks it up, toggle it.
-                                */
-                       if (ract->get_active()) {
-                               ract->set_active (false);
-                       }
-                       ract->set_active (true);
-               }
+       /* because these are radio buttons, one of them will be
+          active no matter what. to trigger a change in the
+          action so that the view picks it up, toggle it.
+       */
 
+       if (ract->get_active()) {
+               ract->set_active (false);
        }
+
+       ract->set_active (true);
 }
 
 void
@@ -999,33 +1064,19 @@ MonitorSection::map_state ()
                return;
        }
 
-       Glib::RefPtr<Action> act;
-
        update_solo_model ();
 
-       act = ActionManager::get_action (X_("Monitor"), "monitor-cut-all");
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-               if (tact) {
-                       tact->set_active (_monitor->cut_all());
-               }
-       }
+       Glib::RefPtr<Action> act;
+       Glib::RefPtr<ToggleAction> tact;
 
-       act = ActionManager::get_action (X_("Monitor"), "monitor-dim-all");
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-               if (tact) {
-                       tact->set_active (_monitor->dim_all());
-               }
-       }
+       tact = ActionManager::get_toggle_action (X_("Monitor"), "monitor-cut-all");
+       tact->set_active (_monitor->cut_all());
 
-       act = ActionManager::get_action (X_("Monitor"), "monitor-mono");
-       if (act) {
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-               if (tact) {
-                       tact->set_active (_monitor->mono());
-               }
-       }
+       tact = ActionManager::get_toggle_action (X_("Monitor"), "monitor-dim-all");
+       tact->set_active (_monitor->dim_all());
+
+       tact = ActionManager::get_toggle_action (X_("Monitor"), "monitor-mono");
+       tact->set_active (_monitor->mono());
 
        uint32_t nchans = _monitor->output_streams().n_audio();
 
@@ -1036,46 +1087,30 @@ MonitorSection::map_state ()
                char action_name[32];
 
                snprintf (action_name, sizeof (action_name), "monitor-cut-%u", n);
-               act = ActionManager::get_action (X_("Monitor"), action_name);
-               if (act) {
-                       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-                       if (tact) {
-                               tact->set_active (_monitor->cut (n));
-                       }
-               }
+               tact = ActionManager::get_toggle_action (X_("Monitor"), action_name);
+               tact->set_active (_monitor->cut (n));
 
                snprintf (action_name, sizeof (action_name), "monitor-dim-%u", n);
-               act = ActionManager::get_action (X_("Monitor"), action_name);
-               if (act) {
-                       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-                       if (tact) {
-                               tact->set_active (_monitor->dimmed (n));
-                       }
-               }
+               tact = ActionManager::get_toggle_action (X_("Monitor"), action_name);
+               tact->set_active (_monitor->dimmed (n));
 
                snprintf (action_name, sizeof (action_name), "monitor-solo-%u", n);
-               act = ActionManager::get_action (X_("Monitor"), action_name);
-               if (act) {
-                       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-                       if (tact) {
-                               tact->set_active (_monitor->soloed (n));
-                       }
-               }
+               tact = ActionManager::get_toggle_action (X_("Monitor"), action_name);
+               tact->set_active (_monitor->soloed (n));
 
                snprintf (action_name, sizeof (action_name), "monitor-invert-%u", n);
-               act = ActionManager::get_action (X_("Monitor"), action_name);
-               if (act) {
-                       Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-                       if (tact) {
-                               tact->set_active (_monitor->inverted (n));
-                       }
-               }
+               tact = ActionManager::get_toggle_action (X_("Monitor"), action_name);
+               tact->set_active (_monitor->inverted (n));
        }
 }
 
 void
 MonitorSection::do_blink (bool onoff)
 {
+       if (!UIConfiguration::instance().get_blink_alert_indicators ()) {
+               onoff = true;
+       }
+
        solo_blink (onoff);
        audition_blink (onoff);
 }
@@ -1123,7 +1158,7 @@ MonitorSection::cancel_isolate (GdkEventButton*)
 {
        if (_session) {
                boost::shared_ptr<RouteList> rl (_session->get_routes ());
-               _session->set_solo_isolated (rl, false, Session::rt_cleanup, true);
+               _session->set_controls (route_list_to_control_list (rl, &Stripable::solo_isolate_control), 0.0, Controllable::NoGroup);
        }
 
        return true;
@@ -1139,12 +1174,9 @@ MonitorSection::cancel_audition (GdkEventButton*)
 }
 
 #define SYNCHRONIZE_TOGGLE_ACTION(action, value) \
-       if (action) { \
-               Glib::RefPtr<ToggleAction> tact = Glib::RefPtr<ToggleAction>::cast_dynamic(action); \
-               if (tact && tact->get_active() != value) { \
-                       tact->set_active(value); \
-               } \
-       }
+       if (action && action->get_active() != value) { \
+               action->set_active(value); \
+       } \
 
 void
 MonitorSection::parameter_changed (std::string name)
@@ -1154,13 +1186,11 @@ MonitorSection::parameter_changed (std::string name)
        } else if (name == "listen-position") {
                update_solo_model ();
        } else if (name == "solo-mute-override") {
-               SYNCHRONIZE_TOGGLE_ACTION(
-                               ActionManager::get_action (X_("Monitor"), "toggle-mute-overrides-solo"),
-                               Config->get_solo_mute_override ())
+               SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Solo"), "toggle-mute-overrides-solo"), Config->get_solo_mute_override ());
        } else if (name == "exclusive-solo") {
-               SYNCHRONIZE_TOGGLE_ACTION(
-                               ActionManager::get_action (X_("Monitor"), "toggle-exclusive-solo"),
-                               Config->get_exclusive_solo ())
+               SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Solo"), "toggle-exclusive-solo"), Config->get_exclusive_solo ());
+       } else if (name == "use-monitor-bus") {
+               SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection"), Config->get_use_monitor_bus ());
        }
 }
 
@@ -1418,7 +1448,7 @@ MonitorSection::update_output_display ()
                                                << Gtkmm2ext::markup_escape_text ( pn.empty() ? connection_name : pn );
                                }
 
-                               if (connection_name.find("ardour:") == 0) {
+                               if (connection_name.find(RouteUI::program_port_prefix) == 0) {
                                        if (ardour_track_name.empty()) {
                                                // "ardour:Master/in 1" -> "ardour:Master/"
                                                string::size_type slash = connection_name.find("/");
@@ -1542,3 +1572,54 @@ MonitorSection::port_connected_or_disconnected (boost::weak_ptr<Port> wa, boost:
                update_output_display ();
        }
 }
+
+void
+MonitorSection::load_bindings ()
+{
+       bindings = Bindings::get_bindings (X_("Monitor Section"));
+}
+
+void
+MonitorSection::help_count_processors (boost::weak_ptr<Processor> p, uint32_t* cnt) const
+{
+       boost::shared_ptr<Processor> processor (p.lock ());
+       if (!processor || !processor->display_to_user()) {
+               return;
+       }
+       if (boost::dynamic_pointer_cast<Amp>(processor)) {
+               return;
+       }
+       ++(*cnt);
+}
+
+uint32_t
+MonitorSection::count_processors ()
+{
+       uint32_t processor_count = 0;
+       if (_route) {
+               _route->foreach_processor (sigc::bind (sigc::mem_fun (*this, &MonitorSection::help_count_processors), &processor_count));
+       }
+       return processor_count;
+}
+
+void
+MonitorSection::processors_changed (ARDOUR::RouteProcessorChange)
+{
+       update_processor_box ();
+}
+
+void
+MonitorSection::use_others_actions ()
+{
+       rude_solo_button.set_related_action (ActionManager::get_action (X_("Main"), X_("cancel-solo")));
+}
+
+void
+MonitorSection::toggle_use_monitor_section ()
+{
+       if (!_session) {
+               return;
+       }
+
+       Config->set_use_monitor_bus (ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection")->get_active());
+}