Enable Menu > Quit to work again after startup on macOS
[ardour.git] / gtk2_ardour / monitor_section.cc
index 201bd175e406ae72754f326c8c29e43240b7c0fa..8c24afe56841dc5cf439f0111e49d0251e680ef6 100644 (file)
@@ -1,27 +1,32 @@
 /*
-  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 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.
-
-*/
+ * Copyright (C) 2010-2019 Paul Davis <paul@linuxaudiosystems.com>
+ * Copyright (C) 2011-2012 David Robillard <d@drobilla.net>
+ * Copyright (C) 2011 Carl Hetherington <carl@carlh.net>
+ * Copyright (C) 2014-2015 Tim Mayberry <mojofunk@gmail.com>
+ * Copyright (C) 2014-2018 Ben Loftis <ben@harrisonconsoles.com>
+ * Copyright (C) 2014-2019 Robin Gareus <robin@gareus.org>
+ *
+ * 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.
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
 
 #include <gdkmm/pixbuf.h>
 
 #include "pbd/compose.h"
 #include "pbd/error.h"
 #include "pbd/replace_all.h"
+#include "pbd/stacktrace.h"
 
 #include "gtkmm2ext/actions.h"
 #include "gtkmm2ext/utils.h"
@@ -62,9 +67,13 @@ using namespace std;
 
 #define PX_SCALE(px) std::max((float)px, rintf((float)px * UIConfiguration::instance().get_ui_scale()))
 
-MonitorSection::MonitorSection (Session* s)
-       : SessionHandlePtr (s)
-       , RouteUI (s)
+#define SYNCHRONIZE_TOGGLE_ACTION(action, value) \
+       if (action && action->get_active() != value) { \
+               action->set_active(value); \
+       }
+
+MonitorSection::MonitorSection ()
+       : RouteUI ((Session*) 0)
        , _tearoff (0)
        , channel_table (0)
        , channel_table_viewport (*channel_table_scroller.get_hadjustment()
@@ -88,6 +97,10 @@ MonitorSection::MonitorSection (Session* s)
        , _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;
 
@@ -96,18 +109,14 @@ MonitorSection::MonitorSection (Session* s)
        load_bindings ();
        register_actions ();
        set_data ("ardour-bindings", bindings);
-       bindings->associate ();
 
        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);
+       insert_box = new ProcessorBox (0, boost::bind (&MonitorSection::plugin_selector, this), _rr_selection, 0);
        insert_box->set_no_show_all ();
        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");
@@ -123,8 +132,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);
@@ -170,7 +177,7 @@ MonitorSection::MonitorSection (Session* s)
        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);
        }
@@ -179,17 +186,14 @@ MonitorSection::MonitorSection (Session* s)
        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_action (X_("Monitor"), X_("toggle-monitor-processor-box"));
+       proctoggle = ActionManager::get_toggle_action (X_("Monitor"), X_("toggle-monitor-processor-box"));
        toggle_processorbox_button.set_related_action (proctoggle);
 
        /* Knobs */
@@ -254,7 +258,7 @@ MonitorSection::MonitorSection (Session* s)
        cut_all_button.set_size_request (-1, PX_SCALE(30));
        cut_all_button.show ();
 
-       act = ActionManager::get_action (X_("Monitor"), X_("monitor-cut-all"));
+       act = ActionManager::get_action (X_("Monitor Section"), X_("monitor-cut-all"));
        if (act) {
                cut_all_button.set_related_action (act);
        }
@@ -263,7 +267,7 @@ MonitorSection::MonitorSection (Session* s)
        dim_all_button.set_text (_("Dim"));
        dim_all_button.set_name ("monitor section dim");
        dim_all_button.set_size_request (-1, PX_SCALE(25));
-       act = ActionManager::get_action (X_("Monitor"), X_("monitor-dim-all"));
+       act = ActionManager::get_action (X_("Monitor Section"), X_("monitor-dim-all"));
        if (act) {
                dim_all_button.set_related_action (act);
        }
@@ -272,7 +276,7 @@ MonitorSection::MonitorSection (Session* s)
        mono_button.set_text (_("Mono"));
        mono_button.set_name ("monitor section mono");
        mono_button.set_size_request (-1, PX_SCALE(25));
