diff options
author | Carl Hetherington <carl@carlh.net> | 2010-07-27 02:09:51 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2010-07-27 02:09:51 +0000 |
commit | 4e8d402fd2f92454c0ce1460e0030020b72c3888 (patch) | |
tree | 8bebc1154fa4eeefe74db6e38383a93ce2e59607 /gtk2_ardour | |
parent | f2df65db6a09e777ed1fc8d6b7b790c2468c5597 (diff) |
Fix route port matrix to only display the relevant port types.
git-svn-id: svn://localhost/ardour2/branches/3.0@7505 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/io_selector.cc | 45 | ||||
-rw-r--r-- | gtk2_ardour/io_selector.h | 5 | ||||
-rw-r--r-- | gtk2_ardour/port_matrix.cc | 2 |
3 files changed, 49 insertions, 3 deletions
diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc index eff2583c42..f90ce88545 100644 --- a/gtk2_ardour/io_selector.cc +++ b/gtk2_ardour/io_selector.cc @@ -46,6 +46,8 @@ IOSelector::IOSelector (Gtk::Window* p, ARDOUR::Session* session, boost::shared_ : PortMatrix (p, session, DataType::NIL) , _io (io) { + setup_type (); + /* signal flow from 0 to 1 */ _find_inputs_for_io_outputs = (_io->direction() == IO::Output); @@ -61,17 +63,58 @@ IOSelector::IOSelector (Gtk::Window* p, ARDOUR::Session* session, boost::shared_ _port_group.reset (new PortGroup (io->name())); _ports[_ours].add_group (_port_group); + io->changed.connect (_io_connection, invalidator (*this), boost::bind (&IOSelector::io_changed_proxy, this), gui_context ()); + setup_all_ports (); init (); } void +IOSelector::setup_type () +{ + /* set type according to what's in the IO */ + + int N = 0; + DataType type_with_ports = DataType::NIL; + for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) { + if (_io->ports().num_ports (*i)) { + type_with_ports = *i; + ++N; + } + } + + if (N <= 1) { + set_type (type_with_ports); + } else { + set_type (DataType::NIL); + } +} + +void +IOSelector::io_changed_proxy () +{ + /* The IO's changed signal is emitted from code that holds its route's processor lock, + 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)); +} + +void +IOSelector::io_changed () +{ + setup_type (); + setup_all_ports (); +} + +void IOSelector::setup_ports (int dim) { if (!_session) { return; } - + _ports[dim].suspend_signals (); if (dim == _other) { diff --git a/gtk2_ardour/io_selector.h b/gtk2_ardour/io_selector.h index 21bd6a2d3e..32946fb1b7 100644 --- a/gtk2_ardour/io_selector.h +++ b/gtk2_ardour/io_selector.h @@ -57,11 +57,16 @@ class IOSelector : public PortMatrix private: + void setup_type (); + void io_changed (); + void io_changed_proxy (); + int _other; int _ours; boost::shared_ptr<ARDOUR::IO> _io; boost::shared_ptr<PortGroup> _port_group; bool _find_inputs_for_io_outputs; + PBD::ScopedConnection _io_connection; }; class IOSelectorWindow : public Gtk::Window diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 6113412df9..06f869b675 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -215,8 +215,6 @@ void PortMatrix::set_type (DataType t) { _type = t; - - setup_all_ports (); } void |