2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2002 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
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
|
|
along with this program; if not, write to the Free Software
|
|
|
|
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
|
|
|
*/
|
2005-10-31 19:56:09 -05:00
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
|
|
|
#include <gtkmm2ext/utils.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <sigc++/bind.h>
|
|
|
|
|
|
|
|
#include "connection_editor.h"
|
|
|
|
|
|
|
|
#include <ardour/session.h>
|
|
|
|
#include <ardour/session_connection.h>
|
|
|
|
#include <ardour/audioengine.h>
|
|
|
|
#include <ardour/connection.h>
|
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "prompter.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
#include <inttypes.h>
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace ARDOUR;
|
2006-06-21 19:01:03 -04:00
|
|
|
using namespace PBD;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace Gtk;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
ConnectionEditor::ConnectionEditor ()
|
2005-11-27 16:17:41 -05:00
|
|
|
: ArdourDialog (_("ardour: connections")),
|
2005-09-25 14:42:24 -04:00
|
|
|
input_frame (_("Input Connections")),
|
|
|
|
output_frame (_("Output Connections")),
|
|
|
|
new_input_connection_button (_("New Input")),
|
|
|
|
new_output_connection_button (_("New Output")),
|
|
|
|
delete_connection_button (_("Delete")),
|
|
|
|
clear_button (_("Clear")),
|
|
|
|
add_port_button (_("Add Port")),
|
|
|
|
ok_button (_("Close")),
|
|
|
|
cancel_button (_("Cancel")),
|
|
|
|
rescan_button (_("Rescan"))
|
|
|
|
|
|
|
|
{
|
2005-09-25 16:33:00 -04:00
|
|
|
add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
session = 0;
|
|
|
|
selected_port = -1;
|
|
|
|
current_connection = 0;
|
|
|
|
push_at_front = false;
|
|
|
|
|
|
|
|
set_name ("ConnectionEditorWindow");
|
|
|
|
|
|
|
|
ok_button.set_name ("ConnectionEditorButton");
|
|
|
|
cancel_button.set_name ("ConnectionEditorButton");
|
|
|
|
rescan_button.set_name ("ConnectionEditorButton");
|
|
|
|
new_input_connection_button.set_name ("ConnectionEditorButton");
|
|
|
|
new_output_connection_button.set_name ("ConnectionEditorButton");
|
|
|
|
clear_button.set_name ("ConnectionEditorButton");
|
|
|
|
|
|
|
|
button_frame.set_name ("ConnectionEditorFrame");
|
|
|
|
input_frame.set_name ("ConnectionEditorFrame");
|
|
|
|
output_frame.set_name ("ConnectionEditorFrame");
|
|
|
|
|
|
|
|
button_box.set_spacing (15);
|
|
|
|
button_box.set_border_width (5);
|
2005-09-25 16:33:00 -04:00
|
|
|
Gtkmm2ext::set_size_request_to_display_given_text (ok_button, _("OK"), 40, 15);
|
2005-09-25 14:42:24 -04:00
|
|
|
button_box.pack_end (ok_button, false, false);
|
|
|
|
// button_box.pack_end (cancel_button, false, false);
|
|
|
|
cancel_button.hide();
|
|
|
|
button_frame.add (button_box);
|
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
ok_button.signal_clicked().connect (mem_fun(*this, &ConnectionEditor::accept));
|
|
|
|
cancel_button.signal_clicked().connect (mem_fun(*this, &ConnectionEditor::cancel));
|
|
|
|
cancel_button.signal_clicked().connect (mem_fun(*this, &ConnectionEditor::rescan));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
notebook.set_name ("ConnectionEditorNotebook");
|
2005-09-25 16:33:00 -04:00
|
|
|
notebook.set_size_request (-1, 125);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
clear_button.set_name ("ConnectionEditorButton");
|
|
|
|
add_port_button.set_name ("ConnectionEditorButton");
|
2005-09-25 16:33:00 -04:00
|
|
|
Gtkmm2ext::set_size_request_to_display_given_text (add_port_button, _("Add Port"), 35, 15);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
selector_frame.set_name ("ConnectionEditorFrame");
|
|
|
|
port_frame.set_name ("ConnectionEditorFrame");
|
|
|
|
|
|
|
|
selector_frame.set_label (_("Available Ports"));
|
|
|
|
|
|
|
|
selector_button_box.set_spacing (5);
|
|
|
|
selector_button_box.set_border_width (5);
|
2005-09-25 16:33:00 -04:00
|
|
|
Gtkmm2ext::set_size_request_to_display_given_text (rescan_button, _("Rescan"), 35, 15);
|
2005-09-25 14:42:24 -04:00
|
|
|
selector_button_box.pack_start (rescan_button, false, false);
|
|
|
|
|
|
|
|
selector_box.set_spacing (5);
|
|
|
|
selector_box.set_border_width (5);
|
|
|
|
selector_box.pack_start (notebook);
|
|
|
|
selector_box.pack_start (selector_button_box);
|
|
|
|
|
|
|
|
selector_frame.add (selector_box);
|
|
|
|
|
|
|
|
port_box.set_spacing (5);
|
|
|
|
port_box.set_border_width (3);
|
|
|
|
|
|
|
|
port_button_box.set_spacing (5);
|
|
|
|
port_button_box.set_border_width (2);
|
|
|
|
|
|
|
|
port_button_box.pack_start (add_port_button, false, false);
|
|
|
|
port_and_button_box.set_border_width (5);
|
|
|
|
port_and_button_box.pack_start (port_button_box, false, false);
|
|
|
|
port_and_button_box.pack_start (port_box);
|
|
|
|
|
|
|
|
port_frame.add (port_and_button_box);
|
|
|
|
|
|
|
|
port_and_selector_box.set_spacing (5);
|
|
|
|
port_and_selector_box.pack_start (port_frame);
|
|
|
|
port_and_selector_box.pack_start (selector_frame);
|
|
|
|
|
|
|
|
right_vbox.set_spacing (5);
|
|
|
|
right_vbox.set_border_width (5);
|
|
|
|
right_vbox.pack_start (port_and_selector_box);
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
input_connection_model = ListStore::create (connection_columns);
|
|
|
|
output_connection_model = ListStore::create (connection_columns);
|
|
|
|
|
|
|
|
input_connection_display.set_model (input_connection_model);
|
|
|
|
output_connection_display.set_model (output_connection_model);
|
|
|
|
|
|
|
|
input_connection_display.append_column (_("Connections"), connection_columns.name);
|
|
|
|
output_connection_display.append_column (_("Connections"), connection_columns.name);
|
|
|
|
|
2005-10-22 13:33:14 -04:00
|
|
|
input_connection_display.get_selection()->set_mode(Gtk::SELECTION_SINGLE);
|
2005-09-25 16:33:00 -04:00
|
|
|
input_connection_display.set_size_request (80, -1);
|
2005-09-25 14:42:24 -04:00
|
|
|
input_connection_display.set_name ("ConnectionEditorConnectionList");
|
|
|
|
|
2005-10-22 13:33:14 -04:00
|
|
|
output_connection_display.get_selection()->set_mode(Gtk::SELECTION_SINGLE);
|
2005-09-25 16:33:00 -04:00
|
|
|
output_connection_display.set_size_request (80, -1);
|
2005-09-25 14:42:24 -04:00
|
|
|
output_connection_display.set_name ("ConnectionEditorConnectionList");
|
2005-10-31 19:56:09 -05:00
|
|
|
|
|
|
|
input_connection_display.get_selection()->signal_changed().connect (bind (mem_fun(*this, &ConnectionEditor::selection_changed), &input_connection_display));
|
|
|
|
output_connection_display.get_selection()->signal_changed().connect (bind (mem_fun(*this, &ConnectionEditor::selection_changed), &output_connection_display));
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
input_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
|
|
|
output_scroller.set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
input_scroller.add (input_connection_display);
|
|
|
|
output_scroller.add (output_connection_display);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
input_box.set_border_width (5);
|
|
|
|
input_box.set_spacing (5);
|
|
|
|
input_box.pack_start (input_scroller);
|
|
|
|
input_box.pack_start (new_input_connection_button, false, false);
|
|
|
|
input_frame.add (input_box);
|
|
|
|
|
|
|
|
output_box.set_border_width (5);
|
|
|
|
output_box.set_spacing (5);
|
|
|
|
output_box.pack_start (output_scroller);
|
|
|
|
output_box.pack_start (new_output_connection_button, false, false);
|
|
|
|
output_frame.add (output_box);
|
|
|
|
|
|
|
|
connection_box.set_spacing (5);
|
|
|
|
connection_box.pack_start (input_frame);
|
|
|
|
connection_box.pack_start (output_frame);
|
|
|
|
|
|
|
|
left_vbox.set_spacing (5);
|
|
|
|
left_vbox.pack_start (connection_box);
|
|
|
|
|
|
|
|
main_hbox.set_border_width (10);
|
|
|
|
main_hbox.set_spacing (5);
|
|
|
|
main_hbox.pack_start (left_vbox);
|
|
|
|
main_hbox.pack_start (right_vbox);
|
|
|
|
|
|
|
|
main_vbox.set_border_width (10);
|
|
|
|
main_vbox.set_spacing (5);
|
|
|
|
main_vbox.pack_start (main_hbox);
|
|
|
|
main_vbox.pack_start (button_frame, false, false);
|
|
|
|
|
2005-11-27 16:17:41 -05:00
|
|
|
get_vbox()->pack_start (main_vbox);
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
clear_button.signal_clicked().connect (mem_fun(*this, &ConnectionEditor::clear));
|
|
|
|
add_port_button.signal_clicked().connect (mem_fun(*this, &ConnectionEditor::add_port));
|
|
|
|
new_input_connection_button.signal_clicked().connect (bind (mem_fun(*this, &ConnectionEditor::new_connection), true));
|
|
|
|
new_output_connection_button.signal_clicked().connect (bind (mem_fun(*this, &ConnectionEditor::new_connection), false));
|
|
|
|
delete_connection_button.signal_clicked().connect (mem_fun(*this, &ConnectionEditor::delete_connection));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ConnectionEditor::~ConnectionEditor()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::set_session (Session *s)
|
|
|
|
{
|
|
|
|
if (s != session) {
|
|
|
|
|
|
|
|
ArdourDialog::set_session (s);
|
|
|
|
|
|
|
|
if (session) {
|
2005-09-25 17:19:23 -04:00
|
|
|
session->ConnectionAdded.connect (mem_fun(*this, &ConnectionEditor::proxy_add_connection_and_select));
|
|
|
|
session->ConnectionRemoved.connect (mem_fun(*this, &ConnectionEditor::proxy_remove_connection));
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::rescan ()
|
|
|
|
{
|
|
|
|
refill_connection_display ();
|
|
|
|
display_ports ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::cancel ()
|
|
|
|
{
|
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::accept ()
|
|
|
|
{
|
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::clear ()
|
|
|
|
{
|
|
|
|
if (current_connection) {
|
|
|
|
current_connection->clear ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
void
|
|
|
|
ConnectionEditor::on_map ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
refill_connection_display ();
|
2005-10-31 19:56:09 -05:00
|
|
|
Window::on_map ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::add_connection (ARDOUR::Connection *connection)
|
|
|
|
{
|
2005-10-12 12:28:26 -04:00
|
|
|
TreeModel::Row row;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (dynamic_cast<InputConnection *> (connection)) {
|
2005-10-12 12:28:26 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (push_at_front) {
|
2005-10-31 19:56:09 -05:00
|
|
|
row = *(input_connection_model->prepend());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2005-10-31 19:56:09 -05:00
|
|
|
row = *(input_connection_model->append());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-10-12 12:28:26 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (push_at_front) {
|
2005-10-31 19:56:09 -05:00
|
|
|
row = *(output_connection_model->prepend());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2005-10-31 19:56:09 -05:00
|
|
|
row = *(output_connection_model->append());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2005-10-31 19:56:09 -05:00
|
|
|
|
|
|
|
row[connection_columns.connection] = connection;
|
|
|
|
row[connection_columns.name] = connection->name();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::remove_connection (ARDOUR::Connection *connection)
|
|
|
|
{
|
2005-10-12 12:28:26 -04:00
|
|
|
TreeModel::iterator i;
|
2005-10-31 19:56:09 -05:00
|
|
|
Glib::RefPtr<TreeModel> model = input_connection_model;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if (dynamic_cast<InputConnection *> (connection) == 0) {
|
|
|
|
model = output_connection_model;
|
|
|
|
}
|
|
|
|
|
|
|
|
TreeModel::Children rows = model->children();
|
|
|
|
|
|
|
|
for (i = rows.begin(); i != rows.end(); ++i) {
|
|
|
|
if ((*i)[connection_columns.connection] == connection) {
|
|
|
|
// model->erase (i);
|
2005-10-12 12:28:26 -04:00
|
|
|
break;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::proxy_add_connection_and_select (ARDOUR::Connection *connection)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &ConnectionEditor::add_connection_and_select), connection));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::proxy_remove_connection (ARDOUR::Connection *connection)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
Gtkmm2ext::UI::instance()->call_slot (bind (mem_fun(*this, &ConnectionEditor::remove_connection), connection));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::add_connection_and_select (ARDOUR::Connection *connection)
|
|
|
|
{
|
|
|
|
add_connection (connection);
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
// GTK2FIX
|
|
|
|
// if (dynamic_cast<InputConnection *> (connection)) {
|
|
|
|
// input_connection_display.rows().front().select ();
|
|
|
|
// } else {
|
|
|
|
// output_connection_display.rows().front().select ();
|
|
|
|
//}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::refill_connection_display ()
|
|
|
|
{
|
2005-10-31 19:56:09 -05:00
|
|
|
input_connection_display.set_model (Glib::RefPtr<TreeModel>(0));
|
|
|
|
output_connection_display.set_model (Glib::RefPtr<TreeModel>(0));
|
2005-10-12 12:28:26 -04:00
|
|
|
|
2005-11-28 17:36:26 -05:00
|
|
|
input_connection_model->clear();
|
|
|
|
output_connection_model->clear();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
current_connection = 0;
|
|
|
|
|
|
|
|
if (session) {
|
|
|
|
session->foreach_connection (this, &ConnectionEditor::add_connection);
|
|
|
|
}
|
2005-10-12 12:28:26 -04:00
|
|
|
|
|
|
|
input_connection_display.set_model (input_connection_model);
|
|
|
|
output_connection_display.set_model (output_connection_model);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-10-31 19:56:09 -05:00
|
|
|
ConnectionEditor::selection_changed (TreeView* view)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
ARDOUR::Connection *old_current = current_connection;
|
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
TreeIter iter;
|
|
|
|
TreeModel::Path path;
|
|
|
|
Glib::RefPtr<TreeView::Selection> selection = view->get_selection();
|
2005-10-31 19:56:09 -05:00
|
|
|
Glib::RefPtr<TreeModel> model = view->get_model();
|
|
|
|
bool input = (view == &input_connection_display);
|
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
iter = model->get_iter (path);
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
current_connection = (*iter)[connection_columns.connection];
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (old_current != current_connection) {
|
|
|
|
config_connection.disconnect ();
|
|
|
|
connect_connection.disconnect ();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (current_connection) {
|
|
|
|
config_connection = current_connection->ConfigurationChanged.connect
|
2005-09-25 17:19:23 -04:00
|
|
|
(bind (mem_fun(*this, &ConnectionEditor::configuration_changed), input));
|
2005-09-25 14:42:24 -04:00
|
|
|
connect_connection = current_connection->ConnectionsChanged.connect
|
2005-09-25 17:19:23 -04:00
|
|
|
(bind (mem_fun(*this, &ConnectionEditor::connections_changed), input));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
display_connection_state (input);
|
|
|
|
display_ports ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::configuration_changed (bool for_input)
|
|
|
|
{
|
|
|
|
display_connection_state (for_input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::connections_changed (int which_port, bool for_input)
|
|
|
|
{
|
|
|
|
display_connection_state (for_input);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::display_ports ()
|
|
|
|
{
|
|
|
|
if (session == 0 || current_connection == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
using namespace Notebook_Helpers;
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
typedef std::map<std::string,std::vector<std::pair<std::string,std::string> > > PortMap;
|
2005-09-25 14:42:24 -04:00
|
|
|
PortMap portmap;
|
|
|
|
const char **ports;
|
|
|
|
PageList& pages = notebook.pages();
|
|
|
|
gint current_page;
|
|
|
|
vector<string> rowdata;
|
|
|
|
bool for_input;
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
current_page = notebook.get_current_page ();
|
2005-09-25 14:42:24 -04:00
|
|
|
pages.clear ();
|
|
|
|
|
|
|
|
/* get relevant current JACK ports */
|
|
|
|
|
|
|
|
for_input = (dynamic_cast<InputConnection *> (current_connection) != 0);
|
|
|
|
|
|
|
|
ports = session->engine().get_ports ("", JACK_DEFAULT_AUDIO_TYPE, for_input?JackPortIsOutput:JackPortIsInput);
|
|
|
|
|
|
|
|
if (ports == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* find all the client names and group their ports into a list-by-client */
|
|
|
|
|
|
|
|
for (int n = 0; ports[n]; ++n) {
|
|
|
|
|
|
|
|
pair<string,vector<pair<string,string> > > newpair;
|
|
|
|
pair<string,string> strpair;
|
|
|
|
pair<PortMap::iterator,bool> result;
|
|
|
|
|
|
|
|
string str = ports[n];
|
|
|
|
string::size_type pos;
|
|
|
|
string portname;
|
|
|
|
|
|
|
|
pos = str.find (':');
|
|
|
|
|
|
|
|
newpair.first = str.substr (0, pos);
|
|
|
|
portname = str.substr (pos+1);
|
|
|
|
|
|
|
|
result = portmap.insert (newpair);
|
|
|
|
|
|
|
|
strpair.first = portname;
|
|
|
|
strpair.second = str;
|
|
|
|
|
|
|
|
result.first->second.push_back (strpair);
|
|
|
|
}
|
|
|
|
|
|
|
|
PortMap::iterator i;
|
|
|
|
|
|
|
|
for (i = portmap.begin(); i != portmap.end(); ++i) {
|
|
|
|
|
|
|
|
Box *client_box = manage (new VBox);
|
2005-10-31 19:56:09 -05:00
|
|
|
Gtk::CTreeView *display = manage (new Gtk::TreeView);
|
|
|
|
RefPtr<TreeModel> model = TreeModel::create (columns);
|
2005-09-25 14:42:24 -04:00
|
|
|
ScrolledWindow *scroller = manage (new ScrolledWindow);
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
display->set_selection_mode (GTK_SELECTION_SINGLE);
|
|
|
|
display->set_name ("ConnectionEditorList");
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (vector<pair<string,string> >::iterator s = i->second.begin(); s != i->second.end(); ++s) {
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
Row row = model->append ();
|
|
|
|
|
|
|
|
row[displayed_name] = s->first;
|
|
|
|
row[full_name] = s->second;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
display->get_selection()->signal_changed().connect (bind (mem_fun(*this, &ConnectionEditor::port_selection_handler), display));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
Label *tab_label = manage (new Label);
|
|
|
|
|
|
|
|
tab_label->set_name ("ConnectionEditorNotebookTab");
|
|
|
|
tab_label->set_text ((*i).first);
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
display->set_model (model);
|
|
|
|
|
|
|
|
scroller->add (*client_port_display);
|
|
|
|
scroller->set_policy (Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
|
|
|
|
|
|
|
client_box->pack_start (*scroller);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
pages.push_back (TabElem (*client_box, *tab_label));
|
|
|
|
}
|
|
|
|
|
|
|
|
notebook.set_page (current_page);
|
2005-09-25 17:19:23 -04:00
|
|
|
notebook.show.connect (bind (mem_fun (notebook, &Notebook::set_page), current_page));
|
2005-09-25 14:42:24 -04:00
|
|
|
selector_box.show_all ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::display_connection_state (bool for_input)
|
|
|
|
{
|
2006-06-07 10:54:12 -04:00
|
|
|
Glib::Mutex::Lock lm (port_display_lock);
|
2005-09-25 14:42:24 -04:00
|
|
|
uint32_t limit;
|
|
|
|
|
|
|
|
if (session == 0 || current_connection == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
string frame_label = _("Connection \"");
|
|
|
|
frame_label += current_connection->name();
|
|
|
|
frame_label += _("\"");
|
|
|
|
port_frame.set_label (frame_label);
|
|
|
|
|
|
|
|
for (slist<ScrolledWindow *>::iterator i = port_displays.begin(); i != port_displays.end(); ) {
|
|
|
|
|
|
|
|
slist<ScrolledWindow *>::iterator tmp;
|
|
|
|
|
|
|
|
tmp = i;
|
|
|
|
tmp++;
|
|
|
|
|
|
|
|
port_box.remove (**i);
|
|
|
|
delete *i;
|
|
|
|
port_displays.erase (i);
|
|
|
|
|
|
|
|
i = tmp;
|
|
|
|
}
|
|
|
|
|
|
|
|
limit = current_connection->nports();
|
|
|
|
|
|
|
|
for (uint32_t n = 0; n < limit; ++n) {
|
|
|
|
|
|
|
|
CList *clist;
|
|
|
|
ScrolledWindow *scroller;
|
|
|
|
|
|
|
|
const gchar *title[1];
|
|
|
|
char buf[32];
|
|
|
|
string really_short_name;
|
|
|
|
|
|
|
|
if (for_input) {
|
|
|
|
snprintf(buf, sizeof(buf)-1, _("in %d"), n+1);
|
|
|
|
} else {
|
|
|
|
snprintf(buf, sizeof(buf)-1, _("out %d"), n+1);
|
|
|
|
}
|
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
tview = manage (new TreeView());
|
|
|
|
Glib::RefPtr<ListStore> port_model = ListStore::create (*port_display_columns);
|
|
|
|
|
|
|
|
tview->set_model (port_model);
|
|
|
|
tview->append_column (_(buf), port_display_columns->name);
|
|
|
|
tview->set_selection()->set_mode (Gtk::SELECTION_SINGLE);
|
|
|
|
tview->set_data ("port", (gpointer) ((intptr_t) n));
|
|
|
|
tview->set_headers_visible (true);
|
|
|
|
tview->set_name ("ConnectionEditorPortList");
|
|
|
|
tview->signal_button_press_event().connect (bind (mem_fun(*this, &ConnectionEditor::port_column_click), clist));
|
|
|
|
|
|
|
|
scroller = manage (new ScrolledWindow);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
scroller->add (*tview);
|
2005-09-25 16:33:00 -04:00
|
|
|
scroller->set_policy (Gtk::POLICY_NEVER, Gtk::POLICY_AUTOMATIC);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
port_displays.insert (port_displays.end(), scroller);
|
|
|
|
port_box.pack_start (*scroller);
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
scroller->set_size_request (-1, 75);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
/* now fill the clist with the current connections */
|
|
|
|
|
|
|
|
const ARDOUR::Connection::PortList& connections = current_connection->port_connections (n);
|
|
|
|
|
|
|
|
for (ARDOUR::Connection::PortList::const_iterator i = connections.begin(); i != connections.end(); ++i) {
|
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
TreeModel::Row row = *(model->append());
|
|
|
|
|
|
|
|
row[port_connection_columns.name] = (*i)->name();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
port_box.show_all ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-10-12 12:28:26 -04:00
|
|
|
ConnectionEditor::port_selection_changed (TreeView* tview)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-12 12:28:26 -04:00
|
|
|
Glib::RefPtr<TreeView::Selection> sel = tview->get_selection();
|
|
|
|
TreeModel::iterator iter = sel->get_selected();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if (!current_connection) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
if (iter) {
|
|
|
|
TreeModel::Row row = *iter;
|
2005-10-31 19:56:09 -05:00
|
|
|
string other_port_name = row[port_display_columns.full_name];
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (current_connection && selected_port >= 0) {
|
|
|
|
current_connection->add_connection (selected_port, other_port_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::add_port ()
|
|
|
|
{
|
|
|
|
if (current_connection) {
|
|
|
|
current_connection->add_port ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-10-31 19:56:09 -05:00
|
|
|
ConnectionEditor::connection_port_button_press_event (GdkEventButton* ev, TreeView* tview)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-06-07 10:54:12 -04:00
|
|
|
Glib::Mutex::Lock lm (port_display_lock);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
int which_port = reinterpret_cast<intptr_t> (treeview->get_data ("port"));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (which_port != selected_port) {
|
|
|
|
|
|
|
|
selected_port = which_port;
|
|
|
|
display_ports ();
|
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
tview->set_name ("ConnectionEditorPortListSelected");
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
for (slist<ScrolledWindow *>::iterator i = port_displays.begin(); i != port_displays.end(); ++i) {
|
|
|
|
|
|
|
|
Widget *child = (*i)->get_child();
|
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
if (static_cast<TreeView *> (child) != tview) {
|
2005-09-25 14:42:24 -04:00
|
|
|
child->set_name ("ConnectionEditorPortList");
|
|
|
|
child->queue_draw ();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
selected_port = -1;
|
|
|
|
clist->set_name ("ConnectionEditorPortList");
|
|
|
|
clist->queue_draw();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
void
|
|
|
|
ConnectionEditor::connection_selection_changed (TreeView* tview);
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-12 12:28:26 -04:00
|
|
|
Glib::RefPtr<TreeView::Selection> sel = tview->get_selection();
|
|
|
|
TreeModel::iterator iter = sel->get_selected();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
if (iter) {
|
|
|
|
TreeModel::Row row = *iter;
|
|
|
|
current_connection = row[XXXX_display_columns.connection];
|
|
|
|
} else {
|
|
|
|
current_connection = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::new_connection (bool for_input)
|
|
|
|
{
|
2005-10-12 12:28:26 -04:00
|
|
|
string name;
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (session == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ArdourPrompter prompter (true);
|
|
|
|
prompter.set_prompt (_("Name for new connection:"));
|
|
|
|
prompter.done.connect (Gtk::Main::quit.slot());
|
|
|
|
|
2005-10-12 12:28:26 -04:00
|
|
|
switch (prompter.run()) {
|
2006-01-13 14:48:55 -05:00
|
|
|
case Gtk::RESPONSE_ACCEPT:
|
2005-09-25 14:42:24 -04:00
|
|
|
prompter.get_result (name);
|
|
|
|
push_at_front = true;
|
|
|
|
if (name.length()) {
|
|
|
|
if (for_input) {
|
|
|
|
session->add_connection (new ARDOUR::InputConnection (name));
|
|
|
|
} else {
|
|
|
|
session->add_connection (new ARDOUR::OutputConnection (name));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
push_at_front = false;
|
2005-10-12 12:28:26 -04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ConnectionEditor::delete_connection ()
|
|
|
|
{
|
|
|
|
if (session && current_connection) {
|
|
|
|
session->remove_connection (current_connection);
|
|
|
|
current_connection = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2005-10-31 19:56:09 -05:00
|
|
|
ConnectionEditor::port_button_event (GdkEventButton *ev, Treeview* treeview)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
int row, col;
|
2005-10-31 19:56:09 -05:00
|
|
|
TreeIter iter;
|
|
|
|
TreeModel::Path path;
|
|
|
|
TreeViewColumn* column;
|
|
|
|
int cellx;
|
|
|
|
int celly;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (current_connection == 0) {
|
2005-10-31 19:56:09 -05:00
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if (!(Keyboard::is_delete_event (ev))) {
|
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if (!treeview->get_path_at_pos ((int)ev->x, (int)ev->y, path, column, cellx, celly)) {
|
|
|
|
return false;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if ((iter = treeview->get_model()->get_iter (path))) {
|
|
|
|
/* path is valid */
|
|
|
|
|
|
|
|
string port_name = (*iter)[columns.full_name];
|
|
|
|
int which_port = (intptr_t) treeview->get_data ("port");
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
current_connection->remove_connection (which_port, port_name);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|