radically change Keyboard/Binding API design to disconnect Gtk::Action lookup from...
[ardour.git] / gtk2_ardour / processor_box.cc
index b72fcbe276f605967e149ad648ebc1ea9814f37e..8fa8d725c51b17e603cc3bac1a5a9fbe1686a611 100644 (file)
@@ -75,6 +75,7 @@
 #include "send_ui.h"
 #include "timers.h"
 #include "tooltips.h"
+#include "new_plugin_preset_dialog.h"
 
 #include "i18n.h"
 
@@ -132,6 +133,12 @@ ProcessorEntry::ProcessorEntry (ProcessorBox* parent, boost::shared_ptr<Processo
                _button.set_elements(ArdourButton::Element(_button.elements() & ~ArdourButton::Indicator));
                _unknown_processor = true;
        }
+       {
+               boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
+               if (pi && pi->plugin()) {
+                       _plugin_preset_pointer = PluginPresetPtr (new PluginPreset (pi->plugin()->get_info()));
+               }
+       }
        if (_processor) {
 
                _vbox.pack_start (_routing_icon);
@@ -211,6 +218,60 @@ ProcessorEntry::drag_text () const
 {
        return name (Wide);
 }
+bool
+ProcessorEntry::drag_data_get (Glib::RefPtr<Gdk::DragContext> const, Gtk::SelectionData &data)
+{
+       if (data.get_target() == "PluginPresetPtr") {
+               boost::shared_ptr<PluginInsert> pi = boost::dynamic_pointer_cast<PluginInsert> (_processor);
+
+               if (!_plugin_preset_pointer || !pi) {
+                       data.set (data.get_target(), 8, NULL, 0);
+                       return true;
+               }
+
+               boost::shared_ptr<ARDOUR::Plugin> plugin = pi->plugin();
+               assert (plugin);
+
+               PluginManager& manager (PluginManager::instance());
+               bool fav = manager.get_status (_plugin_preset_pointer->_pip) == PluginManager::Favorite;
+
+               NewPluginPresetDialog d (plugin,
+                               string_compose(_("New Favorite Preset for \"%1\""),_plugin_preset_pointer->_pip->name), !fav);
+
+               _plugin_preset_pointer->_preset.valid = false;
+
+               switch (d.run ()) {
+                       case Gtk::RESPONSE_CANCEL:
+                               data.set (data.get_target(), 8, NULL, 0);
+                               return true;
+                               break;
+
+                       case Gtk::RESPONSE_NO:
+                               break;
+
+                       case Gtk::RESPONSE_ACCEPT:
+                               if (d.name().empty()) {
+                                       break;
+                               }
+
+                               if (d.replace ()) {
+                                       plugin->remove_preset (d.name ());
+                               }
+
+                               Plugin::PresetRecord const r = plugin->save_preset (d.name());
+
+                               if (!r.uri.empty ()) {
+                                       _plugin_preset_pointer->_preset.uri   = r.uri;
+                                       _plugin_preset_pointer->_preset.label = r.label;
+                                       _plugin_preset_pointer->_preset.user  = r.user;
+                                       _plugin_preset_pointer->_preset.valid = r.valid;
+                               }
+               }
+               data.set (data.get_target(), 8, (const guchar *) &_plugin_preset_pointer, sizeof (PluginPresetPtr));
+               return true;
+       }
+       return false;
+}
 
 void
 ProcessorEntry::set_position (Position p, uint32_t num)
@@ -275,13 +336,39 @@ ProcessorEntry::set_enum_width (Width w)
 }
 
 void
-ProcessorEntry::led_clicked()
+ProcessorEntry::led_clicked(GdkEventButton *ev)
 {
+       bool ctrl_shift_pressed = false;
+       Keyboard::ModifierMask ctrl_shift_mask = Keyboard::ModifierMask (Keyboard::PrimaryModifier|Keyboard::TertiaryModifier);
+
+       if (Keyboard::modifier_state_equals (ev->state, ctrl_shift_mask)) {
+               ctrl_shift_pressed = true;
+       }
+
        if (_processor) {
                if (_button.get_active ()) {
-                       _processor->deactivate ();
+                       if (ctrl_shift_pressed) {
+                               _parent->all_visible_processors_active(false);
+
+                               if (_position == Fader) {
+                                       _processor->deactivate ();
+                               }
+                       }
+                       else {
+                               _processor->deactivate ();
+                       }
+
                } else {
-                       _processor->activate ();
+                       if (ctrl_shift_pressed) {
+                               _parent->all_visible_processors_active(true);
+
+                               if (_position == Fader) {
+                                       _processor->activate ();
+                               }
+                       }
+                       else {
+                               _processor->activate ();
+                       }
                }
        }
 }
