Skip to content
Permalink
Browse files

Hide "Add MIDI Port" in the GUI if there is already one

  • Loading branch information...
x42 committed Jul 11, 2019
1 parent c6740b7 commit dc131da53b2603189dc0fb00109b77178c971fc4
Showing with 33 additions and 6 deletions.
  1. +19 −4 gtk2_ardour/mixer_strip.cc
  2. +13 −2 gtk2_ardour/port_matrix.cc
  3. +1 −0 gtk2_ardour/port_matrix.h
@@ -934,20 +934,27 @@ MixerStrip::output_press (GdkEventButton *ev)
citems.pop_back ();
}

if (!ARDOUR::Profile->get_mixbus()) {
citems.push_back (SeparatorElem());
citems.push_back (SeparatorElem());

if (!ARDOUR::Profile->get_mixbus()) {
bool need_separator = false;
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
if (!_route->output()->can_add_port (*i)) {
continue;
}
need_separator = true;
citems.push_back (
MenuElem (
string_compose (_("Add %1 port"), (*i).to_i18n_string()),
sigc::bind (sigc::mem_fun (*this, &MixerStrip::add_output_port), *i)
)
);
}
if (need_separator) {
citems.push_back (SeparatorElem());
}
}

citems.push_back (SeparatorElem());
citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_output_configuration)));

Gtkmm2ext::anchored_menu_popup(&output_menu, &output_button, "",
@@ -1040,16 +1047,24 @@ MixerStrip::input_press (GdkEventButton *ev)
}

citems.push_back (SeparatorElem());

bool need_separator = false;
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
if (!_route->input()->can_add_port (*i)) {
continue;
}
need_separator = true;
citems.push_back (
MenuElem (
string_compose (_("Add %1 port"), (*i).to_i18n_string()),
sigc::bind (sigc::mem_fun (*this, &MixerStrip::add_input_port), *i)
)
);
}
if (need_separator) {
citems.push_back (SeparatorElem());
}

citems.push_back (SeparatorElem());
citems.push_back (MenuElem (_("Routing Grid"), sigc::mem_fun (*(static_cast<RouteUI*>(this)), &RouteUI::edit_input_configuration)));

Gtkmm2ext::anchored_menu_popup(&input_menu, &input_button, "",
@@ -446,15 +446,15 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
if (can_add_channels (bc[dim].bundle)) {
/* Start off with options for the `natural' port type */
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
if (should_show (*i)) {
if (should_show (*i) && can_add_channel_proxy (w, *i)) {
snprintf (buf, sizeof (buf), _("Add %s %s"), (*i).to_i18n_string(), channel_noun().c_str());
sub.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::add_channel_proxy), w, *i)));
}
}

/* Now add other ones */
for (DataType::iterator i = DataType::begin(); i != DataType::end(); ++i) {
if (!should_show (*i)) {
if (!should_show (*i) && can_add_channel_proxy (w, *i)) {
snprintf (buf, sizeof (buf), _("Add %s %s"), (*i).to_i18n_string(), channel_noun().c_str());
sub.push_back (MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::add_channel_proxy), w, *i)));
}
@@ -790,6 +790,17 @@ PortMatrix::remove_all_channels (boost::weak_ptr<Bundle> w)
}
}

bool
PortMatrix::can_add_channel_proxy (boost::weak_ptr<Bundle> w, DataType t) const
{
boost::shared_ptr<Bundle> b = w.lock ();
if (!b) {
return false;
}
boost::shared_ptr<IO> io = io_from_bundle (b);
return io->can_add_port (t);
}

void
PortMatrix::add_channel_proxy (boost::weak_ptr<Bundle> w, DataType t)
{
@@ -182,6 +182,7 @@ class PortMatrix : public Gtk::Table, public ARDOUR::SessionHandlePtr
void routes_changed ();
void reconnect_to_routes ();
void select_arrangement ();
bool can_add_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, ARDOUR::DataType) const;
void add_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, ARDOUR::DataType);
void remove_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);
void rename_channel_proxy (boost::weak_ptr<ARDOUR::Bundle>, uint32_t);

0 comments on commit dc131da

Please sign in to comment.
You can’t perform that action at this time.