2005-09-25 14:42:24 -04:00
|
|
|
/*
|
2007-10-12 20:58:03 -04:00
|
|
|
Copyright (C) 2002-2007 Paul Davis
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
#include <gtkmm/messagedialog.h>
|
2007-10-10 14:37:13 -04:00
|
|
|
#include <glibmm/objectbase.h>
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm2ext/doi.h>
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
#include <ardour/port_insert.h>
|
|
|
|
#include "ardour/session.h"
|
|
|
|
#include "ardour/io.h"
|
|
|
|
#include "ardour/audioengine.h"
|
2007-10-12 08:13:11 -04:00
|
|
|
#include "ardour/track.h"
|
2007-10-12 10:49:07 -04:00
|
|
|
#include "ardour/audio_track.h"
|
|
|
|
#include "ardour/midi_track.h"
|
|
|
|
#include "ardour/data_type.h"
|
2008-09-10 11:03:30 -04:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "io_selector.h"
|
2007-10-10 14:37:13 -04:00
|
|
|
#include "utils.h"
|
2005-09-25 14:42:24 -04:00
|
|
|
#include "gui_thread.h"
|
|
|
|
#include "i18n.h"
|
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
using namespace ARDOUR;
|
|
|
|
using namespace Gtk;
|
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
IOSelector::IOSelector (ARDOUR::Session& session, boost::shared_ptr<ARDOUR::IO> io, bool offer_inputs)
|
2008-12-14 04:35:23 -05:00
|
|
|
: PortMatrix (session, io->default_type(), offer_inputs,
|
|
|
|
PortGroupList::Mask (PortGroupList::BUSS |
|
|
|
|
PortGroupList::SYSTEM |
|
|
|
|
PortGroupList::OTHER))
|
|
|
|
, _io (io)
|
2007-10-12 20:58:03 -04:00
|
|
|
{
|
2008-12-14 04:35:23 -05:00
|
|
|
list<string> our_ports;
|
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
/* Listen for ports changing on the IO */
|
2008-05-21 19:01:40 -04:00
|
|
|
if (_offer_inputs) {
|
2007-10-19 09:30:07 -04:00
|
|
|
_io->output_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
|
2008-12-14 04:35:23 -05:00
|
|
|
|
|
|
|
const PortSet& ps (_io->outputs());
|
|
|
|
|
|
|
|
for (PortSet::const_iterator i = ps.begin(); i != ps.end(); ++i) {
|
|
|
|
our_ports.push_back ((*i).name());
|
|
|
|
}
|
|
|
|
|
2008-09-29 09:34:35 -04:00
|
|
|
} else {
|
|
|
|
_io->input_changed.connect (mem_fun(*this, &IOSelector::ports_changed));
|
2008-12-14 04:35:23 -05:00
|
|
|
|
|
|
|
const PortSet& ps (_io->inputs());
|
|
|
|
|
|
|
|
for (PortSet::const_iterator i = ps.begin(); i != ps.end(); ++i) {
|
|
|
|
our_ports.push_back ((*i).name());
|
|
|
|
}
|
|
|
|
|
2007-10-12 20:58:03 -04:00
|
|
|
}
|
2008-12-14 04:35:23 -05:00
|
|
|
|
|
|
|
set_ports (our_ports);
|
2008-09-10 11:03:30 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-10-31 19:56:09 -05:00
|
|
|
void
|
2007-10-19 09:30:07 -04:00
|
|
|
IOSelector::ports_changed (ARDOUR::IOChange change, void *src)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-10-19 09:30:07 -04:00
|
|
|
ENSURE_GUI_THREAD (bind (mem_fun (*this, &IOSelector::ports_changed), change, src));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
redisplay ();
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
void
|
2008-10-07 18:24:00 -04:00
|
|
|
IOSelector::set_state (int r, std::string const & p, bool s, uint32_t keymod)
|
2007-10-10 14:37:13 -04:00
|
|
|
{
|
2007-10-19 09:30:07 -04:00
|
|
|
if (s) {
|
2008-05-22 22:13:31 -04:00
|
|
|
if (!_offer_inputs) {
|
2007-10-19 09:30:07 -04:00
|
|
|
_io->connect_input (_io->input(r), p, 0);
|
|
|
|
} else {
|
|
|
|
_io->connect_output (_io->output(r), p, 0);
|
2008-10-07 18:24:00 -04:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!_offer_inputs) {
|
|
|
|
_io->disconnect_input (_io->input(r), p, 0);
|
|
|
|
} else {
|
|
|
|
_io->disconnect_output (_io->output(r), p, 0);
|
|
|
|
}
|
|
|
|
}
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-12 08:13:11 -04:00
|
|
|
bool
|
2007-10-19 09:30:07 -04:00
|
|
|
IOSelector::get_state (int r, std::string const & p) const
|
2007-10-10 14:37:13 -04:00
|
|
|
{
|
2007-10-31 14:24:43 -04:00
|
|
|
vector<string> connections;
|
|
|
|
|
|
|
|
if (_offer_inputs) {
|
2008-05-21 19:01:40 -04:00
|
|
|
_io->output(r)->get_connections (connections);
|
2008-05-22 22:13:31 -04:00
|
|
|
} else {
|
|
|
|
_io->input(r)->get_connections (connections);
|
2007-10-31 14:24:43 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
int k = 0;
|
2007-10-31 14:24:43 -04:00
|
|
|
for (vector<string>::iterator i = connections.begin(); i != connections.end(); ++i) {
|
|
|
|
|
|
|
|
if ((*i)== p) {
|
2007-10-19 09:30:07 -04:00
|
|
|
return true;
|
2007-10-12 08:13:11 -04:00
|
|
|
}
|
2007-10-31 14:24:43 -04:00
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
++k;
|
2007-10-13 06:38:26 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
return false;
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
uint32_t
|
|
|
|
IOSelector::n_rows () const
|
2007-10-10 14:37:13 -04:00
|
|
|
{
|
2008-05-22 22:13:31 -04:00
|
|
|
if (!_offer_inputs) {
|
2007-10-19 09:30:07 -04:00
|
|
|
return _io->inputs().num_ports (_io->default_type());
|
|
|
|
} else {
|
|
|
|
return _io->outputs().num_ports (_io->default_type());
|
2007-10-12 08:13:11 -04:00
|
|
|
}
|
2007-10-12 20:58:03 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
uint32_t
|
|
|
|
IOSelector::maximum_rows () const
|
2007-10-12 20:58:03 -04:00
|
|
|
{
|
2008-05-22 22:13:31 -04:00
|
|
|
if (!_offer_inputs) {
|
2007-10-19 09:30:07 -04:00
|
|
|
return _io->input_maximum ().get (_io->default_type());
|
|
|
|
} else {
|
|
|
|
return _io->output_maximum ().get (_io->default_type());
|
2005-10-31 19:56:09 -05:00
|
|
|
}
|
2007-10-12 20:58:03 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
uint32_t
|
|
|
|
IOSelector::minimum_rows () const
|
2007-10-12 20:58:03 -04:00
|
|
|
{
|
2008-05-22 22:13:31 -04:00
|
|
|
if (!_offer_inputs) {
|
2007-10-19 09:30:07 -04:00
|
|
|
return _io->input_minimum ().get (_io->default_type());
|
|
|
|
} else {
|
|
|
|
return _io->output_minimum ().get (_io->default_type());
|
2007-10-13 07:07:47 -04:00
|
|
|
}
|
2007-10-12 20:58:03 -04:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-19 09:30:07 -04:00
|
|
|
std::string
|
|
|
|
IOSelector::row_name (int r) const
|
2007-10-12 20:58:03 -04:00
|
|
|
{
|
2008-09-29 09:34:35 -04:00
|
|
|
string n;
|
|
|
|
string::size_type pos;
|
|
|
|
|
2008-05-22 22:13:31 -04:00
|
|
|
if (!_offer_inputs) {
|
2008-09-29 09:34:35 -04:00
|
|
|
n = _io->input(r)->short_name();
|
2007-10-12 20:58:03 -04:00
|
|
|
} else {
|
2008-09-29 09:34:35 -04:00
|
|
|
n = _io->output(r)->short_name();
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((pos = n.find ('/')) != string::npos) {
|
|
|
|
return n.substr (pos+1);
|
|
|
|
} else {
|
|
|
|
return n;
|
2006-11-19 11:45:16 -05:00
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-19 09:30:07 -04:00
|
|
|
IOSelector::add_row ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-11 03:15:30 -04:00
|
|
|
// The IO selector only works for single typed IOs
|
2007-10-12 20:58:03 -04:00
|
|
|
const ARDOUR::DataType t = _io->default_type ();
|
2006-08-11 03:15:30 -04:00
|
|
|
|
2008-05-22 22:13:31 -04:00
|
|
|
if (!_offer_inputs) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
try {
|
2007-10-10 14:37:13 -04:00
|
|
|
_io->add_input_port ("", this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
catch (AudioEngine::PortRegistrationFailure& err) {
|
|
|
|
MessageDialog msg (_("There are no more JACK ports available."));
|
2006-03-05 14:39:16 -05:00
|
|
|
msg.run ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
try {
|
2007-10-10 14:37:13 -04:00
|
|
|
_io->add_output_port ("", this);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-09-10 11:03:30 -04:00
|
|
|
catch (AudioEngine::PortRegistrationFailure& err) {
|
|
|
|
MessageDialog msg (_("There are no more JACK ports available."));
|
2006-03-05 14:39:16 -05:00
|
|
|
msg.run ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-19 09:30:07 -04:00
|
|
|
IOSelector::remove_row (int r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2006-08-11 03:15:30 -04:00
|
|
|
// The IO selector only works for single typed IOs
|
2007-10-12 20:58:03 -04:00
|
|
|
const ARDOUR::DataType t = _io->default_type ();
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2008-05-22 22:13:31 -04:00
|
|
|
if (!_offer_inputs) {
|
2007-10-12 20:58:03 -04:00
|
|
|
_io->remove_input_port (_io->input (r), this);
|
2007-10-10 14:37:13 -04:00
|
|
|
} else {
|
2007-10-12 20:58:03 -04:00
|
|
|
_io->remove_output_port (_io->output (r), this);
|
2005-10-31 19:56:09 -05:00
|
|
|
}
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2007-10-12 08:13:11 -04:00
|
|
|
std::string
|
2007-10-19 09:30:07 -04:00
|
|
|
IOSelector::row_descriptor () const
|
2007-10-12 08:13:11 -04:00
|
|
|
{
|
2007-10-19 09:30:07 -04:00
|
|
|
return _("port");
|
2007-10-12 08:13:11 -04:00
|
|
|
}
|
|
|
|
|
2008-12-14 04:35:23 -05:00
|
|
|
IOSelectorWindow::IOSelectorWindow (ARDOUR::Session& session, boost::shared_ptr<ARDOUR::IO> io, bool for_input, bool can_cancel)
|
|
|
|
: ArdourDialog ("I/O selector")
|
|
|
|
, _selector (session, io, !for_input)
|
|
|
|
, add_button (_("Add Port"))
|
|
|
|
, disconnect_button (_("Disconnect All"))
|
|
|
|
, ok_button (can_cancel ? _("OK"): _("Close"))
|
|
|
|
, cancel_button (_("Cancel"))
|
|
|
|
, rescan_button (_("Rescan"))
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
{
|
|
|
|
add_events (Gdk::KEY_PRESS_MASK | Gdk::KEY_RELEASE_MASK);
|
|
|
|
set_name ("IOSelectorWindow2");
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-10-01 05:18:30 -04:00
|
|
|
disconnect_button.set_name ("IOSelectorButton");
|
|
|
|
disconnect_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::DISCONNECT, Gtk::ICON_SIZE_BUTTON)));
|
|
|
|
get_action_area()->pack_start (disconnect_button, false, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2008-09-29 09:34:35 -04:00
|
|
|
if (_selector.maximum_rows() > _selector.n_rows()) {
|
|
|
|
add_button.set_name ("IOSelectorButton");
|
|
|
|
add_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::ADD, Gtk::ICON_SIZE_BUTTON)));
|
|
|
|
get_action_area()->pack_start (add_button, false, false);
|
|
|
|
add_button.signal_clicked().connect (sigc::mem_fun (_selector, &IOSelector::add_row));
|
2008-09-30 10:18:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!for_input) {
|
|
|
|
io->output_changed.connect (mem_fun(*this, &IOSelectorWindow::ports_changed));
|
2008-09-29 09:34:35 -04:00
|
|
|
} else {
|
2008-09-30 10:18:15 -04:00
|
|
|
io->input_changed.connect (mem_fun(*this, &IOSelectorWindow::ports_changed));
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2008-09-29 09:34:35 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
rescan_button.set_name ("IOSelectorButton");
|
|
|
|
rescan_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::REFRESH, Gtk::ICON_SIZE_BUTTON)));
|
|
|
|
get_action_area()->pack_start (rescan_button, false, false);
|
|
|
|
|
|
|
|
if (can_cancel) {
|
2008-09-29 09:34:35 -04:00
|
|
|
cancel_button.set_name ("IOSelectorButton");
|
2007-10-10 14:37:13 -04:00
|
|
|
cancel_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CANCEL, Gtk::ICON_SIZE_BUTTON)));
|
|
|
|
get_action_area()->pack_start (cancel_button, false, false);
|
|
|
|
} else {
|
|
|
|
cancel_button.hide();
|
|
|
|
}
|
|
|
|
|
2008-09-29 09:34:35 -04:00
|
|
|
ok_button.set_name ("IOSelectorButton");
|
|
|
|
if (!can_cancel) {
|
|
|
|
ok_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON)));
|
|
|
|
}
|
2007-10-10 14:37:13 -04:00
|
|
|
get_action_area()->pack_start (ok_button, false, false);
|
2005-10-31 19:56:09 -05:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
get_vbox()->set_spacing (8);
|
|
|
|
get_vbox()->pack_start (_selector);
|
|
|
|
|
2008-10-01 05:18:30 -04:00
|
|
|
suggestion.set_alignment (0.5, 0.5);
|
|
|
|
suggestion_box.pack_start (suggestion, true, true);
|
|
|
|
get_vbox()->pack_start (suggestion_box);
|
|
|
|
|
2007-10-10 14:37:13 -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));
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
set_position (Gtk::WIN_POS_MOUSE);
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2008-09-30 10:18:15 -04:00
|
|
|
io_name_changed (this);
|
|
|
|
ports_changed (IOChange (0), this);
|
2008-10-01 05:18:30 -04:00
|
|
|
leave_scroller ((GdkEventCrossing*) 0);
|
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
show_all ();
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2008-09-30 10:18:15 -04:00
|
|
|
signal_delete_event().connect (bind (sigc::ptr_fun (just_hide_it), this));
|
2008-10-01 05:18:30 -04:00
|
|
|
|
|
|
|
_selector.scrolled_window().add_events (Gdk::ENTER_NOTIFY_MASK|Gdk::LEAVE_NOTIFY_MASK);
|
2008-10-07 18:24:00 -04:00
|
|
|
_selector.scrolled_window().signal_enter_notify_event().connect (mem_fun (*this, &IOSelectorWindow::enter_scroller), false);
|
|
|
|
_selector.scrolled_window().signal_leave_notify_event().connect (mem_fun (*this, &IOSelectorWindow::leave_scroller), false);
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
IOSelectorWindow::~IOSelectorWindow()
|
|
|
|
{
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2008-10-01 05:18:30 -04:00
|
|
|
bool
|
|
|
|
IOSelectorWindow::enter_scroller (GdkEventCrossing* ignored)
|
|
|
|
{
|
|
|
|
cerr << "IN\n";
|
|
|
|
suggestion.set_text (_("Click to connect. Ctrl-click to disconnect. Shift-click for cross-connect"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
IOSelectorWindow::leave_scroller (GdkEventCrossing* ignored)
|
|
|
|
{
|
2008-10-07 18:24:00 -04:00
|
|
|
cerr << "OUT, ev = " << ignored << "\n";
|
2008-10-01 05:18:30 -04:00
|
|
|
suggestion.set_text (_("Right-click on individual port names for per-port operations"));
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-09-30 10:18:15 -04:00
|
|
|
void
|
|
|
|
IOSelectorWindow::ports_changed (ARDOUR::IOChange change, void *src)
|
|
|
|
{
|
|
|
|
if (_selector.maximum_rows() > _selector.n_rows()) {
|
|
|
|
add_button.set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
add_button.set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
void
|
|
|
|
IOSelectorWindow::rescan ()
|
|
|
|
{
|
|
|
|
_selector.redisplay ();
|
|
|
|
}
|
2006-11-19 11:45:16 -05:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
void
|
|
|
|
IOSelectorWindow::cancel ()
|
|
|
|
{
|
|
|
|
_selector.Finished (IOSelector::Cancelled);
|
|
|
|
hide ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-10 14:37:13 -04:00
|
|
|
IOSelectorWindow::accept ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2007-10-10 14:37:13 -04:00
|
|
|
_selector.Finished (IOSelector::Accepted);
|
|
|
|
hide ();
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
void
|
|
|
|
IOSelectorWindow::on_map ()
|
|
|
|
{
|
|
|
|
_selector.redisplay ();
|
|
|
|
Window::on_map ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2008-09-30 10:18:15 -04:00
|
|
|
void
|
|
|
|
IOSelectorWindow::io_name_changed (void* src)
|
|
|
|
{
|
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &IOSelectorWindow::io_name_changed), src));
|
|
|
|
|
|
|
|
string title;
|
|
|
|
|
|
|
|
if (!_selector.offering_input()) {
|
|
|
|
title = string_compose(_("%1 input"), _selector.io()->name());
|
|
|
|
} else {
|
|
|
|
title = string_compose(_("%1 output"), _selector.io()->name());
|
|
|
|
}
|
|
|
|
|
|
|
|
set_title (title);
|
|
|
|
}
|
2007-10-10 14:37:13 -04:00
|
|
|
|
|
|
|
PortInsertUI::PortInsertUI (ARDOUR::Session& sess, boost::shared_ptr<ARDOUR::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
|
2007-10-10 14:37:13 -04:00
|
|
|
PortInsertUI::redisplay ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
input_selector.redisplay();
|
|
|
|
output_selector.redisplay();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2007-10-10 14:37:13 -04:00
|
|
|
PortInsertUI::finished (IOSelector::Result r)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
input_selector.Finished (r);
|
|
|
|
output_selector.Finished (r);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
PortInsertWindow::PortInsertWindow (ARDOUR::Session& sess, boost::shared_ptr<ARDOUR::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");
|
2007-10-10 14:37:13 -04:00
|
|
|
if (!can_cancel) {
|
|
|
|
ok_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CLOSE, Gtk::ICON_SIZE_BUTTON)));
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
cancel_button.set_name ("IOSelectorButton");
|
|
|
|
rescan_button.set_name ("IOSelectorButton");
|
2007-10-10 14:37:13 -04:00
|
|
|
rescan_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::REFRESH, Gtk::ICON_SIZE_BUTTON)));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-10 14:37:13 -04:00
|
|
|
get_action_area()->pack_start (rescan_button, false, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
if (can_cancel) {
|
2007-10-10 14:37:13 -04:00
|
|
|
cancel_button.set_image (*Gtk::manage (new Gtk::Image (Gtk::Stock::CANCEL, Gtk::ICON_SIZE_BUTTON)));
|
|
|
|
get_action_area()->pack_start (cancel_button, false, false);
|
|
|
|
} else {
|
2005-09-25 14:42:24 -04:00
|
|
|
cancel_button.hide();
|
|
|
|
}
|
2007-10-10 14:37:13 -04:00
|
|
|
get_action_area()->pack_start (ok_button, false, false);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2006-03-05 05:24:31 -05:00
|
|
|
get_vbox()->pack_start (_portinsertui);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2007-10-10 14:37:13 -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
|
|
|
|
2007-10-10 14:37:13 -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
|
|
|
{
|
2007-10-10 14:37:13 -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 ()
|
|
|
|
{
|
2007-10-10 14:37:13 -04:00
|
|
|
_portinsertui.redisplay ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortInsertWindow::cancel ()
|
|
|
|
{
|
2007-10-10 14:37:13 -04:00
|
|
|
_portinsertui.finished (IOSelector::Cancelled);
|
2005-09-25 14:42:24 -04:00
|
|
|
hide ();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PortInsertWindow::accept ()
|
|
|
|
{
|
2007-10-10 14:37:13 -04:00
|
|
|
_portinsertui.finished (IOSelector::Accepted);
|
2005-09-25 14:42:24 -04:00
|
|
|
hide ();
|
|
|
|
}
|