@@ -328,7 +415,7 @@ ProcessorEntry::setup_tooltip ()
                        }
                        if (pi->plugin()->has_editor()) {
                                ARDOUR_UI_UTILS::set_tooltip (_button,
-                                               string_compose (_("<b>%1</b>\nDouble-click to show GUI.\nAlt+double-click to show generic GUI.%2"), name (Wide), postfix));
+                                               string_compose (_("<b>%1</b>\nDouble-click to show GUI.\n%2+double-click to show generic GUI.%3"), name (Wide), Keyboard::primary_modifier_name (), postfix));
                        } else {
                                ARDOUR_UI_UTILS::set_tooltip (_button,
                                                string_compose (_("<b>%1</b>\nDouble-click to show generic GUI.%2"), name (Wide), postfix));
@@ -533,7 +620,7 @@ ProcessorEntry::Control::Control (boost::shared_ptr<AutomationControl> c, string
                _button.show ();
 
                _button.signal_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
-               _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked));
+               _button.signal_led_clicked.connect (sigc::mem_fun (*this, &Control::button_clicked_event));
                // dup. currently timers are used :(
                //c->Changed.connect (_connection, MISSING_INVALIDATOR, boost::bind (&Control::control_changed, this), gui_context ());
 
@@ -606,7 +693,7 @@ ProcessorEntry::Control::set_tooltip ()
                snprintf (tmp, sizeof(tmp), "%s: %.2f", _name.c_str(), c->internal_to_user (c->get_value ()));
        }
 
-       string sm = Glib::Markup::escape_text (tmp);
+       string sm = Gtkmm2ext::markup_escape_text (tmp);
        _slider_persistant_tooltip.set_tip (sm);
        ARDOUR_UI_UTILS::set_tooltip (_button, sm);
 }
@@ -624,7 +711,7 @@ ProcessorEntry::Control::slider_adjusted ()
                return;
        }
 
-       c->set_value ( c->interface_to_internal(_adjustment.get_value ()) );
+       c->set_value ( c->interface_to_internal(_adjustment.get_value ()) , Controllable::NoGroup);
        set_tooltip ();
 }
 
@@ -639,11 +726,19 @@ ProcessorEntry::Control::button_clicked ()
 
        bool const n = _button.get_active ();
 
-       c->set_value (n ? 0 : 1);
+       c->set_value (n ? 0 : 1, Controllable::NoGroup);
        _button.set_active (!n);
        set_tooltip ();
 }
 
+void
+ProcessorEntry::Control::button_clicked_event (GdkEventButton *ev)
+{
+       (void) ev;
+
+       button_clicked ();
+}
+
 void
 ProcessorEntry::Control::control_changed ()
 {
@@ -1007,6 +1102,30 @@ ProcessorEntry::RoutingIcon::on_expose_event (GdkEventExpose* ev)
        return true;
 }
 
+static std::list<Gtk::TargetEntry> drop_targets()
+{
+       std::list<Gtk::TargetEntry> tmp;
+       tmp.push_back (Gtk::TargetEntry ("processor")); // from processor-box to processor-box
+       tmp.push_back (Gtk::TargetEntry ("PluginInfoPtr")); // from plugin-manager
+       tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // from sidebar
+       return tmp;
+}
+
+static std::list<Gtk::TargetEntry> drag_targets()
+{
+       std::list<Gtk::TargetEntry> tmp;
+       tmp.push_back (Gtk::TargetEntry ("PluginPresetPtr")); // to sidebar (optional preset)
+       tmp.push_back (Gtk::TargetEntry ("processor")); // to processor-box (copy)
+       return tmp;
+}
+
+static std::list<Gtk::TargetEntry> drag_targets_noplugin()
+{
+       std::list<Gtk::TargetEntry> tmp;
+       tmp.push_back (Gtk::TargetEntry ("processor")); // to processor box (sends, faders re-order)
+       return tmp;
+}
+
 ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
                            RouteProcessorSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
        : _parent_strip (parent)
