+ boost::shared_ptr<Pannable> p = _route->pannable ();
+
+ p->automation_state_changed.connect (panstate_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_state_changed, &panners), gui_context());
+ p->automation_style_changed.connect (panstyle_connection, invalidator (*this), boost::bind (&PannerUI::pan_automation_style_changed, &panners), gui_context());
+
+ panners.panshell_changed ();
+}
+
+
+/*
+ * Output port labelling
+ * =====================
+ *
+ * Case 1: Each output has one connection, all connections are to system:playback_%i
+ * out 1 -> system:playback_1
+ * out 2 -> system:playback_2
+ * out 3 -> system:playback_3
+ * Display as: 1/2/3
+ *
+ * Case 2: Each output has one connection, all connections are to ardour:track_x/in 1
+ * out 1 -> ardour:track_x/in 1
+ * out 2 -> ardour:track_x/in 2
+ * Display as: track_x
+ *
+ * Case 3: Each output has one connection, all connections are to Jack client "program x"
+ * out 1 -> program x:foo
+ * out 2 -> program x:foo
+ * Display as: program x
+ *
+ * Case 4: No connections (Disconnected)
+ * Display as: -
+ *
+ * Default case (unusual routing):
+ * Display as: *number of connections*
+ *
+ * Tooltips
+ * ========
+ * .-----------------------------------------------.
+ * | Mixdown |
+ * | out 1 -> ardour:master/in 1, jamin:input/in 1 |
+ * | out 2 -> ardour:master/in 2, jamin:input/in 2 |
+ * '-----------------------------------------------'
+ * .-----------------------------------------------.
+ * | Guitar SM58 |
+ * | Disconnected |
+ * '-----------------------------------------------'
+ */
+
+void
+MixerStrip::update_io_button (boost::shared_ptr<ARDOUR::Route> route, Width width, bool for_input)
+{
+ uint32_t io_count;
+ uint32_t io_index;
+ boost::shared_ptr<Port> port;
+ vector<string> port_connections;
+
+ uint32_t total_connection_count = 0;
+ uint32_t io_connection_count = 0;
+ uint32_t ardour_connection_count = 0;
+ uint32_t system_connection_count = 0;
+ uint32_t other_connection_count = 0;
+
+ ostringstream label;
+ string label_string;
+
+ bool have_label = false;
+ bool each_io_has_one_connection = true;
+
+ string connection_name;
+ string ardour_track_name;
+ string other_connection_type;
+ string system_ports;
+ string system_port;
+
+ ostringstream tooltip;
+ char * tooltip_cstr;
+
+ if (for_input) {
+ io_count = route->n_inputs().n_total();
+ tooltip << string_compose (_("<b>INPUT</b> to %1"), Glib::Markup::escape_text(route->name()));
+ } else {
+ io_count = route->n_outputs().n_total();
+ tooltip << string_compose (_("<b>OUTPUT</b> from %1"), Glib::Markup::escape_text(route->name()));
+ }
+
+
+ for (io_index = 0; io_index < io_count; ++io_index) {
+ if (for_input) {
+ port = route->input()->nth (io_index);
+ } else {
+ port = route->output()->nth (io_index);
+ }
+
+ port_connections.clear ();
+ port->get_connections(port_connections);
+ io_connection_count = 0;
+
+ if (!port_connections.empty()) {
+ for (vector<string>::iterator i = port_connections.begin(); i != port_connections.end(); ++i) {
+ string& connection_name (*i);
+
+ if (io_connection_count == 0) {
+ tooltip << endl << Glib::Markup::escape_text(port->name().substr(port->name().find("/") + 1)) << " -> " << Glib::Markup::escape_text(connection_name);
+ } else {
+ tooltip << ", " << Glib::Markup::escape_text(connection_name);
+ }
+
+ if (connection_name.find("ardour:") == 0) {
+ if (ardour_track_name.empty()) {
+ // "ardour:Master/in 1" -> "ardour:Master/"
+ string::size_type slash = connection_name.find("/");
+ if (slash != string::npos) {
+ ardour_track_name = connection_name.substr(0, slash + 1);
+ }
+ }
+
+ if (connection_name.find(ardour_track_name) == 0) {
+ ++ardour_connection_count;
+ }
+ } else if (connection_name.find("system:") == 0) {
+ if (for_input) {
+ // "system:capture_123" -> "123"
+ system_port = connection_name.substr(15);
+ } else {
+ // "system:playback_123" -> "123"
+ system_port = connection_name.substr(16);
+ }
+
+ if (system_ports.empty()) {
+ system_ports += system_port;
+ } else {
+ system_ports += "/" + system_port;
+ }
+
+ ++system_connection_count;
+ } else {
+ if (other_connection_type.empty()) {
+ // "jamin:in 1" -> "jamin:"
+ other_connection_type = connection_name.substr(0, connection_name.find(":") + 1);
+ }
+
+ if (connection_name.find(other_connection_type) == 0) {
+ ++other_connection_count;
+ }
+ }
+
+ ++total_connection_count;
+ ++io_connection_count;
+ }
+ }
+
+ if (io_connection_count != 1) {
+ each_io_has_one_connection = false;
+ }
+ }
+
+ if (total_connection_count == 0) {
+ tooltip << endl << _("Disconnected");
+ }
+
+ tooltip_cstr = new char[tooltip.str().size() + 1];
+ strcpy(tooltip_cstr, tooltip.str().c_str());
+
+ if (for_input) {
+ ARDOUR_UI::instance()->set_tip (&input_button, tooltip_cstr, "");
+ } else {
+ ARDOUR_UI::instance()->set_tip (&output_button, tooltip_cstr, "");
+ }
+
+ if (each_io_has_one_connection) {
+ if (total_connection_count == ardour_connection_count) {
+ // all connections are to the same track in ardour
+ // "ardour:Master/" -> "Master"
+ string::size_type slash = ardour_track_name.find("/");
+ if (slash != string::npos) {
+ label << ardour_track_name.substr(7, slash - 7);
+ have_label = true;
+ }
+ }
+ else if (total_connection_count == system_connection_count) {
+ // all connections are to system ports
+ label << system_ports;
+ have_label = true;
+ }
+ else if (total_connection_count == other_connection_count) {
+ // all connections are to the same external program eg jamin
+ // "jamin:" -> "jamin"
+ label << other_connection_type.substr(0, other_connection_type.size() - 1);
+ have_label = true;
+ }
+ }