-       act = ActionManager::get_action (X_("Monitor"), X_("monitor-mono"));
+       act = ActionManager::get_action (X_("Monitor Section"), X_("monitor-mono"));
        if (act) {
                mono_button.set_related_action (act);
        }
@@ -337,6 +341,8 @@ MonitorSection::MonitorSection (Session* s)
         * LAYOUT  top to bottom
         */
 
+       Gtk::Label *top_spacer = manage (new Gtk::Label);
+
        // solo, iso information
        HBox* rude_box = manage (new HBox);
        rude_box->set_spacing (PX_SCALE(4));
@@ -426,6 +432,7 @@ MonitorSection::MonitorSection (Session* s)
         * TOP LEVEL LAYOUT
         */
        vpacker.set_border_width (PX_SCALE(3));
+       vpacker.pack_start (*top_spacer,          false, false, 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));
@@ -435,9 +442,9 @@ MonitorSection::MonitorSection (Session* s)
        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 */
+                       scrollbar_height /* no outer frame */
 #else
-                       scrollbar_height + 2 /* sample borders */
+                       scrollbar_height + 2 /* frame borders */
 #endif
                        );
 
@@ -467,7 +474,6 @@ MonitorSection::MonitorSection (Session* s)
        hpacker.show ();
 
        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);
@@ -505,7 +511,7 @@ MonitorSection::~MonitorSection ()
        }
 
        _channel_buttons.clear ();
-       output_changed_connections.drop_connections ();
+       route_connections.drop_connections ();
 
        delete insert_box; insert_box = 0;
        delete output_button; output_button = 0;
@@ -556,7 +562,7 @@ MonitorSection::leave_handler (GdkEventCrossing* ev)
 void
 MonitorSection::update_processor_box ()
 {
-       bool show_processor_box = Glib::RefPtr<ToggleAction>::cast_dynamic (proctoggle)->get_active ();
+       bool show_processor_box = proctoggle->get_active ();
 
        if (count_processors () > 0 && !show_processor_box) {
                toggle_processorbox_button.set_name (X_("monitor section processors present"));
@@ -587,58 +593,90 @@ void
 MonitorSection::set_session (Session* s)
 {
        RouteUI::set_session (s);
-       _plugin_selector->set_session (_session);
+       insert_box->set_session (_session);
+
+       Glib::RefPtr<ActionGroup> global_monitor_actions = ActionManager::get_action_group (X_("Monitor Section"));
 
        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_connections, invalidator (*this),
-                                                                                       boost::bind (&MonitorSection::update_output_display, this),
-                                                                                       gui_context());
+                       _route->output()->changed.connect (route_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->processors_changed.connect (route_connections, invalidator (*this), boost::bind (&MonitorSection::processors_changed, this, _1), gui_context());
+                       _route->output()->PortCountChanged.connect (route_connections, invalidator (*this), boost::bind (&MonitorSection::populate_buttons, this), gui_context());
+                       _route->DropReferences.connect (route_connections, invalidator (*this), boost::bind (&MonitorSection::drop_route, this), gui_context());
+
                        if (_ui_initialized) {
                                update_processor_box ();
                        }
+
+                       SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection"), true);
+                       ActionManager::set_sensitive (global_monitor_actions, true);
+                       ActionManager::set_sensitive (monitor_actions, true);
+                       ActionManager::set_sensitive (solo_actions, true);
+
                } else {
                        /* session with no monitor section */
-                       output_changed_connections.drop_connections();
+                       route_connections.drop_connections();
                        _monitor.reset ();
                        _route.reset ();
                        delete _output_selector;
                        _output_selector = 0;
+
+                       SYNCHRONIZE_TOGGLE_ACTION (ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection"), false);
+                       ActionManager::set_sensitive (global_monitor_actions, false);
+                       ActionManager::set_sensitive (monitor_actions, false);
+                       ActionManager::set_sensitive (solo_actions, true);
+                       /* this action needs to always be true in this, so that we can turn it back on */
+                       ActionManager::get_toggle_action (X_("Monitor"), X_("UseMonitorSection"))->set_sensitive (true);
                }
 
                populate_buttons ();
-
-               /* some actions may have been left in the wrong state from a
-                * previous monitor route that was then deleted
-                */
-               ActionManager::set_sensitive (monitor_actions, true);
-               ActionManager::set_sensitive (solo_actions, true);
+               map_state ();
 
        } else {
+
                /* no session */
 
-               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;
+               if (_route) {
+                       drop_route ();
+                       unassign_controllables ();
+               }
 
-               assign_controllables ();
+               ActionManager::set_sensitive (monitor_actions, false);
+               ActionManager::set_sensitive (solo_actions, false);
+               ActionManager::set_sensitive (global_monitor_actions, false);
        }
 }
 
+void
+MonitorSection::drop_route ()
+{
+       route_connections.drop_connections();
+       _monitor.reset ();
+       _route.reset ();
+       unassign_controllables ();
+       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_("mute button"));
@@ -783,12 +821,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
@@ -798,11 +831,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
@@ -812,12 +842,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 Section"), "monitor-dim-all");
+       _monitor->set_dim_all (tact->get_active());
 }
 
 void