@@ -1016,6 +1135,7 @@ ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelecto
        , _placement (-1)
        , _visible_prefader_processors (0)
        , _rr_selection(rsel)
+       , processor_display (drop_targets())
        , _redisplay_pending (false)
 
 {
@@ -1043,6 +1163,7 @@ ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelecto
 
        processor_display.Reordered.connect (sigc::mem_fun (*this, &ProcessorBox::reordered));
        processor_display.DropFromAnotherBox.connect (sigc::mem_fun (*this, &ProcessorBox::object_drop));
+       processor_display.DropFromExternal.connect (sigc::mem_fun (*this, &ProcessorBox::plugin_drop));
 
        processor_scroller.show ();
        processor_display.show ();
@@ -1105,16 +1226,16 @@ ProcessorBox::route_going_away ()
        _route.reset ();
 }
 
-void
-ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
+boost::shared_ptr<Processor>
+ProcessorBox::find_drop_position (ProcessorEntry* position)
 {
        boost::shared_ptr<Processor> p;
        if (position) {
                p = position->processor ();
                if (!p) {
                        /* dropped on the blank entry (which will be before the
-                          fader), so use the first non-blank child as our
-                          `dropped on' processor */
+                                fader), so use the first non-blank child as our
+                                `dropped on' processor */
                        list<ProcessorEntry*> c = processor_display.children ();
                        list<ProcessorEntry*>::iterator i = c.begin ();
 
@@ -1123,6 +1244,97 @@ ProcessorBox::object_drop(DnDVBox<ProcessorEntry>* source, ProcessorEntry* posit
                        assert (p);
                }
        }
+       return p;
+}
+
+void
+ProcessorBox::_drop_plugin_preset (Gtk::SelectionData const &data, Route::ProcessorList &pl)
+{
+               const void * d = data.get_data();
+               const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginPresetPtr>*>(d);
+
+               PluginPresetList nfos;
+               TreeView* source;
+               tv->get_object_drag_data (nfos, &source);
+
+               for (list<PluginPresetPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
+                       PluginPresetPtr ppp = (*i);
+                       PluginInfoPtr pip = ppp->_pip;
+                       PluginPtr p = pip->load (*_session);
+                       if (!p) {
+                               continue;
+                       }
+
+                       if (ppp->_preset.valid) {
+                               p->load_preset (ppp->_preset);
+                       }
+
+                       boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
+                       if (Config->get_new_plugins_active ()) {
+                               processor->activate ();
+                       }
+                       pl.push_back (processor);
+               }
+}
+
+void
+ProcessorBox::_drop_plugin (Gtk::SelectionData const &data, Route::ProcessorList &pl)
+{
+               const void * d = data.get_data();
+               const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>* tv = reinterpret_cast<const Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr>*>(d);
+               PluginInfoList nfos;
+
+               TreeView* source;
+               tv->get_object_drag_data (nfos, &source);
+
+               for (list<PluginInfoPtr>::const_iterator i = nfos.begin(); i != nfos.end(); ++i) {
+                       PluginPtr p = (*i)->load (*_session);
+                       if (!p) {
+                               continue;
+                       }
+                       boost::shared_ptr<Processor> processor (new PluginInsert (*_session, p));
+                       if (Config->get_new_plugins_active ()) {
+                               processor->activate ();
+                       }
+                       pl.push_back (processor);
+               }
+}
+
+void
+ProcessorBox::plugin_drop (Gtk::SelectionData const &data, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
+{
+       if (!_session) {
+               return;
+       }
+
+       boost::shared_ptr<Processor> p = find_drop_position (position);
+       Route::ProcessorList pl;
+
+       if (data.get_target() == "PluginInfoPtr") {
+               _drop_plugin (data, pl);
+       }
+       else if (data.get_target() == "PluginPresetPtr") {
+               _drop_plugin_preset (data, pl);
+       }
+       else {
+               return;
+       }
+
+       Route::ProcessorStreams err;
+       if (_route->add_processors (pl, p, &err)) {
+               string msg = _(
+                               "Processor Drag/Drop failed. Probably because\n\
+the I/O configuration of the plugins could\n\
+not match the configuration of this track.");
+               MessageDialog am (msg);
+               am.run ();
+       }
+}
+
+void
+ProcessorBox::object_drop (DnDVBox<ProcessorEntry>* source, ProcessorEntry* position, Glib::RefPtr<Gdk::DragContext> const & context)
+{
+       boost::shared_ptr<Processor> p = find_drop_position (position);
 
        list<ProcessorEntry*> children = source->selection ();
        list<boost::shared_ptr<Processor> > procs;
@@ -1182,6 +1394,10 @@ ProcessorBox::build_possible_aux_menu ()
                return 0;
        }
 
+       if (_route->is_monitor ()) {
+               return 0;
+       }
+
        using namespace Menu_Helpers;
        Menu* menu = manage (new Menu);
        MenuList& items = menu->items();
@@ -1227,6 +1443,9 @@ ProcessorBox::show_processor_menu (int arg)
                }
        }
 
+       ActionManager::get_action (X_("ProcessorMenu"), "newinsert")->set_sensitive (!_route->is_monitor ());
+       ActionManager::get_action (X_("ProcessorMenu"), "newsend")->set_sensitive (!_route->is_monitor ());
+
        ProcessorEntry* single_selection = 0;
        if (processor_display.selection().size() == 1) {
                single_selection = processor_display.selection().front();
@@ -1253,7 +1472,7 @@ ProcessorBox::show_processor_menu (int arg)
 
        Gtk::MenuItem* send_menu_item = dynamic_cast<Gtk::MenuItem*>(ActionManager::get_widget("/ProcessorMenu/send_options"));
        if (send_menu_item) {
-               if (single_selection) {
+               if (single_selection && !_route->is_monitor()) {
                        Menu* m = single_selection->build_send_options_menu ();
                        if (m && !m->items().empty()) {
                                send_menu_item->set_submenu (*m);
@@ -1530,10 +1749,13 @@ ProcessorBox::use_plugins (const SelectedPlugins& plugins)
                        weird_plugin_dialog (**p, err_streams);
                        return true;
                        // XXX SHAREDPTR delete plugin here .. do we even need to care?
-               } else {
-
-                       if (Profile->get_sae()) {
-                               processor->activate ();
+               } else if (plugins.size() == 1 && Config->get_open_gui_after_adding_plugin()) {
+                       if (_session->engine().connected () && processor_can_be_edited (processor)) {
+                               if ((*p)->has_editor ()) {
+                                       edit_processor (processor);
+                               } else {
+                                       generic_edit_processor (processor);
+                               }
                        }
                }
        }
@@ -1780,7 +2002,7 @@ ProcessorBox::maybe_add_processor_to_ui_list (boost::weak_ptr<Processor> w)
        const XMLNode* ui_xml = _session->extra_xml (X_("UI"));
 
        if (ui_xml) {
-               wp->set_state (*ui_xml);
+               wp->set_state (*ui_xml, 0);
        }
 
         void* existing_ui = p->get_ui ();
@@ -1805,7 +2027,8 @@ ProcessorBox::help_count_visible_prefader_processors (boost::weak_ptr<Processor>
                         )
           ) {
 
-               if (boost::dynamic_pointer_cast<Amp>(processor) && boost::dynamic_pointer_cast<Amp>(processor)->type() == X_("amp")) {
+               if (boost::dynamic_pointer_cast<Amp>(processor) && 
+                   boost::dynamic_pointer_cast<Amp>(processor)->gain_control()->parameter().type() == GainAutomation) {
                        *amp_seen = true;
                } else {
                        if (!*amp_seen) {
@@ -1868,7 +2091,16 @@ ProcessorBox::add_processor_to_display (boost::weak_ptr<Processor> p)
                e->show_all_controls ();
        }
 
-       processor_display.add_child (e);
+       if (plugin_insert
+#ifdef MIXBUS
+                       && !plugin_insert->plugin(0)->is_channelstrip()
+#endif
+                )
+       {
+               processor_display.add_child (e, drag_targets());
+       } else {
+               processor_display.add_child (e, drag_targets_noplugin());
+       }
 }
 
 void
@@ -1886,7 +2118,8 @@ ProcessorBox::setup_entry_positions ()
 
        uint32_t num = 0;
        for (list<ProcessorEntry*>::iterator i = children.begin(); i != children.end(); ++i) {
-               if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) && boost::dynamic_pointer_cast<Amp>((*i)->processor())->type() == X_("amp")) {
+               if (boost::dynamic_pointer_cast<Amp>((*i)->processor()) && 
+                   boost::dynamic_pointer_cast<Amp>((*i)->processor())->gain_control()->parameter().type() == GainAutomation) {
                        pre_fader = false;
                        (*i)->set_position (ProcessorEntry::Fader, num++);
                } else {
@@ -2458,7 +2691,7 @@ ProcessorBox::get_editor_window (boost::shared_ptr<Processor> processor, bool us
                }
        }
 
-       if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->type() == X_("amp")) {
+       if (boost::dynamic_pointer_cast<Amp> (processor) && boost::dynamic_pointer_cast<Amp> (processor)->gain_control()->parameter().type() == GainAutomation) {
 
                if (_parent_strip) {
                        _parent_strip->revert_to_default_display ();
@@ -2567,68 +2800,71 @@ ProcessorBox::get_generic_editor_window (boost::shared_ptr<Processor> processor)
 void
 ProcessorBox::register_actions ()
 {
-       Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Gtk::ActionGroup::create(X_("ProcessorMenu"));
+       Glib::RefPtr<Gtk::ActionGroup> popup_act_grp = Actions.create_action_group (X_("ProcessorMenu"));
        Glib::RefPtr<Action> act;
 
        /* new stuff */
-       ActionManager::register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
+       Actions.register_action (popup_act_grp, X_("newplugin"), _("New Plugin"),
                        sigc::ptr_fun (ProcessorBox::rb_choose_plugin));
 
-       act = ActionManager::register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
+       act = Actions.register_action (popup_act_grp, X_("newinsert"), _("New Insert"),
                        sigc::ptr_fun (ProcessorBox::rb_choose_insert));
        ActionManager::engine_sensitive_actions.push_back (act);
-       act = ActionManager::register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
+       act = Actions.register_action (popup_act_grp, X_("newsend"), _("New External Send ..."),
                        sigc::ptr_fun (ProcessorBox::rb_choose_send));
        ActionManager::engine_sensitive_actions.push_back (act);
 
-       ActionManager::register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
+       Actions.register_action (popup_act_grp, X_("newaux"), _("New Aux Send ..."));
 
-       ActionManager::register_action (popup_act_grp, X_("controls"), _("Controls"));
-       ActionManager::register_action (popup_act_grp, X_("send_options"), _("Send Options"));
+       Actions.register_action (popup_act_grp, X_("controls"), _("Controls"));
+       Actions.register_action (popup_act_grp, X_("send_options"), _("Send Options"));
 
-       ActionManager::register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
+       Actions.register_action (popup_act_grp, X_("clear"), _("Clear (all)"),
                        sigc::ptr_fun (ProcessorBox::rb_clear));
-       ActionManager::register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
+       Actions.register_action (popup_act_grp, X_("clear_pre"), _("Clear (pre-fader)"),
                        sigc::ptr_fun (ProcessorBox::rb_clear_pre));
-       ActionManager::register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
+       Actions.register_action (popup_act_grp, X_("clear_post"), _("Clear (post-fader)"),
                        sigc::ptr_fun (ProcessorBox::rb_clear_post));
 
        /* standard editing stuff */
-       cut_action = ActionManager::register_action (popup_act_grp, X_("cut"), _("Cut"),
-                                                     sigc::ptr_fun (ProcessorBox::rb_cut));
-       copy_action = ActionManager::register_action (popup_act_grp, X_("copy"), _("Copy"),
-                       sigc::ptr_fun (ProcessorBox::rb_copy));
-       delete_action = ActionManager::register_action (popup_act_grp, X_("delete"), _("Delete"),
-                       sigc::ptr_fun (ProcessorBox::rb_delete));
-
-       paste_action = ActionManager::register_action (popup_act_grp, X_("paste"), _("Paste"),
+
+       cut_action = Actions.register_action (popup_act_grp, X_("cut"), _("Cut"),
+                                                           sigc::ptr_fun (ProcessorBox::rb_cut));
+       copy_action = Actions.register_action (popup_act_grp, X_("copy"), _("Copy"),
+                                                            sigc::ptr_fun (ProcessorBox::rb_copy));
+       delete_action = Actions.register_action (popup_act_grp, X_("delete"), _("Delete"),
+                                                              sigc::ptr_fun (ProcessorBox::rb_delete));
+       
+       ActionManager::plugin_selection_sensitive_actions.push_back (cut_action);
+       ActionManager::plugin_selection_sensitive_actions.push_back (copy_action);
+       ActionManager::plugin_selection_sensitive_actions.push_back (delete_action);
+       
+       paste_action = processor_box_actions.register_action (popup_act_grp, X_("paste"), _("Paste"),
                        sigc::ptr_fun (ProcessorBox::rb_paste));
-       rename_action = ActionManager::register_action (popup_act_grp, X_("rename"), _("Rename"),
+       rename_action = Actions.register_action (popup_act_grp, X_("rename"), _("Rename"),
                        sigc::ptr_fun (ProcessorBox::rb_rename));
-       ActionManager::register_action (popup_act_grp, X_("selectall"), _("Select All"),
+       Actions.register_action (popup_act_grp, X_("selectall"), _("Select All"),
                        sigc::ptr_fun (ProcessorBox::rb_select_all));
-       ActionManager::register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
+       Actions.register_action (popup_act_grp, X_("deselectall"), _("Deselect All"),
                        sigc::ptr_fun (ProcessorBox::rb_deselect_all));
 
        /* activation etc. */
 
-       ActionManager::register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
+       Actions.register_action (popup_act_grp, X_("activate_all"), _("Activate All"),
                        sigc::ptr_fun (ProcessorBox::rb_activate_all));
-       ActionManager::register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
+       Actions.register_action (popup_act_grp, X_("deactivate_all"), _("Deactivate All"),
                        sigc::ptr_fun (ProcessorBox::rb_deactivate_all));
-       ActionManager::register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
+       Actions.register_action (popup_act_grp, X_("ab_plugins"), _("A/B Plugins"),
                        sigc::ptr_fun (ProcessorBox::rb_ab_plugins));
 
        /* show editors */
-       edit_action = ActionManager::register_action (
+       edit_action = Actions.register_action (
                popup_act_grp, X_("edit"), _("Edit..."),
                sigc::ptr_fun (ProcessorBox::rb_edit));
 
-       edit_generic_action = ActionManager::register_action (
+       edit_generic_action = Actions.register_action (
                popup_act_grp, X_("edit-generic"), _("Edit with generic controls..."),
                sigc::ptr_fun (ProcessorBox::rb_edit_generic));
-
-       ActionManager::add_action_group (popup_act_grp);
 }
 
 void
@@ -2849,7 +3085,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
 
        if (proxy) {
                proxy->set_custom_ui_mode (true);
-               proxy->toggle ();
+               proxy->show_the_right_window ();
        }
 }
 
@@ -2867,7 +3103,7 @@ ProcessorBox::generic_edit_processor (boost::shared_ptr<Processor> processor)
 
        if (proxy) {
                proxy->set_custom_ui_mode (false);
-               proxy->toggle ();
+               proxy->show_the_right_window ();
        }
 }
 
@@ -3072,7 +3308,7 @@ ProcessorWindowProxy::session_handle()
 }
 
 XMLNode&
-ProcessorWindowProxy::get_state () const
+ProcessorWindowProxy::get_state ()
 {
        XMLNode *node;
        node = &ProxyBase::get_state();
@@ -3080,8 +3316,8 @@ ProcessorWindowProxy::get_state () const
        return *node;
 }
 
-void
-ProcessorWindowProxy::set_state (const XMLNode& node)
+int
+ProcessorWindowProxy::set_state (const XMLNode& node, int /*version*/)
 {
        XMLNodeList children = node.children ();
        XMLNodeList::const_iterator i = children.begin ();
@@ -3100,7 +3336,7 @@ ProcessorWindowProxy::set_state (const XMLNode& node)
                }
        }
 
-       ProxyBase::set_state(node);
+       return ProxyBase::set_state (node, 0);
 }
 
 Gtk::Window*
@@ -3133,13 +3369,16 @@ ProcessorWindowProxy::get (bool create)
 }
 
 void
-ProcessorWindowProxy::toggle ()
+ProcessorWindowProxy::show_the_right_window ()
 {
        if (_window && (is_custom != want_custom)) {
                /* drop existing window - wrong type */
                drop_window ();
+               get (true);
+               setup ();
+               assert (_window);
+               is_custom = want_custom;
        }
-       is_custom = want_custom;
 
-       WM::ProxyBase::toggle ();
+       toggle ();
 }