summaryrefslogtreecommitdiff
path: root/gtk2_ardour/port_matrix.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2019-07-11 22:58:27 +0200
committerRobin Gareus <robin@gareus.org>2019-07-11 22:58:27 +0200
commitdc131da53b2603189dc0fb00109b77178c971fc4 (patch)
tree90279a03a80824bbf2d8809322e5ef5befd6620b /gtk2_ardour/port_matrix.cc
parentc6740b7cb06591f68851a3821a6cbc2b095e5bd0 (diff)
Hide "Add MIDI Port" in the GUI if there is already one
Diffstat (limited to 'gtk2_ardour/port_matrix.cc')
-rw-r--r--gtk2_ardour/port_matrix.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc
index 23e9acaf62..b5e7cb008d 100644
--- a/gtk2_ardour/port_matrix.cc
+++ b/gtk2_ardour/port_matrix.cc
@@ -446,7 +446,7 @@ 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)));
}
@@ -454,7 +454,7 @@ PortMatrix::popup_menu (BundleChannel column, BundleChannel row, uint32_t t)
/* 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)
{