X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fport_matrix.cc;h=1e0db19cf6b016fcfd65647944c664226086d56a;hb=ab565167ff36eb473340e950d93d46c3dfaa9616;hp=febd6ab56584085c2ebe16787c7492489b969ed2;hpb=ab1afe97fe235513791ecda9d2d90596a58a776d;p=ardour.git diff --git a/gtk2_ardour/port_matrix.cc b/gtk2_ardour/port_matrix.cc index febd6ab565..1e0db19cf6 100644 --- a/gtk2_ardour/port_matrix.cc +++ b/gtk2_ardour/port_matrix.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2009 Paul Davis + Copyright (C) 2002-2009 Paul Davis This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -34,6 +34,7 @@ #include "port_matrix_body.h" #include "port_matrix_component.h" #include "i18n.h" +#include "gui_thread.h" using namespace std; using namespace sigc; @@ -61,9 +62,12 @@ PortMatrix::PortMatrix (Window* parent, Session& session, DataType type) for (int i = 0; i < 2; ++i) { _ports[i].set_type (type); - + /* watch for the content of _ports[] changing */ _ports[i].Changed.connect (mem_fun (*this, &PortMatrix::setup)); + + /* and for bundles in _ports[] changing */ + _ports[i].BundleChanged.connect (mem_fun (*this, &PortMatrix::bundle_changed)); } _hscroll.signal_value_changed().connect (mem_fun (*this, &PortMatrix::hscroll_changed)); @@ -77,13 +81,13 @@ PortMatrix::PortMatrix (Window* parent, Session& session, DataType type) /* and also ports */ _session.engine().PortRegisteredOrUnregistered.connect (mem_fun (*this, &PortMatrix::setup_all_ports)); - + reconnect_to_routes (); attach (*_body, 0, 1, 0, 1); attach (_vscroll, 1, 2, 0, 1, SHRINK); attach (_hscroll, 0, 1, 1, 2, FILL | EXPAND, SHRINK); - + show_all (); } @@ -139,7 +143,7 @@ PortMatrix::set_type (DataType t) _type = t; _ports[0].set_type (_type); _ports[1].set_type (_type); - + setup_all_ports (); } @@ -184,7 +188,7 @@ PortMatrix::disassociate_all () for (uint32_t j = 0; j < i->bundle->nchannels(); ++j) { for (PortGroup::BundleList::iterator k = b.begin(); k != b.end(); ++k) { for (uint32_t l = 0; l < k->bundle->nchannels(); ++l) { - + BundleChannel c[2] = { BundleChannel (i->bundle, j), BundleChannel (k->bundle, l) @@ -216,7 +220,7 @@ PortMatrix::select_arrangement () maintain notional `signal flow' vaguely from left to right. Subclasses should choose where to put ports based on signal flowing from _ports[0] to _ports[1] */ - + if (N[0] > N[1]) { _row_index = 0; @@ -253,12 +257,12 @@ PortMatrix::popup_menu ( ) { using namespace Menu_Helpers; - + delete _menu; _menu = new Menu; _menu->set_name ("ArdourContextMenu"); - + MenuList& items = _menu->items (); boost::shared_ptr pg[2]; @@ -285,8 +289,8 @@ PortMatrix::popup_menu ( snprintf (buf, sizeof (buf), _("Add %s"), channel_noun().c_str()); sub.push_back (MenuElem (buf, bind (mem_fun (*this, &PortMatrix::add_channel_proxy), w))); } - - + + if (can_rename_channels (bc[dim].bundle)) { snprintf (buf, sizeof (buf), _("Rename '%s'..."), bc[dim].bundle->channel_name (bc[dim].channel).c_str()); sub.push_back ( @@ -298,7 +302,7 @@ PortMatrix::popup_menu ( } sub.push_back (SeparatorElem ()); - + if (can_remove_channels (bc[dim].bundle)) { snprintf (buf, sizeof (buf), _("Remove '%s'"), bc[dim].bundle->channel_name (bc[dim].channel).c_str()); sub.push_back ( @@ -307,7 +311,7 @@ PortMatrix::popup_menu ( bind (mem_fun (*this, &PortMatrix::remove_channel_proxy), w, bc[dim].channel) ) ); - } + } if (_show_only_bundles) { snprintf (buf, sizeof (buf), _("%s all"), disassociation_verb().c_str()); @@ -318,7 +322,7 @@ PortMatrix::popup_menu ( bc[dim].bundle->channel_name (bc[dim].channel).c_str() ); } - + sub.push_back ( MenuElem (buf, bind (mem_fun (*this, &PortMatrix::disassociate_all_on_channel), w, bc[dim].channel, dim)) ); @@ -334,13 +338,13 @@ PortMatrix::popup_menu ( } need_separator = false; - + for (int dim = 0; dim < 2; ++dim) { if (pg[dim]) { boost::weak_ptr wp (pg[dim]); - + if (pg[dim]->visible()) { if (dim == 0) { if (pg[dim]->name.empty()) { @@ -388,7 +392,7 @@ PortMatrix::popup_menu ( _inhibit_toggle_show_only_bundles = true; i->set_active (!_show_only_bundles); _inhibit_toggle_show_only_bundles = false; - + _menu->popup (1, t); } @@ -454,6 +458,8 @@ PortMatrix::setup_global_ports () void PortMatrix::setup_all_ports () { + ENSURE_GUI_THREAD (mem_fun (*this, &PortMatrix::setup_all_ports)); + setup_ports (0); setup_ports (1); } @@ -464,7 +470,7 @@ PortMatrix::toggle_show_only_bundles () if (_inhibit_toggle_show_only_bundles) { return; } - + _show_only_bundles = !_show_only_bundles; _body->setup (); setup_scrollbars (); @@ -509,7 +515,7 @@ PortMatrix::on_scroll_event (GdkEventScroll* ev) { double const h = _hscroll.get_value (); double const v = _vscroll.get_value (); - + switch (ev->direction) { case GDK_SCROLL_UP: _vscroll.set_value (v - PortMatrixComponent::grid_spacing ()); @@ -584,3 +590,13 @@ PortMatrix::add_channel_proxy (boost::weak_ptr w) add_channel (b); } + +void +PortMatrix::bundle_changed (ARDOUR::Bundle::Change c) +{ + if (c != Bundle::NameChanged) { + setup_all_ports (); + } + + setup (); +}