add some more hand-holding language to the startup assistant
[ardour.git] / gtk2_ardour / io_selector.cc
index 3e8feba60c48e3c6e4641a854bdc0c35368bdb68..d7b65dc58b68354e5ca05e882ecaeeb46bd90814 100644 (file)
@@ -17,7 +17,6 @@
 
 */
 
-#include <gtkmm/messagedialog.h>
 #include <glibmm/objectbase.h>
 
 #include <gtkmm2ext/doi.h>
@@ -47,7 +46,7 @@ IOSelector::IOSelector (Gtk::Window* p, ARDOUR::Session* session, boost::shared_
        , _io (io)
 {
        setup_type ();
-       
+
        /* signal flow from 0 to 1 */
 
        _find_inputs_for_io_outputs = (_io->direction() == IO::Output);
@@ -97,7 +96,7 @@ IOSelector::io_changed_proxy ()
           so we can't call setup_all_ports (which results in a call to Route::foreach_processor)
           without a deadlock unless we break things up with this idle handler.
        */
-       
+
        Glib::signal_idle().connect_once (sigc::mem_fun (*this, &IOSelector::io_changed));
 }
 
@@ -139,16 +138,20 @@ IOSelector::set_state (ARDOUR::BundleChannel c[2], bool s)
        for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) {
                for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) {
 
-                       Port* f = _session->engine().get_port_by_name (*i);
+                       boost::shared_ptr<Port> f = _session->engine().get_port_by_name (*i);
                        if (!f) {
                                return;
                        }
 
-                       if (s) {
-                               _io->connect (f, *j, 0);
-                       } else {
-                               _io->disconnect (f, *j, 0);
-                       }
+                        if (s) {
+                               if (!f->connected_to (*j)) {
+                                       _io->connect (f, *j, 0);
+                               }
+                        } else {
+                               if (f->connected_to (*j)) {
+                                       _io->disconnect (f, *j, 0);
+                               }
+                        }
                }
        }
 }
@@ -156,6 +159,10 @@ IOSelector::set_state (ARDOUR::BundleChannel c[2], bool s)
 PortMatrixNode::State
 IOSelector::get_state (ARDOUR::BundleChannel c[2]) const
 {
+       if (c[0].bundle->nchannels() == ChanCount::ZERO || c[1].bundle->nchannels() == ChanCount::ZERO) {
+               return PortMatrixNode::NOT_ASSOCIATED;
+       }
+
        ARDOUR::Bundle::PortList const & our_ports = c[_ours].bundle->channel_ports (c[_ours].channel);
        ARDOUR::Bundle::PortList const & other_ports = c[_other].bundle->channel_ports (c[_other].channel);
 
@@ -168,7 +175,7 @@ IOSelector::get_state (ARDOUR::BundleChannel c[2]) const
        for (ARDOUR::Bundle::PortList::const_iterator i = our_ports.begin(); i != our_ports.end(); ++i) {
                for (ARDOUR::Bundle::PortList::const_iterator j = other_ports.begin(); j != other_ports.end(); ++j) {
 
-                       Port* f = _session->engine().get_port_by_name (*i);
+                       boost::shared_ptr<Port> f = _session->engine().get_port_by_name (*i);
 
                        /* since we are talking about an IO, our ports should all have an associated Port *,
                           so the above call should never fail */
@@ -213,10 +220,10 @@ IOSelector::channel_noun () const
 }
 
 IOSelectorWindow::IOSelectorWindow (ARDOUR::Session* session, boost::shared_ptr<ARDOUR::IO> io, bool /*can_cancel*/)
-       : _selector (this, session, io)
+       : ArdourWindow (_("I/O selector"))
+       , _selector (this, session, io)
 {
        set_name ("IOSelectorWindow2");
-       set_title (_("I/O selector"));
 
        add (_selector);
 
@@ -254,7 +261,7 @@ IOSelectorWindow::on_show ()
 }
 
 void
-IOSelectorWindow::io_name_changed (void* src)
+IOSelectorWindow::io_name_changed (void*)
 {
        ENSURE_GUI_THREAD (*this, &IOSelectorWindow::io_name_changed, src)