X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=gtk2_ardour%2Fio_selector.cc;h=3e8feba60c48e3c6e4641a854bdc0c35368bdb68;hb=d31a63c68592d8a54d9a728c787c17885677151f;hp=77f917d92b275bb4df93b6e6db303d81dd396fc3;hpb=64dc5427e4f5339a16a018692dd94f476c53cae9;p=ardour.git diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc index 77f917d92b..3e8feba60c 100644 --- a/gtk2_ardour/io_selector.cc +++ b/gtk2_ardour/io_selector.cc @@ -29,6 +29,7 @@ #include "ardour/track.h" #include "ardour/audio_track.h" #include "ardour/midi_track.h" +#include "ardour/mtdm.h" #include "ardour/data_type.h" #include "ardour/port.h" #include "ardour/bundle.h" @@ -42,9 +43,11 @@ using namespace ARDOUR; using namespace Gtk; IOSelector::IOSelector (Gtk::Window* p, ARDOUR::Session* session, boost::shared_ptr io) - : PortMatrix (p, session, io->default_type()) + : PortMatrix (p, session, DataType::NIL) , _io (io) { + setup_type (); + /* signal flow from 0 to 1 */ _find_inputs_for_io_outputs = (_io->direction() == IO::Output); @@ -60,22 +63,63 @@ 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) { - _ports[_other].gather (_session, _find_inputs_for_io_outputs, false); + _ports[_other].gather (_session, type(), _find_inputs_for_io_outputs, false); } else { @@ -115,7 +159,7 @@ IOSelector::get_state (ARDOUR::BundleChannel c[2]) const 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); - if (our_ports.empty() || other_ports.empty()) { + if (!_session || our_ports.empty() || other_ports.empty()) { /* we're looking at a bundle with no parts associated with this channel, so nothing to connect */ return PortMatrixNode::NOT_ASSOCIATED; @@ -156,6 +200,18 @@ IOSelector::list_is_global (int dim) const return (dim == _other); } +string +IOSelector::disassociation_verb () const +{ + return _("Disconnect"); +} + +string +IOSelector::channel_noun () const +{ + return _("port"); +} + IOSelectorWindow::IOSelectorWindow (ARDOUR::Session* session, boost::shared_ptr io, bool /*can_cancel*/) : _selector (this, session, io) { @@ -213,103 +269,3 @@ IOSelectorWindow::io_name_changed (void* src) set_title (title); } -PortInsertUI::PortInsertUI (Gtk::Window* parent, ARDOUR::Session* sess, boost::shared_ptr pi) - : input_selector (parent, sess, pi->input()) - , output_selector (parent, sess, pi->output()) -{ - output_selector.set_min_height_divisor (2); - input_selector.set_min_height_divisor (2); - - pack_start (output_selector, true, true); - pack_start (input_selector, true, true); -} - -void -PortInsertUI::redisplay () -{ - input_selector.setup_ports (input_selector.other()); - output_selector.setup_ports (output_selector.other()); -} - -void -PortInsertUI::finished (IOSelector::Result r) -{ - input_selector.Finished (r); - output_selector.Finished (r); -} - - -PortInsertWindow::PortInsertWindow (ARDOUR::Session* sess, boost::shared_ptr pi, bool can_cancel) - : ArdourDialog ("port insert dialog"), - _portinsertui (this, sess, pi), - ok_button (can_cancel ? _("OK"): _("Close")), - cancel_button (_("Cancel")) -{ - - set_name ("IOSelectorWindow"); - string title = _("ardour: "); - title += pi->name(); - set_title (title); - - ok_button.set_name ("IOSelectorButton"); - if (!can_cancel) { - ok_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON))); - } - cancel_button.set_name ("IOSelectorButton"); - - if (can_cancel) { - cancel_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CANCEL, Gtk::ICON_SIZE_BUTTON))); - get_action_area()->pack_start (cancel_button, false, false); - } else { - cancel_button.hide(); - } - get_action_area()->pack_start (ok_button, false, false); - - get_vbox()->pack_start (_portinsertui); - - ok_button.signal_clicked().connect (sigc::mem_fun (*this, &PortInsertWindow::accept)); - cancel_button.signal_clicked().connect (sigc::mem_fun (*this, &PortInsertWindow::cancel)); - - signal_delete_event().connect (sigc::mem_fun (*this, &PortInsertWindow::wm_delete), false); - - going_away_connection = pi->GoingAway.connect (sigc::mem_fun (*this, &PortInsertWindow::plugin_going_away)); -} - -bool -PortInsertWindow::wm_delete (GdkEventAny* /*event*/) -{ - accept (); - return true; -} - -void -PortInsertWindow::plugin_going_away () -{ - ENSURE_GUI_THREAD (*this, &PortInsertWindow::plugin_going_away) - - going_away_connection.disconnect (); - delete_when_idle (this); -} - -void -PortInsertWindow::on_map () -{ - _portinsertui.redisplay (); - Window::on_map (); -} - - -void -PortInsertWindow::cancel () -{ - _portinsertui.finished (IOSelector::Cancelled); - hide (); -} - -void -PortInsertWindow::accept () -{ - _portinsertui.finished (IOSelector::Accepted); - hide (); -} -