change PropertyChange from a bitfield into a real object, with all the many widesprea...
[ardour.git] / gtk2_ardour / processor_box.cc
index 900579e419b42ea975213ecb61c090469eeecb6d..c4d01e4458479078135821e4cc178d2ad0975df0 100644 (file)
@@ -80,7 +80,6 @@ class AUPluginUI;
 #endif
 
 using namespace std;
-using namespace sigc;
 using namespace ARDOUR;
 using namespace PBD;
 using namespace Gtk;
@@ -107,8 +106,8 @@ ProcessorEntry::ProcessorEntry (boost::shared_ptr<Processor> p, Width w)
        _active.set_active (_processor->active ());
        _active.signal_toggled().connect (sigc::mem_fun (*this, &ProcessorEntry::active_toggled));
        
-       _processor->ActiveChanged.connect (sigc::mem_fun (*this, &ProcessorEntry::processor_active_changed));
-       _processor->NameChanged.connect (sigc::mem_fun (*this, &ProcessorEntry::processor_name_changed));
+       _processor->ActiveChanged.connect (active_connection, boost::bind (&ProcessorEntry::processor_active_changed, this), gui_context());
+       _processor->PropertyChanged.connect (name_connection, ui_bind (&ProcessorEntry::processor_property_changed, this, _1), gui_context());
 }
 
 EventBox&
@@ -164,9 +163,11 @@ ProcessorEntry::processor_active_changed ()
 }
 
 void
-ProcessorEntry::processor_name_changed ()
+ProcessorEntry::processor_property_changed (const PropertyChange& what_changed)
 {
-       _name.set_text (name ());
+       if (what_changed.contains (ARDOUR::Properties::name)) {
+               _name.set_text (name ());
+       }
 }
 
 string
@@ -230,7 +231,7 @@ SendProcessorEntry::SendProcessorEntry (boost::shared_ptr<Send> s, Width w)
        _vbox.pack_start (_fader);
 
        _adjustment.signal_value_changed().connect (sigc::mem_fun (*this, &SendProcessorEntry::gain_adjusted));
-       _send->amp()->gain_control()->Changed.connect (sigc::mem_fun (*this, &SendProcessorEntry::show_gain));
+       _send->amp()->gain_control()->Changed.connect (send_gain_connection, boost::bind (&SendProcessorEntry::show_gain, this), gui_context());
        show_gain ();
 }
 
@@ -271,16 +272,17 @@ SendProcessorEntry::set_pixel_width (int p)
        _fader.set_fader_length (p);
 }
 
-ProcessorBox::ProcessorBox (ARDOUR::Session& sess, sigc::slot<PluginSelector*> get_plugin_selector,
-                       RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
-       : _session(sess)
-       , _parent_strip (parent)
+ProcessorBox::ProcessorBox (ARDOUR::Session* sess, boost::function<PluginSelector*()> get_plugin_selector,
+                           RouteRedirectSelection& rsel, MixerStrip* parent, bool owner_is_mixer)
+       : _parent_strip (parent)
        , _owner_is_mixer (owner_is_mixer)
        , ab_direction (true)
        , _get_plugin_selector (get_plugin_selector)
        , _placement(PreFader)
        , _rr_selection(rsel)
 {
+       set_session (sess);
+
        _width = Wide;
        processor_menu = 0;
        send_action_menu = 0;
@@ -320,17 +322,15 @@ ProcessorBox::set_route (boost::shared_ptr<Route> r)
                return;
        }
        
-       connections.clear ();
+       connections.drop_connections();
 
        /* new route: any existing block on processor redisplay must be meaningless */
        no_processor_redisplay = false;
        _route = r;
 
-       connections.push_back (_route->processors_changed.connect (sigc::mem_fun (*this, &ProcessorBox::route_processors_changed)));
-       connections.push_back (_route->GoingAway.connect (
-                       sigc::mem_fun (*this, &ProcessorBox::route_going_away)));
-       connections.push_back (_route->NameChanged.connect (
-                       sigc::mem_fun(*this, &ProcessorBox::route_name_changed)));
+       _route->processors_changed.connect (connections, ui_bind (&ProcessorBox::route_processors_changed, this, _1), gui_context());
+       _route->DropReferences.connect (connections, boost::bind (&ProcessorBox::route_going_away, this), gui_context());
+       _route->PropertyChanged.connect (connections, ui_bind (&ProcessorBox::route_property_changed, this, _1), gui_context());
 
        redisplay_processors ();
 }