@@ -827,11 +853,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 Section"), "monitor-cut-all");
+       _monitor->set_cut_all (tact->get_active());
 }
 
 void
@@ -841,11 +864,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 Section"), "monitor-mono");
+       _monitor->set_mono (tact->get_active());
 }
 
 void
@@ -858,11 +878,8 @@ MonitorSection::cut_channel (uint32_t chn)
        char buf[64];
        snprintf (buf, sizeof (buf), "monitor-cut-%u", chn);
 
-       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
@@ -875,12 +892,8 @@ MonitorSection::dim_channel (uint32_t chn)
        char buf[64];
        snprintf (buf, sizeof (buf), "monitor-dim-%u", chn);
 
-       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
@@ -893,11 +906,8 @@ MonitorSection::solo_channel (uint32_t chn)
        char buf[64];
        snprintf (buf, sizeof (buf), "monitor-solo-%u", chn);
 
-       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());
 
 }
 
@@ -911,11 +921,8 @@ MonitorSection::invert_channel (uint32_t chn)
        char buf[64];
        snprintf (buf, sizeof (buf), "monitor-invert-%u", chn);
 
-       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
@@ -925,58 +932,68 @@ MonitorSection::register_actions ()
        string action_descr;
        Glib::RefPtr<Action> act;
 
-       monitor_actions = ActionManager::create_action_group (X_("Monitor"));
+       /* ...will get sensitized if a mon-session is added */
 
-       act = ActionManager::register_toggle_action (monitor_actions, "toggle-exclusive-solo", _("Toggle exclusive solo mode"),
-                       sigc::bind (sigc::ptr_fun (MonitorSection::action_proxy0), ToggleExclusiveSolo));
+       monitor_actions = ActionManager::create_action_group (bindings, X_("Monitor"));
+       solo_actions = ActionManager::create_action_group (bindings, X_("Monitor"));
 
-       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::bind (sigc::ptr_fun (MonitorSection::action_proxy0), ToggleMuteOverridesSolo));
+       ActionManager::register_toggle_action (monitor_actions, X_("UseMonitorSection"), _("Use Monitor Section"), sigc::mem_fun(*this, &MonitorSection::toggle_use_monitor_section));
+
+       /* these are global monitor actions that invoke MonitorSectioncode. Do
+        * not create local versions (i.e. as part of "monitor_actions")
+        * because then we can end up with two different bindings (one global,
+        * one local to the monitor section) for the same action.
+        */
+
+       Glib::RefPtr<ActionGroup> global_monitor_actions = ActionManager::get_action_group (X_("Monitor Section"));
+
+       ActionManager::register_toggle_action (global_monitor_actions, "monitor-mono", _("Mono"), sigc::mem_fun (*this, &MonitorSection::mono));
+       ActionManager::register_toggle_action (global_monitor_actions, "monitor-cut-all", _("Mute"), sigc::mem_fun (*this, &MonitorSection::cut_all));
+       ActionManager::register_toggle_action (global_monitor_actions, "monitor-dim-all", _("Dim"), 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));
 
-       tact = Glib::RefPtr<ToggleAction>::cast_dynamic(act);
-       tact->set_active (Config->get_solo_mute_override());
 
        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::ptr_fun (action_proxy1), CutChannel, chn));
+                                                      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::ptr_fun (action_proxy1), DimChannel, chn));
+                                                      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::ptr_fun (action_proxy1), SoloChannel, chn));
+                                                      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::ptr_fun (action_proxy1), InvertChannel, chn));
+                                                      sigc::bind (sigc::mem_fun (*this, &MonitorSection::invert_channel), chn));
 
        }
 
