+
+ if (can_rename_channels (bc[dim].bundle) && bc[dim].channel != -1) {
+ snprintf (
+ buf, sizeof (buf), _("Rename '%s'..."),
+ escape_underscores (bc[dim].bundle->channel_name (bc[dim].channel)).c_str()
+ );
+ sub.push_back (
+ MenuElem (
+ buf,
+ sigc::bind (sigc::mem_fun (*this, &PortMatrix::rename_channel_proxy), w, bc[dim].channel)
+ )
+ );
+ }
+
+ if (can_remove_channels (bc[dim].bundle) && bc[dim].bundle->nchannels() != ARDOUR::ChanCount::ZERO) {
+ if (bc[dim].channel != -1) {
+ add_remove_option (sub, w, bc[dim].channel);
+ } else {
+ sub.push_back (
+ MenuElem (_("Remove all"), sigc::bind (sigc::mem_fun (*this, &PortMatrix::remove_all_channels), w))
+ );
+
+ if (bc[dim].bundle->nchannels().n_total() > 1) {
+ for (uint32_t i = 0; i < bc[dim].bundle->nchannels().n_total(); ++i) {
+ if (should_show (bc[dim].bundle->channel_type(i))) {
+ add_remove_option (sub, w, i);
+ }
+ }
+ }
+ }
+ }
+
+ uint32_t c = count_of_our_type (bc[dim].bundle->nchannels ());
+ if ((_show_only_bundles && c > 0) || c == 1) {
+
+ /* we're looking just at bundles, or our bundle has only one channel, so just offer
+ to disassociate all on the bundle.
+ */
+
+ snprintf (buf, sizeof (buf), _("%s all"), disassociation_verb().c_str());
+ sub.push_back (
+ MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_bundle), w, dim))
+ );
+
+ } else if (c != 0) {
+
+ if (bc[dim].channel != -1) {
+ /* specific channel under the menu, so just offer to disassociate that */
+ add_disassociate_option (sub, w, dim, bc[dim].channel);
+ } else {
+ /* no specific channel; offer to disassociate all, or any one in particular */
+ snprintf (buf, sizeof (buf), _("%s all"), disassociation_verb().c_str());
+ sub.push_back (
+ MenuElem (buf, sigc::bind (sigc::mem_fun (*this, &PortMatrix::disassociate_all_on_bundle), w, dim))
+ );
+
+ for (uint32_t i = 0; i < bc[dim].bundle->nchannels().n_total(); ++i) {
+ if (should_show (bc[dim].bundle->channel_type(i))) {
+ add_disassociate_option (sub, w, dim, i);
+ }
+ }
+ }
+ }
+
+ items.push_back (MenuElem (escape_underscores (bc[dim].bundle->name()).c_str(), *m));
+ need_separator = true;