@@ -438,7 +438,7 @@ ProcessorBox::build_send_action_menu ()
 Gtk::Menu*
 ProcessorBox::build_possible_aux_menu ()
 {
-       boost::shared_ptr<RouteList> rl = _session.get_routes_with_internal_returns();
+       boost::shared_ptr<RouteList> rl = _session->get_routes_with_internal_returns();
 
        if (rl->empty()) {
                return 0;
@@ -631,7 +631,7 @@ ProcessorBox::processor_button_press_event (GdkEventButton *ev, ProcessorEntry*
 
        if (processor && (Keyboard::is_edit_event (ev) || (ev->button == 1 && ev->type == GDK_2BUTTON_PRESS))) {
 
-               if (_session.engine().connected()) {
+               if (_session->engine().connected()) {
                        /* XXX giving an error message here is hard, because we may be in the midst of a button press */
                        edit_processor (processor);
                }
@@ -748,7 +748,7 @@ ProcessorBox::use_plugins (const SelectedPlugins& plugins)
 {
        for (SelectedPlugins::const_iterator p = plugins.begin(); p != plugins.end(); ++p) {
 
-               boost::shared_ptr<Processor> processor (new PluginInsert (_session, *p));
+               boost::shared_ptr<Processor> processor (new PluginInsert (*_session, *p));
 
                Route::ProcessorStreams err_streams;
 
@@ -813,18 +813,18 @@ ProcessorBox::weird_plugin_dialog (Plugin& p, Route::ProcessorStreams streams)
 void
 ProcessorBox::choose_insert ()
 {
-       boost::shared_ptr<Processor> processor (new PortInsert (_session, _route->mute_master()));
+       boost::shared_ptr<Processor> processor (new PortInsert (*_session, _route->mute_master()));
        _route->add_processor (processor, _placement);
 }
 
 void
 ProcessorBox::choose_send ()
 {
-       boost::shared_ptr<Send> send (new Send (_session, _route->mute_master()));
+       boost::shared_ptr<Send> send (new Send (*_session, _route->mute_master()));
 
        /* make an educated guess at the initial number of outputs for the send */
-       ChanCount outs = (_session.master_out())
-                       ? _session.master_out()->n_outputs()
+       ChanCount outs = (_session->master_out())
+                       ? _session->master_out()->n_outputs()
                        : _route->n_outputs();
 
        /* XXX need processor lock on route */
@@ -842,7 +842,7 @@ ProcessorBox::choose_send ()
           is closed.
         */
 
-       IOSelectorWindow *ios = new IOSelectorWindow (&_session, send->output(), true);
+       IOSelectorWindow *ios = new IOSelectorWindow (_session, send->output(), true);
        ios->show_all ();
 
        /* keep a reference to the send so it doesn't get deleted while
@@ -928,7 +928,7 @@ ProcessorBox::choose_aux (boost::weak_ptr<Route> wr)
        boost::shared_ptr<RouteList> rlist (new RouteList);
        rlist->push_back (_route);
 
-       _session.add_internal_sends (target, PreFader, rlist);
+       _session->add_internal_sends (target, PreFader, rlist);
 }
 
 void
@@ -990,7 +990,7 @@ ProcessorBox::build_processor_tooltip (EventBox& box, string start)
                tip += (*i)->processor()->name();
        }
        
-       ARDOUR_UI::instance()->tooltips().set_tip (box, tip);
+       ARDOUR_UI::instance()->set_tip (box, tip);
 }
 
 void
@@ -1021,10 +1021,11 @@ ProcessorBox::compute_processor_sort_keys ()
                Label label;
 
                label.set_text (_("\
-You cannot reorder this set of processors\n\
+You cannot reorder these plugins/sends/inserts\n\
 in that way because the inputs and\n\
-outputs do not work correctly."));
+outputs will not work correctly."));
 
+               dialog.get_vbox()->set_border_width (12);
                dialog.get_vbox()->pack_start (label);
                dialog.add_button (Stock::OK, RESPONSE_ACCEPT);
 
@@ -1220,7 +1221,7 @@ ProcessorBox::rename_processor (boost::shared_ptr<Processor> processor)
        case Gtk::RESPONSE_ACCEPT:
                name_prompter.get_result (result);
                if (result.length()) {
-                       if (_session.route_by_name (result)) {
+                       if (_session->route_by_name (result)) {
                                ARDOUR_UI::instance()->popup_error (_("A track already exists with that name."));
                                return;
                        }
@@ -1280,20 +1281,20 @@ ProcessorBox::paste_processor_state (const XMLNodeList& nlist, boost::shared_ptr
                        } else if (type->value() == "send") {
 
                                XMLNode n (**niter);
-                               Send::make_unique (n, _session);
-                               p.reset (new Send (_session, _route->mute_master(), n));
+                               Send::make_unique (n, *_session);
+                               p.reset (new Send (*_session, _route->mute_master(), n));
 
                        } else if (type->value() == "return") {
 
                                XMLNode n (**niter);
-                               Return::make_unique (n, _session);
-                               p.reset (new Return (_session, **niter));
+                               Return::make_unique (n, *_session);
+                               p.reset (new Return (*_session, **niter));
 
                        } else {
                                /* XXX its a bit limiting to assume that everything else
                                   is a plugin.
                                */
-                               p.reset (new PluginInsert (_session, **niter));
+                               p.reset (new PluginInsert (*_session, **niter));
                        }
 
                        copies.push_back (p);
@@ -1375,7 +1376,7 @@ ProcessorBox::clear_processors ()
        choices.push_back (_("Cancel"));
        choices.push_back (_("Yes, remove them all"));
 
-       Gtkmm2ext::Choice prompter (prompt, choices);
+       Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
 
        if (prompter.run () == 1) {
                _route->clear_processors (PreFader);
@@ -1400,7 +1401,7 @@ ProcessorBox::clear_processors (Placement p)
        choices.push_back (_("Cancel"));
        choices.push_back (_("Yes, remove them all"));
 
-       Gtkmm2ext::Choice prompter (prompt, choices);
+       Gtkmm2ext::Choice prompter (_("Remove processors"), prompt, choices);
 
        if (prompter.run () == 1) {
                _route->clear_processors (p);
@@ -1425,7 +1426,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
 
        if ((send = boost::dynamic_pointer_cast<Send> (processor)) != 0) {
 
-               if (!_session.engine().connected()) {
+               if (!_session->engine().connected()) {
                        return;
                }
 
@@ -1450,7 +1451,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
 
        } else if ((retrn = boost::dynamic_pointer_cast<Return> (processor)) != 0) {
 
-               if (!_session.engine().connected()) {
+               if (!_session->engine().connected()) {
                        return;
                }
 
@@ -1494,7 +1495,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
 
        } else if ((port_insert = boost::dynamic_pointer_cast<PortInsert> (processor)) != 0) {
 
-               if (!_session.engine().connected()) {
+               if (!_session->engine().connected()) {
                        MessageDialog msg ( _("Not connected to JACK - no I/O changes are possible"));
                        msg.run ();
                        return;
@@ -1503,7 +1504,7 @@ ProcessorBox::edit_processor (boost::shared_ptr<Processor> processor)
                PortInsertWindow *io_selector;
 
                if (port_insert->get_gui() == 0) {
-                       io_selector = new PortInsertWindow (&_session, port_insert);
+                       io_selector = new PortInsertWindow (_session, port_insert);
                        port_insert->set_gui (io_selector);
 
                } else {
@@ -1765,9 +1766,13 @@ ProcessorBox::rb_edit ()
 }
 
 void
-ProcessorBox::route_name_changed ()
+ProcessorBox::route_property_changed (const PropertyChange& what_changed)
 {
-       ENSURE_GUI_THREAD (*this, &ProcessorBox::route_name_changed)
+       if (!what_changed.contains (ARDOUR::Properties::name)) {
+               return;
+       }
+
+       ENSURE_GUI_THREAD (*this, &ProcessorBox::route_property_changed, what_changed);
 
        boost::shared_ptr<Processor> processor;
        boost::shared_ptr<PluginInsert> plugin_insert;