-
-       Glib::RefPtr<ActionGroup> solo_actions = ActionManager::create_action_group (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::bind (sigc::ptr_fun (MonitorSection::action_proxy0), SoloUseInPlace));
+                                             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::bind (sigc::ptr_fun (MonitorSection::action_proxy0), SoloUseAFL));
+                                             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::bind (sigc::ptr_fun (MonitorSection::action_proxy0), SoloUsePFL));
-
-       ActionManager::register_toggle_action (monitor_actions, "toggle-monitor-processor-box", _("Toggle Monitor Section Processor Box"),
-                                              sigc::bind (sigc::ptr_fun (MonitorSection::action_proxy0), ToggleMonitorProcessorBox));
+                                             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
@@ -987,23 +1004,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
@@ -1014,15 +1025,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);
        }
 }
 
@@ -1034,15 +1040,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);
        }
 }
 
@@ -1054,7 +1055,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()) {
@@ -1069,22 +1070,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
@@ -1099,29 +1096,14 @@ MonitorSection::map_state ()
        Glib::RefPtr<Action> act;
        Glib::RefPtr<ToggleAction> tact;
 
-       act = ActionManager::get_action (X_("Monitor"), "monitor-cut-all");
-       if (act) {
-               tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-               if (tact) {
-                       tact->set_active (_monitor->cut_all());
-               }
-       }
+       tact = ActionManager::get_toggle_action (X_("Monitor Section"), "monitor-cut-all");
+       tact->set_active (_monitor->cut_all());
 
-       act = ActionManager::get_action (X_("Monitor"), "monitor-dim-all");
-       if (act) {
-               tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-               if (tact) {
-                       tact->set_active (_monitor->dim_all());
-               }
-       }
+       tact = ActionManager::get_toggle_action (X_("Monitor Section"), "monitor-dim-all");
+       tact->set_active (_monitor->dim_all());
 
-       act = ActionManager::get_action (X_("Monitor"), "monitor-mono");
-       if (act) {
-               tact = Glib::RefPtr<ToggleAction>::cast_dynamic (act);
-               if (tact) {
-                       tact->set_active (_monitor->mono());
-               }
-       }
+       tact = ActionManager::get_toggle_action (X_("Monitor Section"), "monitor-mono");
+       tact->set_active (_monitor->mono());
 
        uint32_t nchans = _monitor->output_streams().n_audio();
 
@@ -1132,40 +1114,20 @@ 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));
        }
 }
 
@@ -1238,14 +1200,6 @@ MonitorSection::cancel_audition (GdkEventButton*)
        return true;
 }
 
-#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); \
-               } \
-       }
-
 void
 MonitorSection::parameter_changed (std::string name)
 {
@@ -1254,66 +1208,52 @@ 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 ());
        }
 }
 
 void
