X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fio_selector.cc;h=0738758931193a034eb73ff0b51463d04172a2e5;hb=f420fed45db5417b5360c525ae1fcc8e919f3ac9;hp=7ff12612e60c30dee554a382f311fa766ef8c6e8;hpb=d6ef740e9002c7112bc47cb2d9d8d4b8609aa089;p=ardour.git diff --git a/gtk2_ardour/io_selector.cc b/gtk2_ardour/io_selector.cc index 7ff12612e6..0738758931 100644 --- a/gtk2_ardour/io_selector.cc +++ b/gtk2_ardour/io_selector.cc @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include @@ -98,6 +98,12 @@ IOSelectorWindow::IOSelectorWindow (Session& sess, boost::shared_ptr ior, bo set_title (title); set_position (WIN_POS_MOUSE); + ok_button.show(); + cancel_button.show(); + rescan_button.show(); + button_box.show(); + get_vbox()->show(); + signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast (this))); } @@ -183,7 +189,43 @@ IOSelector::IOSelector (Session& sess, boost::shared_ptr ior, bool input) port_button_box.set_border_width (5); port_button_box.pack_start (add_port_button, false, false); + + // The IO selector only works for single typed IOs + const ARDOUR::DataType t = io->default_type(); + + if (for_input) { + if (io->input_maximum().get(t) < 0 || io->input_maximum().get(t) > (size_t) io->n_inputs().get(t)) { + add_port_button.set_sensitive (true); + } else { + add_port_button.set_sensitive (false); + } + + } else { + if (io->output_maximum().get(t) < 0 || io->output_maximum().get(t) > (size_t) io->n_outputs().get(t)) { + add_port_button.set_sensitive (true); + } else { + add_port_button.set_sensitive (false); + } + + } + port_button_box.pack_start (remove_port_button, false, false); + + if (for_input) { + if (io->input_minimum().get(t) < 0 || io->input_minimum().get(t) < (size_t) io->n_inputs().get(t)) { + remove_port_button.set_sensitive (true); + } else { + remove_port_button.set_sensitive (false); + } + + } else { + if (io->output_minimum().get(t) < 0 || io->output_minimum().get(t) < (size_t) io->n_outputs().get(t)) { + remove_port_button.set_sensitive (true); + } else { + remove_port_button.set_sensitive (false); + } + } + port_button_box.pack_start (clear_connections_button, false, false); port_and_button_box.set_border_width (5); @@ -214,7 +256,25 @@ IOSelector::IOSelector (Session& sess, boost::shared_ptr ior, bool input) io->output_changed.connect (mem_fun(*this, &IOSelector::ports_changed)); } - io->name_changed.connect (mem_fun(*this, &IOSelector::name_changed)); + io->NameChanged.connect (mem_fun(*this, &IOSelector::name_changed)); + + main_box.show(); + port_and_selector_box.show(); + notebook.show(); + selector_frame.show(); + selector_box.show(); + selector_button_box.show(); + port_box.show(); + port_button_box.show(); + port_and_button_box.show(); + port_frame.show(); + add_port_button.show(); + remove_port_button.show(); + clear_connections_button.show(); + port_display_scroller.show(); + + show(); + } IOSelector::~IOSelector () @@ -224,9 +284,11 @@ IOSelector::~IOSelector () void IOSelector::set_button_sensitivity () { + DataType t = io->default_type(); + if (for_input) { - if (io->input_maximum() < 0 || io->input_maximum() > (int) io->n_inputs()) { + if (io->input_maximum().get(t) < 0 || io->input_maximum().get(t) > io->n_inputs().get(t)) { add_port_button.set_sensitive (true); } else { add_port_button.set_sensitive (false); @@ -234,7 +296,7 @@ IOSelector::set_button_sensitivity () } else { - if (io->output_maximum() < 0 || io->output_maximum() > (int) io->n_outputs()) { + if (io->output_maximum().get(t) < 0 || io->output_maximum().get(t) > io->n_outputs().get(t)) { add_port_button.set_sensitive (true); } else { add_port_button.set_sensitive (false); @@ -243,14 +305,14 @@ IOSelector::set_button_sensitivity () } if (for_input) { - if (io->n_inputs() && (io->input_minimum() < 0 || io->input_minimum() < (int) io->n_inputs())) { + if (io->n_inputs().get(t) && (io->input_minimum().get(t) < 0 || io->input_minimum().get(t) < io->n_inputs().get(t))) { remove_port_button.set_sensitive (true); } else { remove_port_button.set_sensitive (false); } } else { - if (io->n_outputs() && (io->output_minimum() < 0 || io->output_minimum() < (int) io->n_outputs())) { + if (io->n_outputs().get(t) && (io->output_minimum().get(t) < 0 || io->output_minimum().get(t) < io->n_outputs().get(t))) { remove_port_button.set_sensitive (true); } else { remove_port_button.set_sensitive (false); @@ -260,9 +322,9 @@ IOSelector::set_button_sensitivity () void -IOSelector::name_changed (void* src) +IOSelector::name_changed () { - ENSURE_GUI_THREAD(bind (mem_fun(*this, &IOSelector::name_changed), src)); + ENSURE_GUI_THREAD(mem_fun(*this, &IOSelector::name_changed)); display_ports (); } @@ -297,7 +359,7 @@ IOSelector::rescan () /* get relevant current JACK ports */ - ports = session.engine().get_ports ("", JACK_DEFAULT_AUDIO_TYPE, for_input ? JackPortIsOutput : JackPortIsInput); + ports = session.engine().get_ports ("", io->default_type().to_jack_type(), for_input ? JackPortIsOutput : JackPortIsInput); if (ports == 0) { return; @@ -380,10 +442,13 @@ IOSelector::display_ports () Port *port; uint32_t limit; + // The IO selector only works for single typed IOs + const ARDOUR::DataType t = io->default_type(); + if (for_input) { - limit = io->n_inputs(); + limit = io->n_inputs().get(t); } else { - limit = io->n_outputs(); + limit = io->n_outputs().get(t); } for (slist::iterator i = port_displays.begin(); i != port_displays.end(); ) { @@ -448,7 +513,7 @@ IOSelector::display_ports () if (for_input) { - if (io->input_maximum() == 1) { + if (io->input_maximum().get(io->default_type()) == 1) { selected_port = port; selected_port_tview = tview; } else { @@ -459,7 +524,7 @@ IOSelector::display_ports () } else { - if (io->output_maximum() == 1) { + if (io->output_maximum().get(t) == 1) { selected_port = port; selected_port_tview = tview; } else { @@ -511,7 +576,9 @@ IOSelector::port_selection_changed (GdkEventButton *ev, TreeView* treeview) if (for_input) { if ((status = io->connect_input (selected_port, other_port_name, this)) == 0) { Port *p = session.engine().get_port_by_name (other_port_name); - p->enable_metering(); + if (p) { + p->enable_metering(); + } } } else { status = io->connect_output (selected_port, other_port_name, this); @@ -538,6 +605,9 @@ IOSelector::add_port () { /* add a new port, then hide the button if we're up to the maximum allowed */ + // The IO selector only works for single typed IOs + const ARDOUR::DataType t = io->default_type(); + if (for_input) { try { @@ -569,15 +639,17 @@ IOSelector::remove_port () { uint32_t nports; + // The IO selector only works for single typed IOs + const ARDOUR::DataType t = io->default_type(); + // always remove last port if (for_input) { - if ((nports = io->n_inputs()) > 0) { + if ((nports = io->n_inputs().get(t)) > 0) { io->remove_input_port (io->input(nports-1), this); } - } else { - if ((nports = io->n_outputs()) > 0) { + if ((nports = io->n_outputs().get(t)) > 0) { io->remove_output_port (io->output(nports-1), this); } } @@ -616,7 +688,9 @@ IOSelector::connection_button_release (GdkEventButton *ev, TreeView *treeview) if (for_input) { Port *p = session.engine().get_port_by_name (connected_port_name); - p->disable_metering(); + if (p) { + p->disable_metering(); + } io->disconnect_input (port, connected_port_name, this); } else { io->disconnect_output (port, connected_port_name, this); @@ -704,19 +778,19 @@ IOSelector::redisplay () display_ports (); if (for_input) { - if (io->input_maximum() != 0) { + if (io->input_maximum().get(io->default_type()) != 0) { rescan (); } } else { - if (io->output_maximum() != 0) { + if (io->output_maximum().get(io->default_type()) != 0) { rescan(); } } } PortInsertUI::PortInsertUI (Session& sess, boost::shared_ptr pi) - : input_selector (sess, pi, true), - output_selector (sess, pi, false) + : input_selector (sess, pi->io(), true), + output_selector (sess, pi->io(), false) { hbox.pack_start (output_selector, true, true); hbox.pack_start (input_selector, true, true); @@ -778,14 +852,15 @@ PortInsertWindow::PortInsertWindow (Session& sess, boost::shared_ptr rescan_button.signal_clicked().connect (mem_fun(*this, &PortInsertWindow::rescan)); signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast (this))); - pi->GoingAway.connect (mem_fun(*this, &PortInsertWindow::plugin_going_away)); + + going_away_connection = pi->GoingAway.connect (mem_fun(*this, &PortInsertWindow::plugin_going_away)); } void PortInsertWindow::plugin_going_away () { ENSURE_GUI_THREAD(mem_fun(*this, &PortInsertWindow::plugin_going_away)); - + going_away_connection.disconnect (); delete_when_idle (this); }