2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2002-2003 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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <vector>
|
|
|
|
|
2006-08-29 17:21:48 -04:00
|
|
|
#include <sigc++/bind.h>
|
|
|
|
|
2006-03-05 14:39:16 -05:00
|
|
|
#include <gtkmm/messagedialog.h>
|
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
#include <glibmm/thread.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include <ardour/io.h>
|
|
|
|
#include <ardour/route.h>
|
|
|
|
#include <ardour/audioengine.h>
|
|
|
|
#include <ardour/port.h>
|
2007-06-19 23:39:19 -04:00
|
|
|
#include <ardour/port_insert.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
#include <ardour/session.h>
|
2006-06-14 21:34:54 -04:00
|
|
|
#include <ardour/audio_diskstream.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/doi.h>
|
|
|
|
#include <gtkmm2ext/gtk_ui.h>
|
2006-01-01 10:31:59 -05:00
|
|
|
#include <gtkmm2ext/utils.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include "utils.h"
|
|
|
|
#include "io_selector.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace Gtk;
|
2005-10-31 19:56:09 -05:00
|
|
|
using namespace Glib;
|
2005-09-25 16:33:00 -04:00
|
|
|
using namespace sigc;
|
2005-09-25 14:42:24 -04:00
|
|
|
using namespace ARDOUR;
|
Large nasty commit in the form of a 5000 line patch chock-full of completely
unecessary changes. (Sorry, doing a "sprint" based thing, this is the end of the first one)
Achieved MIDI track and bus creation, associated Jack port and diskstream creation, and minimal GUI stuff for creating them. Should be set to start work on actually recording and playing midi to/from disk now.
Relevant (significant) changes:
- Creation of a Buffer class. Base class is type agnostic so things can point to a buffer but not care what kind it is (otherwise it'd be a template). Derived into AudioBuffer and MidiBuffer, with a type tag because checking type is necessary in parts of the code where dynamic_cast wouldn't be wise. Originally I considered this a hack, but passing around a type proved to be a very good solution to all the other problems (below). There is a 1:1 mapping between jack port data types and ardour Buffer types (with a conversion function), but that's easily removed if it ever becomes necessary. Having the type scoped in the Buffer class is maybe not the best spot for it, but whatever (this is proof of concept kinda stuff right now...)
- IO now has a "default" port type (passed to the constructor and stored as a member), used by ensure_io (and similar) to create n ports. IO::register_***_port has a type argument that defaults to the default type if not passed. Rationale: previous IO API is identical, no changes needed to existing code, but path is paved for multiple port types in one IO, which we will need for eg synth plugin inserts, among other things. This is not quite ideal (best would be to only have the two port register functions and have them take a type), but the alternative is a lot of work (namely destroying the 'ensure' functions and everything that uses them) for very little gain. (I am convinced after quite a few tries at the whiteboard that subclassing IO in any way is not a feasible option, look at it's inheritance diagram in Doxygen and you can see why)
- AudioEngine::register_audio_input_port is now register_input_port and takes a type argument. Ditto for output.
- (Most significant change) AudioDiskstream abstracted into Distream, and sibling MidiDiskstream created. Very much still a work in progress, but Diskstream is there to switch references over to (most already are), which is the important part. It is still unclear what the MIDI diskstream's relation to channels is, but I'm pretty sure they will be single channel only (so SMF Type 0) since noone can come up with a reason otherwise.
- MidiTrack creation. Same thing as AudioTrack but with a different default type basically. No big deal here.
- Random cleanups and variable renamings etc. because I have OCD and can't help myself. :)
Known broken: Loading of sessions containing MIDI tracks.
git-svn-id: svn://localhost/ardour2/branches/midi@641 d708f5d6-7413-0410-9779-e7cbd77b26cf
2006-06-26 12:01:34 -04:00
|
|
|
using namespace PBD;
|
2006-01-01 10:31:59 -05:00
|
|
|
using namespace Gtkmm2ext;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
IOSelectorWindow::IOSelectorWindow (Session& sess, boost::shared_ptr<IO> ior, bool input, bool can_cancel)
|
2005-09-25 14:42:24 -04:00
|
|
|
: ArdourDialog ("i/o selector"),
|
|
|
|
_selector (sess, ior, input),
|
|
|
|
ok_button (can_cancel ? _("OK"): _("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
|
|
|
set_name ("IOSelectorWindow");
|
|
|
|
|
|
|
|
string title;
|
|
|
|
if (input) {
|
2006-07-27 21:08:57 -04:00
|
|
|
title = string_compose(_("%1 input"), ior->name());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-07-27 21:08:57 -04:00
|
|
|
title = string_compose(_("%1 output"), ior->name());
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ok_button.set_name ("IOSelectorButton");
|
|
|
|
cancel_button.set_name ("IOSelectorButton");
|
|
|
|
rescan_button.set_name ("IOSelectorButton");
|
|
|
|
|
|
|
|
button_box.set_spacing (5);
|
|
|
|
button_box.set_border_width (5);
|
|
|
|
button_box.set_homogeneous (true);
|
|
|
|
button_box.pack_start (rescan_button);
|
|
|
|
|
|
|
|
if (can_cancel) {
|
|
|
|
button_box.pack_start (cancel_button);
|
2005-10-31 19:56:09 -05:00
|
|
|
} else {
|
2005-09-25 14:42:24 -04:00
|
|
|
cancel_button.hide();
|
|
|
|
}
|
|
|
|
|
|
|
|
button_box.pack_start (ok_button);
|
|
|
|
|
2005-12-14 12:21:53 -05:00
|
|
|
get_vbox()->pack_start (_selector);
|
|
|
|
get_vbox()->pack_start (button_box, false, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
ok_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::accept));
|
|
|
|
cancel_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::cancel));
|
|
|
|
rescan_button.signal_clicked().connect (mem_fun(*this, &IOSelectorWindow::rescan));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
set_title (title);
|
2005-10-31 19:56:09 -05:00
|
|
|
set_position (WIN_POS_MOUSE);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-07-06 19:55:54 -04:00
|
|
|
ok_button.show();
|
|
|
|
cancel_button.show();
|
|
|
|
rescan_button.show();
|
|
|
|
button_box.show();
|
|
|
|
get_vbox()->show();
|
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this)));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
IOSelectorWindow::~IOSelectorWindow()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelectorWindow::rescan ()
|
|
|
|
{
|
|
|
|
_selector.redisplay ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelectorWindow::cancel ()
|
|
|
|
{
|
|
|
|
_selector.Finished(IOSelector::Cancelled);
|
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelectorWindow::accept ()
|
|
|
|
{
|
|
|
|
_selector.Finished(IOSelector::Accepted);
|
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
void
|
|
|
|
IOSelectorWindow::on_map ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
_selector.redisplay ();
|
2005-10-31 19:56:09 -05:00
|
|
|
Window::on_map ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/*************************
|
|
|
|
The IO Selector "widget"
|
|
|
|
*************************/
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
IOSelector::IOSelector (Session& sess, boost::shared_ptr<IO> ior, bool input)
|
2005-09-25 14:42:24 -04:00
|
|
|
: session (sess),
|
|
|
|
io (ior),
|
|
|
|
for_input (input),
|
|
|
|
port_frame (for_input? _("Inputs") : _("Outputs")),
|
|
|
|
add_port_button (for_input? _("Add Input") : _("Add Output")),
|
|
|
|
remove_port_button (for_input? _("Remove Input") : _("Remove Output")),
|
|
|
|
clear_connections_button (_("Disconnect All"))
|
|
|
|
{
|
|
|
|
selected_port = 0;
|
|
|
|
|
|
|
|
notebook.set_name ("IOSelectorNotebook");
|
2005-09-25 16:33:00 -04:00
|
|
|
notebook.set_size_request (-1, 125);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
clear_connections_button.set_name ("IOSelectorButton");
|
|
|
|
add_port_button.set_name ("IOSelectorButton");
|
|
|
|
remove_port_button.set_name ("IOSelectorButton");
|
|
|
|
|
|
|
|
selector_frame.set_name ("IOSelectorFrame");
|
|
|
|
port_frame.set_name ("IOSelectorFrame");
|
|
|
|
|
|
|
|
selector_frame.set_label (_("Available connections"));
|
|
|
|
|
|
|
|
selector_button_box.set_spacing (5);
|
|
|
|
selector_button_box.set_border_width (5);
|
|
|
|
|
|
|
|
selector_box.set_spacing (5);
|
|
|
|
selector_box.set_border_width (5);
|
|
|
|
selector_box.pack_start (notebook);
|
|
|
|
selector_box.pack_start (selector_button_box, false, false);
|
|
|
|
|
|
|
|
selector_frame.add (selector_box);
|
|
|
|
|
|
|
|
port_box.set_spacing (5);
|
|
|
|
port_box.set_border_width (5);
|
|
|
|
|
|
|
|
port_display_scroller.set_name ("IOSelectorNotebook");
|
|
|
|
port_display_scroller.set_border_width (0);
|
2005-09-25 16:33:00 -04:00
|
|
|
port_display_scroller.set_size_request (-1, 170);
|
2005-10-22 13:33:14 -04:00
|
|
|
port_display_scroller.add (port_box);
|
2005-10-31 19:56:09 -05:00
|
|
|
port_display_scroller.set_policy (POLICY_NEVER,
|
|
|
|
POLICY_AUTOMATIC);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
port_button_box.set_spacing (5);
|
|
|
|
port_button_box.set_border_width (5);
|
|
|
|
|
|
|
|
port_button_box.pack_start (add_port_button, false, false);
|
|
|
|
|
2006-08-11 03:15:30 -04:00
|
|
|
// The IO selector only works for single typed IOs
|
|
|
|
const ARDOUR::DataType t = io->default_type();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (for_input) {
|
2006-08-11 03:15:30 -04:00
|
|
|
if (io->input_maximum().get(t) < 0 || io->input_maximum().get(t) > (size_t) io->n_inputs().get(t)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
add_port_button.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
add_port_button.set_sensitive (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2006-08-11 03:15:30 -04:00
|
|
|
if (io->output_maximum().get(t) < 0 || io->output_maximum().get(t) > (size_t) io->n_outputs().get(t)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
add_port_button.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
add_port_button.set_sensitive (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
port_button_box.pack_start (remove_port_button, false, false);
|
|
|
|
|
|
|
|
if (for_input) {
|
2006-08-11 03:15:30 -04:00
|
|
|
if (io->input_minimum().get(t) < 0 || io->input_minimum().get(t) < (size_t) io->n_inputs().get(t)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
remove_port_button.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
remove_port_button.set_sensitive (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
2006-08-11 03:15:30 -04:00
|
|
|
if (io->output_minimum().get(t) < 0 || io->output_minimum().get(t) < (size_t) io->n_outputs().get(t)) {
|
2005-09-25 14:42:24 -04:00
|
|
|
remove_port_button.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
remove_port_button.set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
port_button_box.pack_start (clear_connections_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_display_scroller);
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
set_spacing (5);
|
|
|
|
set_border_width (5);
|
|
|
|
pack_start (port_and_selector_box);
|
|
|
|
|
|
|
|
rescan();
|
|
|
|
display_ports ();
|
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
clear_connections_button.signal_clicked().connect (mem_fun(*this, &IOSelector::clear_connections));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
add_port_button.signal_clicked().connect (mem_fun(*this, &IOSelector::add_port));
|
|
|
|
remove_port_button.signal_clicked().connect (mem_fun(*this, &IOSelector::remove_port));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (for_input) {
|
2006-07-27 21:08:57 -04:00
|
|
|
io->input_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-07-27 21:08:57 -04:00
|
|
|
io->output_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2007-06-23 16:13:13 -04:00
|
|
|
io->NameChanged.connect (mem_fun(*this, &IOSelector::name_changed));
|
2007-07-06 19:55:54 -04:00
|
|
|
|
|
|
|
main_box.show();
|
|
|
|
port_and_selector_box.show();
|
|
|
|
notebook.show();
|
|
|
|
selector_frame.show();
|
|
|
|
selector_box.show();
|
|
|
|
selector_button_box.show();
|
|
|
|
port_box.show();
|
|
|
|
port_button_box.show();
|
|
|
|
port_and_button_box.show();
|
|
|
|
port_frame.show();
|
|
|
|
add_port_button.show();
|
|
|
|
remove_port_button.show();
|
|
|
|
clear_connections_button.show();
|
|
|
|
port_display_scroller.show();
|
|
|
|
|
|
|
|
show();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
IOSelector::~IOSelector ()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
void
|
|
|
|
IOSelector::set_button_sensitivity ()
|
|
|
|
{
|
|
|
|
DataType t = io->default_type();
|
|
|
|
|
|
|
|
if (for_input) {
|
|
|
|
|
|
|
|
if (io->input_maximum().get(t) < 0 || io->input_maximum().get(t) > io->n_inputs().get(t)) {
|
|
|
|
add_port_button.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
add_port_button.set_sensitive (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (io->output_maximum().get(t) < 0 || io->output_maximum().get(t) > io->n_outputs().get(t)) {
|
|
|
|
add_port_button.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
add_port_button.set_sensitive (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (for_input) {
|
|
|
|
if (io->n_inputs().get(t) && (io->input_minimum().get(t) < 0 || io->input_minimum().get(t) < io->n_inputs().get(t))) {
|
|
|
|
remove_port_button.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
remove_port_button.set_sensitive (false);
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
if (io->n_outputs().get(t) && (io->output_minimum().get(t) < 0 || io->output_minimum().get(t) < io->n_outputs().get(t))) {
|
|
|
|
remove_port_button.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
remove_port_button.set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2007-06-23 16:13:13 -04:00
|
|
|
IOSelector::name_changed ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-06-23 16:13:13 -04:00
|
|
|
ENSURE_GUI_THREAD(mem_fun(*this, &IOSelector::name_changed));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
display_ports ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelector::clear_connections ()
|
|
|
|
{
|
|
|
|
if (for_input) {
|
2006-07-27 21:08:57 -04:00
|
|
|
io->disconnect_inputs (this);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-07-27 21:08:57 -04:00
|
|
|
io->disconnect_outputs (this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelector::rescan ()
|
|
|
|
{
|
|
|
|
using namespace Notebook_Helpers;
|
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
typedef std::map<string,vector<pair<string,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;
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
page_selection_connection.disconnect ();
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
current_page = notebook.get_current_page ();
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
pages.clear ();
|
|
|
|
|
|
|
|
/* get relevant current JACK ports */
|
|
|
|
|
2007-05-10 00:45:38 -04:00
|
|
|
ports = session.engine().get_ports ("", io->default_type().to_jack_type(), for_input ? JackPortIsOutput : JackPortIsInput);
|
2005-10-31 19:56:09 -05:00
|
|
|
|
|
|
|
if (ports == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* 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;
|
2005-10-31 19:56:09 -05:00
|
|
|
pair<PortMap::iterator,bool> result;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
string str = ports[n];
|
|
|
|
string::size_type pos;
|
|
|
|
string portname;
|
|
|
|
|
|
|
|
pos = str.find (':');
|
|
|
|
|
2005-12-24 08:00:17 -05:00
|
|
|
newpair.first = str.substr (0, pos);
|
2005-09-25 14:42:24 -04:00
|
|
|
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
|
|
|
TreeView *display = manage (new TreeView);
|
|
|
|
RefPtr<ListStore> model = ListStore::create (port_display_columns);
|
2005-09-25 14:42:24 -04:00
|
|
|
ScrolledWindow *scroller = manage (new ScrolledWindow);
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
display->set_model (model);
|
|
|
|
display->append_column (X_("notvisible"), port_display_columns.displayed_name);
|
|
|
|
display->set_headers_visible (false);
|
|
|
|
display->get_selection()->set_mode (SELECTION_SINGLE);
|
|
|
|
display->set_name ("IOSelectorList");
|
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
|
|
|
TreeModel::Row row = *(model->append ());
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
row[port_display_columns.displayed_name] = s->first;
|
|
|
|
row[port_display_columns.full_name] = s->second;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-03-08 18:19:24 -05:00
|
|
|
display->signal_button_release_event().connect (bind (mem_fun(*this, &IOSelector::port_selection_changed), display));
|
2005-09-25 14:42:24 -04:00
|
|
|
Label *tab_label = manage (new Label);
|
|
|
|
|
|
|
|
tab_label->set_name ("IOSelectorNotebookTab");
|
|
|
|
tab_label->set_text ((*i).first);
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
scroller->add (*display);
|
|
|
|
scroller->set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC);
|
|
|
|
|
|
|
|
client_box->pack_start (*scroller);
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
pages.push_back (TabElem (*client_box, *tab_label));
|
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
notebook.set_current_page (current_page);
|
2006-11-19 11:45:16 -05:00
|
|
|
page_selection_connection = notebook.signal_show().connect (bind (mem_fun (notebook, &Notebook::set_current_page), current_page));
|
2005-09-25 14:42:24 -04:00
|
|
|
selector_box.show_all ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelector::display_ports ()
|
|
|
|
{
|
2005-10-31 19:56:09 -05:00
|
|
|
TreeView *firsttview = 0;
|
|
|
|
TreeView *selected_port_tview = 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-06-13 03:27:52 -04:00
|
|
|
Glib::Mutex::Lock lm (port_display_lock);
|
2005-09-25 14:42:24 -04:00
|
|
|
Port *port;
|
|
|
|
uint32_t limit;
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2006-08-11 03:15:30 -04:00
|
|
|
// The IO selector only works for single typed IOs
|
|
|
|
const ARDOUR::DataType t = io->default_type();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (for_input) {
|
2006-08-11 03:15:30 -04:00
|
|
|
limit = io->n_inputs().get(t);
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-08-11 03:15:30 -04:00
|
|
|
limit = io->n_outputs().get(t);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
for (slist<TreeView *>::iterator i = port_displays.begin(); i != port_displays.end(); ) {
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
slist<TreeView *>::iterator tmp;
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
tmp = i;
|
|
|
|
++tmp;
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
port_box.remove (**i);
|
|
|
|
delete *i;
|
|
|
|
port_displays.erase (i);
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
i = tmp;
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
for (uint32_t n = 0; n < limit; ++n) {
|
2005-10-31 19:56:09 -05:00
|
|
|
|
|
|
|
TreeView* tview;
|
2005-12-24 08:00:17 -05:00
|
|
|
//ScrolledWindow *scroller;
|
2005-09-25 14:42:24 -04:00
|
|
|
string really_short_name;
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2005-12-14 12:21:53 -05:00
|
|
|
if (for_input) {
|
2006-07-27 21:08:57 -04:00
|
|
|
port = io->input (n);
|
2005-12-14 12:21:53 -05:00
|
|
|
} else {
|
2006-07-27 21:08:57 -04:00
|
|
|
port = io->output (n);
|
2005-12-14 12:21:53 -05:00
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
/* we know there is '/' because we put it there */
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
really_short_name = port->short_name();
|
|
|
|
really_short_name = really_short_name.substr (really_short_name.find ('/') + 1);
|
2007-01-09 18:24:54 -05:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
tview = manage (new TreeView());
|
|
|
|
RefPtr<ListStore> port_model = ListStore::create (port_display_columns);
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if (!firsttview) {
|
|
|
|
firsttview = tview;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
tview->set_model (port_model);
|
|
|
|
tview->append_column (really_short_name, port_display_columns.displayed_name);
|
|
|
|
tview->get_selection()->set_mode (SELECTION_SINGLE);
|
2006-11-19 11:45:16 -05:00
|
|
|
tview->set_data (X_("port"), port);
|
2005-10-31 19:56:09 -05:00
|
|
|
tview->set_headers_visible (true);
|
2006-11-19 11:45:16 -05:00
|
|
|
tview->set_name (X_("IOSelectorPortList"));
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2005-12-24 08:00:17 -05:00
|
|
|
port_box.pack_start (*tview);
|
2005-10-31 19:56:09 -05:00
|
|
|
port_displays.insert (port_displays.end(), tview);
|
|
|
|
|
|
|
|
/* now fill the clist with the current connections */
|
|
|
|
|
|
|
|
const char **connections = port->get_connections ();
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if (connections) {
|
|
|
|
for (uint32_t c = 0; connections[c]; ++c) {
|
|
|
|
TreeModel::Row row = *(port_model->append());
|
|
|
|
row[port_display_columns.displayed_name] = connections[c];
|
2005-12-24 08:00:17 -05:00
|
|
|
row[port_display_columns.full_name] = connections[c];
|
2005-10-31 19:56:09 -05:00
|
|
|
}
|
2007-01-09 18:24:54 -05:00
|
|
|
}
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (for_input) {
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2006-08-11 03:15:30 -04:00
|
|
|
if (io->input_maximum().get(io->default_type()) == 1) {
|
2005-09-25 14:42:24 -04:00
|
|
|
selected_port = port;
|
2005-10-31 19:56:09 -05:00
|
|
|
selected_port_tview = tview;
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
if (port == selected_port) {
|
2005-10-31 19:56:09 -05:00
|
|
|
selected_port_tview = tview;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2006-08-11 03:15:30 -04:00
|
|
|
if (io->output_maximum().get(t) == 1) {
|
2005-09-25 14:42:24 -04:00
|
|
|
selected_port = port;
|
2005-10-31 19:56:09 -05:00
|
|
|
selected_port_tview = tview;
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
|
|
|
if (port == selected_port) {
|
2005-10-31 19:56:09 -05:00
|
|
|
selected_port_tview = tview;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
TreeViewColumn* col = tview->get_column (0);
|
|
|
|
|
|
|
|
col->set_clickable (true);
|
2006-11-19 11:45:16 -05:00
|
|
|
|
|
|
|
/* handle button events on the column header ... */
|
2006-03-09 22:16:38 -05:00
|
|
|
col->signal_clicked().connect (bind (mem_fun(*this, &IOSelector::select_treeview), tview));
|
2006-11-19 11:45:16 -05:00
|
|
|
|
|
|
|
/* ... and within the treeview itself */
|
2005-12-24 08:00:17 -05:00
|
|
|
tview->signal_button_release_event().connect (bind (mem_fun(*this, &IOSelector::connection_button_release), tview));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
port_box.show_all ();
|
|
|
|
}
|
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
if (!selected_port_tview) {
|
|
|
|
selected_port_tview = firsttview;
|
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if (selected_port_tview) {
|
|
|
|
select_treeview (selected_port_tview);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-03-08 18:19:24 -05:00
|
|
|
bool
|
|
|
|
IOSelector::port_selection_changed (GdkEventButton *ev, TreeView* treeview)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-31 19:56:09 -05:00
|
|
|
TreeModel::iterator i = treeview->get_selection()->get_selected();
|
2005-09-25 14:42:24 -04:00
|
|
|
int status;
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if (!i) {
|
2006-03-08 18:19:24 -05:00
|
|
|
return 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
if (selected_port == 0) {
|
2006-03-08 18:19:24 -05:00
|
|
|
return 0;
|
2005-10-31 19:56:09 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
ustring other_port_name = (*i)[port_display_columns.full_name];
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (for_input) {
|
2006-07-27 21:08:57 -04:00
|
|
|
if ((status = io->connect_input (selected_port, other_port_name, this)) == 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
Port *p = session.engine().get_port_by_name (other_port_name);
|
2006-08-30 21:06:37 -04:00
|
|
|
if (p) {
|
|
|
|
p->enable_metering();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
} else {
|
2006-07-27 21:08:57 -04:00
|
|
|
status = io->connect_output (selected_port, other_port_name, this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (status == 0) {
|
2005-10-31 19:56:09 -05:00
|
|
|
select_next_treeview ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-03-08 18:19:24 -05:00
|
|
|
|
|
|
|
treeview->get_selection()->unselect_all();
|
|
|
|
return 0;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelector::ports_changed (IOChange change, void *src)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &IOSelector::ports_changed), change, src));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
display_ports ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelector::add_port ()
|
|
|
|
{
|
|
|
|
/* add a new port, then hide the button if we're up to the maximum allowed */
|
|
|
|
|
2006-08-11 03:15:30 -04:00
|
|
|
// The IO selector only works for single typed IOs
|
|
|
|
const ARDOUR::DataType t = io->default_type();
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
if (for_input) {
|
|
|
|
|
|
|
|
try {
|
2006-07-27 21:08:57 -04:00
|
|
|
io->add_input_port ("", this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
catch (AudioEngine::PortRegistrationFailure& err) {
|
2006-03-05 14:39:16 -05:00
|
|
|
MessageDialog msg (0, _("There are no more JACK ports available."));
|
|
|
|
msg.run ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
try {
|
2006-07-27 21:08:57 -04:00
|
|
|
io->add_output_port ("", this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
catch (AudioEngine::PortRegistrationFailure& err) {
|
2006-03-05 14:39:16 -05:00
|
|
|
MessageDialog msg (0, _("There are no more JACK ports available."));
|
|
|
|
msg.run ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
|
|
|
set_button_sensitivity ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelector::remove_port ()
|
|
|
|
{
|
|
|
|
uint32_t nports;
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2006-08-11 03:15:30 -04:00
|
|
|
// The IO selector only works for single typed IOs
|
|
|
|
const ARDOUR::DataType t = io->default_type();
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
// always remove last port
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if (for_input) {
|
2006-08-11 03:15:30 -04:00
|
|
|
if ((nports = io->n_inputs().get(t)) > 0) {
|
2006-07-27 21:08:57 -04:00
|
|
|
io->remove_input_port (io->input(nports-1), this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
} else {
|
2006-08-11 03:15:30 -04:00
|
|
|
if ((nports = io->n_outputs().get(t)) > 0) {
|
2006-07-27 21:08:57 -04:00
|
|
|
io->remove_output_port (io->output(nports-1), this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
|
|
|
set_button_sensitivity ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
gint
|
2005-10-31 19:56:09 -05:00
|
|
|
IOSelector::connection_button_release (GdkEventButton *ev, TreeView *treeview)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-31 19:56:09 -05:00
|
|
|
/* this handles button release on a port name row: i.e. a connection
|
|
|
|
between the named port and the port represented by the treeview.
|
|
|
|
*/
|
|
|
|
|
2005-12-24 08:00:17 -05:00
|
|
|
Gtk::TreeModel::iterator iter;
|
2005-10-31 19:56:09 -05:00
|
|
|
TreeModel::Path path;
|
|
|
|
TreeViewColumn* column;
|
|
|
|
int cellx;
|
|
|
|
int celly;
|
|
|
|
|
|
|
|
/* only handle button1 events here */
|
|
|
|
|
|
|
|
if (ev->button != 1) {
|
|
|
|
return false;
|
|
|
|
}
|
2005-12-24 08:00:17 -05: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;
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2005-12-24 08:00:17 -05:00
|
|
|
if ((iter = treeview->get_model()->get_iter (path.to_string()))) {
|
2005-10-31 19:56:09 -05:00
|
|
|
|
|
|
|
/* path is valid */
|
|
|
|
ustring connected_port_name = (*iter)[port_display_columns.full_name];
|
2006-11-19 11:45:16 -05:00
|
|
|
Port *port = reinterpret_cast<Port *> (treeview->get_data (X_("port")));
|
2005-10-31 19:56:09 -05:00
|
|
|
|
|
|
|
if (for_input) {
|
|
|
|
Port *p = session.engine().get_port_by_name (connected_port_name);
|
2006-08-30 21:06:37 -04:00
|
|
|
if (p) {
|
|
|
|
p->disable_metering();
|
|
|
|
}
|
2006-07-27 21:08:57 -04:00
|
|
|
io->disconnect_input (port, connected_port_name, this);
|
2005-10-31 19:56:09 -05:00
|
|
|
} else {
|
2006-07-27 21:08:57 -04:00
|
|
|
io->disconnect_output (port, connected_port_name, this);
|
2005-10-31 19:56:09 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
2005-10-31 19:56:09 -05:00
|
|
|
IOSelector::select_next_treeview ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-31 19:56:09 -05:00
|
|
|
slist<TreeView*>::iterator next;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
if (port_displays.empty() || port_displays.size() == 1) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
for (slist<TreeView *>::iterator i = port_displays.begin(); i != port_displays.end(); ++i) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
if ((*i)->get_name() == "IOSelectorPortListSelected") {
|
|
|
|
|
|
|
|
++i;
|
|
|
|
|
|
|
|
if (i == port_displays.end()) {
|
2005-10-31 19:56:09 -05:00
|
|
|
select_treeview (port_displays.front());
|
2005-09-25 14:42:24 -04:00
|
|
|
} else {
|
2005-10-31 19:56:09 -05:00
|
|
|
select_treeview (*i);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-10-31 19:56:09 -05:00
|
|
|
IOSelector::select_treeview (TreeView* tview)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-10-31 19:56:09 -05:00
|
|
|
/* Gack. TreeView's don't respond visually to a change
|
2005-09-25 14:42:24 -04:00
|
|
|
in their state, so rename them to force a style
|
|
|
|
switch.
|
|
|
|
*/
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2006-06-13 03:27:52 -04:00
|
|
|
Glib::Mutex::Lock lm (port_display_lock);
|
2006-11-19 11:45:16 -05:00
|
|
|
Port* port = reinterpret_cast<Port *> (tview->get_data (X_("port")));
|
|
|
|
|
|
|
|
selected_port = port;
|
|
|
|
|
|
|
|
tview->set_name ("IOSelectorPortListSelected");
|
|
|
|
tview->queue_draw ();
|
|
|
|
|
|
|
|
/* ugly hack to force the column header button to change as well */
|
|
|
|
|
|
|
|
TreeViewColumn* col = tview->get_column (0);
|
|
|
|
GtkTreeViewColumn* ccol = col->gobj();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
if (ccol->button) {
|
|
|
|
gtk_widget_set_name (ccol->button, "IOSelectorPortListSelected");
|
|
|
|
gtk_widget_queue_draw (ccol->button);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (slist<TreeView*>::iterator i = port_displays.begin(); i != port_displays.end(); ++i) {
|
|
|
|
if (*i == tview) {
|
|
|
|
continue;
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
col = (*i)->get_column (0);
|
|
|
|
ccol = col->gobj();
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-11-19 11:45:16 -05:00
|
|
|
if (ccol->button) {
|
|
|
|
gtk_widget_set_name (ccol->button, "IOSelectorPortList");
|
|
|
|
gtk_widget_queue_draw (ccol->button);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
|
|
|
(*i)->set_name ("IOSelectorPortList");
|
|
|
|
(*i)->queue_draw ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
|
|
|
selector_box.show_all ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
IOSelector::redisplay ()
|
|
|
|
{
|
|
|
|
display_ports ();
|
|
|
|
|
|
|
|
if (for_input) {
|
2006-08-11 03:15:30 -04:00
|
|
|
if (io->input_maximum().get(io->default_type()) != 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
rescan ();
|
|
|
|
}
|
|
|
|
} else {
|
2006-08-11 03:15:30 -04:00
|
|
|
if (io->output_maximum().get(io->default_type()) != 0) {
|
2005-09-25 14:42:24 -04:00
|
|
|
rescan();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
PortInsertUI::PortInsertUI (Session& sess, boost::shared_ptr<PortInsert> pi)
|
2007-06-23 16:13:13 -04:00
|
|
|
: input_selector (sess, pi->io(), true),
|
|
|
|
output_selector (sess, pi->io(), false)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
hbox.pack_start (output_selector, true, true);
|
|
|
|
hbox.pack_start (input_selector, true, true);
|
|
|
|
|
|
|
|
|
|
|
|
pack_start (hbox);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortInsertUI::redisplay()
|
|
|
|
{
|
|
|
|
|
|
|
|
input_selector.redisplay();
|
|
|
|
output_selector.redisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortInsertUI::finished(IOSelector::Result r)
|
|
|
|
{
|
|
|
|
input_selector.Finished (r);
|
|
|
|
output_selector.Finished (r);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-07-27 21:08:57 -04:00
|
|
|
PortInsertWindow::PortInsertWindow (Session& sess, boost::shared_ptr<PortInsert> pi, bool can_cancel)
|
2005-09-25 14:42:24 -04:00
|
|
|
: ArdourDialog ("port insert dialog"),
|
2006-07-27 21:08:57 -04:00
|
|
|
_portinsertui (sess, pi),
|
2005-09-25 14:42:24 -04:00
|
|
|
ok_button (can_cancel ? _("OK"): _("Close")),
|
|
|
|
cancel_button (_("Cancel")),
|
|
|
|
rescan_button (_("Rescan"))
|
|
|
|
{
|
|
|
|
|
|
|
|
set_name ("IOSelectorWindow");
|
|
|
|
string title = _("ardour: ");
|
2006-07-27 21:08:57 -04:00
|
|
|
title += pi->name();
|
2005-09-25 14:42:24 -04:00
|
|
|
set_title (title);
|
|
|
|
|
|
|
|
ok_button.set_name ("IOSelectorButton");
|
|
|
|
cancel_button.set_name ("IOSelectorButton");
|
|
|
|
rescan_button.set_name ("IOSelectorButton");
|
|
|
|
|
|
|
|
button_box.set_spacing (5);
|
|
|
|
button_box.set_border_width (5);
|
|
|
|
button_box.set_homogeneous (true);
|
|
|
|
button_box.pack_start (rescan_button);
|
|
|
|
if (can_cancel) {
|
|
|
|
button_box.pack_start (cancel_button);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
cancel_button.hide();
|
|
|
|
}
|
|
|
|
button_box.pack_start (ok_button);
|
|
|
|
|
2006-03-05 05:24:31 -05:00
|
|
|
get_vbox()->pack_start (_portinsertui);
|
|
|
|
get_vbox()->pack_start (button_box, false, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-09-25 17:19:23 -04:00
|
|
|
ok_button.signal_clicked().connect (mem_fun(*this, &PortInsertWindow::accept));
|
|
|
|
cancel_button.signal_clicked().connect (mem_fun(*this, &PortInsertWindow::cancel));
|
|
|
|
rescan_button.signal_clicked().connect (mem_fun(*this, &PortInsertWindow::rescan));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), reinterpret_cast<Window *> (this)));
|
2007-04-12 19:20:37 -04:00
|
|
|
|
|
|
|
going_away_connection = pi->GoingAway.connect (mem_fun(*this, &PortInsertWindow::plugin_going_away));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2006-08-29 17:21:48 -04:00
|
|
|
PortInsertWindow::plugin_going_away ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-29 17:21:48 -04:00
|
|
|
ENSURE_GUI_THREAD(mem_fun(*this, &PortInsertWindow::plugin_going_away));
|
2007-04-12 19:20:37 -04:00
|
|
|
going_away_connection.disconnect ();
|
2005-09-25 14:42:24 -04:00
|
|
|
delete_when_idle (this);
|
|
|
|
}
|
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
void
|
|
|
|
PortInsertWindow::on_map ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
_portinsertui.redisplay ();
|
2005-10-31 19:56:09 -05:00
|
|
|
Window::on_map ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
PortInsertWindow::rescan ()
|
|
|
|
{
|
|
|
|
_portinsertui.redisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortInsertWindow::cancel ()
|
|
|
|
{
|
|
|
|
_portinsertui.finished(IOSelector::Cancelled);
|
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortInsertWindow::accept ()
|
|
|
|
{
|
|
|
|
_portinsertui.finished(IOSelector::Accepted);
|
|
|
|
hide ();
|
|
|
|
}
|