-MonitorSection::assign_controllables ()
+MonitorSection::unassign_controllables ()
 {
        boost::shared_ptr<Controllable> none;
 
-       if (!gain_control) {
-               /* too early - GUI controls not set up yet */
-               return;
-       }
-
-       if (_session) {
-               solo_cut_control->set_controllable (_session->solo_cut_control());
-               solo_cut_display->set_controllable (_session->solo_cut_control());
-       } else {
-               solo_cut_control->set_controllable (none);
-               solo_cut_display->set_controllable (none);
-       }
-
-       if (_route) {
-               gain_control->set_controllable (_route->gain_control());
-               gain_display->set_controllable (_route->gain_control());
-       } else {
-               gain_control->set_controllable (none);
-       }
-
-       if (_monitor) {
-
-               cut_all_button.set_controllable (_monitor->cut_control());
-               cut_all_button.watch ();
-               dim_all_button.set_controllable (_monitor->dim_control());
-               dim_all_button.watch ();
-               mono_button.set_controllable (_monitor->mono_control());
-               mono_button.watch ();
-
-               dim_control->set_controllable (_monitor->dim_level_control ());
-               dim_display->set_controllable (_monitor->dim_level_control ());
-               solo_boost_control->set_controllable (_monitor->solo_boost_control ());
-               solo_boost_display->set_controllable (_monitor->solo_boost_control ());
-
-       } else {
-
-               cut_all_button.set_controllable (none);
-               dim_all_button.set_controllable (none);
-               mono_button.set_controllable (none);
+       solo_cut_control->set_controllable (none);
+       solo_cut_display->set_controllable (none);
+       gain_control->set_controllable (none);
+       gain_display->set_controllable (none);
+       cut_all_button.set_controllable (none);
+       dim_all_button.set_controllable (none);
+       mono_button.set_controllable (none);
+       dim_control->set_controllable (none);
+       dim_display->set_controllable (none);
+       solo_boost_control->set_controllable (none);
+       solo_boost_display->set_controllable (none);
+}
 
-               dim_control->set_controllable (none);
-               dim_display->set_controllable (none);
-               solo_boost_control->set_controllable (none);
-               solo_boost_display->set_controllable (none);
-       }
+void
+MonitorSection::assign_controllables ()
+{
+       assert (_session);
+       assert (_route);
+       assert (_monitor);
+
+       solo_cut_control->set_controllable (_session->solo_cut_control());
+       solo_cut_display->set_controllable (_session->solo_cut_control());
+
+       gain_control->set_controllable (_route->gain_control());
+       gain_display->set_controllable (_route->gain_control());
+       cut_all_button.set_controllable (_monitor->cut_control());
+       cut_all_button.watch ();
+       dim_all_button.set_controllable (_monitor->dim_control());
+       dim_all_button.watch ();
+       mono_button.set_controllable (_monitor->mono_control());
+       mono_button.watch ();
+       dim_control->set_controllable (_monitor->dim_level_control ());
+       dim_display->set_controllable (_monitor->dim_level_control ());
+       solo_boost_control->set_controllable (_monitor->solo_boost_control ());
+       solo_boost_display->set_controllable (_monitor->solo_boost_control ());
 }
 
 string
@@ -1678,63 +1618,35 @@ MonitorSection::processors_changed (ARDOUR::RouteProcessorChange)
        update_processor_box ();
 }
 
+PluginSelector*
+MonitorSection::plugin_selector ()
+{
+       return Mixer_UI::instance()->plugin_selector ();
+}
+
 void
-MonitorSection::action_proxy0 (enum MonitorActions action)
+MonitorSection::use_others_actions ()
 {
-       MonitorSection* ms = Mixer_UI::instance()->monitor_section ();
-       if (!ms) {
-               return;
-       }
-       switch (action) {
-               case MonitorMono:
-                       ms->mono ();
-                       break;
-               case MonitorCutAll:
-                       ms->cut_all ();
-                       break;
-               case MonitorDimAll:
-                       ms->dim_all ();
-                       break;
-               case ToggleExclusiveSolo:
-                       ms->toggle_exclusive_solo ();
-                       break;
-               case ToggleMuteOverridesSolo:
-                       ms->toggle_mute_overrides_solo ();
-                       break;
-               case SoloUseInPlace:
-                       ms->solo_use_in_place ();
-                       break;
-               case SoloUseAFL:
-                       ms->solo_use_afl ();
-                       break;
-               case SoloUsePFL:
-                       ms->solo_use_pfl ();
-                       break;
-               case ToggleMonitorProcessorBox:
-                       ms->update_processor_box ();
-                       break;
-       }
+       rude_solo_button.set_related_action (ActionManager::get_action (X_("Main"), X_("cancel-solo")));
 }
 
 void
-MonitorSection::action_proxy1 (enum ChannelActions action, uint32_t chn)
+MonitorSection::toggle_use_monitor_section ()
 {
-       MonitorSection* ms = Mixer_UI::instance()->monitor_section ();
-       if (!ms) {
+       if (!_session) {
+               return;
+       }
+       bool want_ms = ActionManager::get_toggle_action (X_("Monitor"), "UseMonitorSection")->get_active();
+       bool have_ms = Config->get_use_monitor_bus ();
+
+       if (want_ms == have_ms) {
                return;
        }
-       switch (action) {
-               case CutChannel:
-                       ms->cut_channel (chn);
-                       break;
-               case DimChannel:
-                       ms->dim_channel (chn);
-                       break;
-               case SoloChannel:
-                       ms->solo_channel (chn);
-                       break;
-               case InvertChannel:
-                       ms->invert_channel (chn);
-                       break;
+
+       if (want_ms) {
+               Config->set_use_monitor_bus (true);
+               ActionManager::get_toggle_action (X_("Mixer"), X_("ToggleMonitorSection"))->set_active (true);
+       } else {
+               Config->set_use_monitor_bus (false);
        }
 }