2 Copyright (C) 2009 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include <gtkmm/image.h>
21 #include <gtkmm/stock.h>
22 #include "global_port_matrix.h"
24 #include "ardour/bundle.h"
25 #include "ardour/session.h"
26 #include "ardour/audioengine.h"
27 #include "ardour/port.h"
29 GlobalPortMatrix::GlobalPortMatrix (ARDOUR::Session& s, ARDOUR::DataType t)
36 GlobalPortMatrix::setup_ports (int dim)
38 _ports[dim].suspend_signals ();
39 _ports[dim].gather (_session, dim == IN);
40 _ports[dim].resume_signals ();
44 GlobalPortMatrix::set_state (ARDOUR::BundleChannel c[2], bool s)
46 ARDOUR::Bundle::PortList const & in_ports = c[IN].bundle->channel_ports (c[IN].channel);
47 ARDOUR::Bundle::PortList const & out_ports = c[OUT].bundle->channel_ports (c[OUT].channel);
49 for (ARDOUR::Bundle::PortList::const_iterator i = in_ports.begin(); i != in_ports.end(); ++i) {
50 for (ARDOUR::Bundle::PortList::const_iterator j = out_ports.begin(); j != out_ports.end(); ++j) {
52 ARDOUR::Port* p = _session.engine().get_port_by_name (*i);
53 ARDOUR::Port* q = _session.engine().get_port_by_name (*j);
69 /* we don't handle connections between two non-Ardour ports */
75 GlobalPortMatrix::get_state (ARDOUR::BundleChannel c[2]) const
77 ARDOUR::Bundle::PortList const & in_ports = c[IN].bundle->channel_ports (c[IN].channel);
78 ARDOUR::Bundle::PortList const & out_ports = c[OUT].bundle->channel_ports (c[OUT].channel);
79 if (in_ports.empty() || out_ports.empty()) {
80 /* we're looking at a bundle with no parts associated with this channel,
81 so nothing to connect */
85 for (ARDOUR::Bundle::PortList::const_iterator i = in_ports.begin(); i != in_ports.end(); ++i) {
86 for (ARDOUR::Bundle::PortList::const_iterator j = out_ports.begin(); j != out_ports.end(); ++j) {
88 ARDOUR::Port* p = _session.engine().get_port_by_name (*i);
89 ARDOUR::Port* q = _session.engine().get_port_by_name (*j);
91 /* we don't know the state of connections between two non-Ardour ports */
96 if (p && p->connected_to (*j) == false) {
97 return NOT_ASSOCIATED;
98 } else if (q && q->connected_to (*i) == false) {
99 return NOT_ASSOCIATED;
109 GlobalPortMatrixWindow::GlobalPortMatrixWindow (ARDOUR::Session& s, ARDOUR::DataType t)
110 : _port_matrix (s, t)
113 case ARDOUR::DataType::AUDIO:
114 set_title (_("Audio Connections Manager"));
116 case ARDOUR::DataType::MIDI:
117 set_title (_("MIDI Connections Manager"));
121 Gtk::HBox* buttons_hbox = Gtk::manage (new Gtk::HBox);
123 _rescan_button.set_label (_("Rescan"));
124 _rescan_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::REFRESH, Gtk::ICON_SIZE_BUTTON)));
125 _rescan_button.signal_clicked().connect (sigc::mem_fun (_port_matrix, &GlobalPortMatrix::setup_all_ports));
126 buttons_hbox->pack_start (_rescan_button, Gtk::PACK_SHRINK);
128 Gtk::VBox* vbox = Gtk::manage (new Gtk::VBox);
129 vbox->pack_start (_port_matrix);
130 vbox->pack_start (*buttons_hbox, Gtk::PACK_SHRINK);