diff --git a/gtk2_ardour/bundle_manager.cc b/gtk2_ardour/bundle_manager.cc index d8cfde7123..e6260ae4d0 100644 --- a/gtk2_ardour/bundle_manager.cc +++ b/gtk2_ardour/bundle_manager.cc @@ -112,6 +112,17 @@ BundleEditorMatrix::can_add_channels (boost::shared_ptr b) const return PortMatrix::can_add_channels (b); } +bool +BundleEditorMatrix::can_add_port (boost::shared_ptr b, DataType t) const +{ +#if 1 + return true; // anything goes +#else + /* Do not allow to mix datatypes */ + return _bundle->nchannels().get (t) > 0; +#endif +} + void BundleEditorMatrix::add_channel (boost::shared_ptr b, DataType t) { @@ -136,11 +147,10 @@ BundleEditorMatrix::add_channel (boost::shared_ptr b, DataType t) bool BundleEditorMatrix::can_remove_channels (boost::shared_ptr b) const { - if (b == _bundle) { - return true; + if (b != _bundle) { + return false; } - - return PortMatrix::can_remove_channels (b); + return _bundle->n_total () > 1; } void diff --git a/gtk2_ardour/bundle_manager.h b/gtk2_ardour/bundle_manager.h index fc365a0992..38294cd8c0 100644 --- a/gtk2_ardour/bundle_manager.h +++ b/gtk2_ardour/bundle_manager.h @@ -44,6 +44,7 @@ public: PortMatrixNode::State get_state (ARDOUR::BundleChannel c[2]) const; bool can_add_channels (boost::shared_ptr) const; + bool can_add_port (boost::shared_ptr, ARDOUR::DataType t) const; void add_channel (boost::shared_ptr, ARDOUR::DataType); bool can_remove_channels (boost::shared_ptr) const; diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index 353c510b55..e064d0aabd 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -460,7 +460,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) && can_add_channel_proxy (w, *i)) { + if (should_show (*i) && can_add_port_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))); } @@ -468,7 +468,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) && can_add_channel_proxy (w, *i)) { + if (!should_show (*i) && can_add_port_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))); } @@ -735,6 +735,13 @@ PortMatrix::can_add_channels (boost::shared_ptr b) const return io_from_bundle (b) != 0; } +bool +PortMatrix::can_add_port (boost::shared_ptr b, DataType t) const +{ + boost::shared_ptr io = io_from_bundle (b); + return io && io->can_add_port (t); +} + void PortMatrix::add_channel (boost::shared_ptr b, DataType t) { @@ -805,14 +812,13 @@ PortMatrix::remove_all_channels (boost::weak_ptr w) } bool -PortMatrix::can_add_channel_proxy (boost::weak_ptr w, DataType t) const +PortMatrix::can_add_port_proxy (boost::weak_ptr w, DataType t) const { boost::shared_ptr b = w.lock (); if (!b) { return false; } - boost::shared_ptr io = io_from_bundle (b); - return io && io->can_add_port (t); + return can_add_port (b, t); } void diff --git a/gtk2_ardour/port_matrix.h b/gtk2_ardour/port_matrix.h index 8667c8c8e6..24f1a6961f 100644 --- a/gtk2_ardour/port_matrix.h +++ b/gtk2_ardour/port_matrix.h @@ -153,6 +153,7 @@ public: virtual bool can_rename_channels (boost::shared_ptr) const { return false; } + virtual bool can_add_port (boost::shared_ptr, ARDOUR::DataType t) const; virtual void rename_channel (ARDOUR::BundleChannel) {} virtual std::string disassociation_verb () const = 0; virtual std::string channel_noun () const; @@ -183,7 +184,7 @@ private: void routes_changed (); void reconnect_to_routes (); void select_arrangement (); - bool can_add_channel_proxy (boost::weak_ptr, ARDOUR::DataType) const; + bool can_add_port_proxy (boost::weak_ptr, ARDOUR::DataType) const; void add_channel_proxy (boost::weak_ptr, ARDOUR::DataType); void remove_channel_proxy (boost::weak_ptr, uint32_t); void rename_channel_proxy (boost::weak_ptr, uint32_t);