2005-09-25 14:42:24 -04:00
|
|
|
/*
|
|
|
|
Copyright (C) 2000 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 <cstdio>
|
|
|
|
#include <lrdf.h>
|
|
|
|
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm/table.h>
|
2005-11-27 12:59:03 -05:00
|
|
|
#include <gtkmm/stock.h>
|
2005-09-25 16:33:00 -04:00
|
|
|
#include <gtkmm/button.h>
|
|
|
|
#include <gtkmm/notebook.h>
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
#include <ardour/plugin_manager.h>
|
|
|
|
#include <ardour/plugin.h>
|
|
|
|
#include <ardour/configuration.h>
|
|
|
|
|
|
|
|
#include "ardour_ui.h"
|
|
|
|
#include "plugin_selector.h"
|
|
|
|
#include "gui_thread.h"
|
|
|
|
|
|
|
|
#include "i18n.h"
|
|
|
|
|
|
|
|
using namespace ARDOUR;
|
2005-11-27 12:59:03 -05:00
|
|
|
using namespace Gtk;
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
PluginSelector::PluginSelector (PluginManager *mgr)
|
2005-12-02 14:18:26 -05:00
|
|
|
: ArdourDialog (_("ardour: plugins"), true, false)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-09-25 16:33:00 -04:00
|
|
|
set_position (Gtk::WIN_POS_MOUSE);
|
2005-09-25 14:42:24 -04:00
|
|
|
set_name ("PluginSelectorWindow");
|
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
|
|
|
|
|
|
|
manager = mgr;
|
|
|
|
session = 0;
|
|
|
|
o_selected_plug = -1;
|
|
|
|
i_selected_plug = 0;
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
lmodel = Gtk::ListStore::create(lcols);
|
|
|
|
ladspa_display.set_model (lmodel);
|
2006-04-19 16:42:17 -04:00
|
|
|
ladspa_display.append_column (_("Available LADSPA Plugins"), lcols.name);
|
2005-11-22 00:10:12 -05:00
|
|
|
ladspa_display.append_column (_("Type"), lcols.type);
|
|
|
|
ladspa_display.append_column (_("# Inputs"),lcols.ins);
|
|
|
|
ladspa_display.append_column (_("# Outputs"), lcols.outs);
|
|
|
|
ladspa_display.set_headers_visible (true);
|
|
|
|
ladspa_display.set_reorderable (false);
|
2005-12-02 14:18:26 -05:00
|
|
|
lscroller.set_border_width(10);
|
|
|
|
lscroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
|
|
|
lscroller.add(ladspa_display);
|
2005-11-22 00:10:12 -05:00
|
|
|
|
|
|
|
amodel = Gtk::ListStore::create(acols);
|
|
|
|
added_list.set_model (amodel);
|
2006-04-22 11:28:59 -04:00
|
|
|
added_list.append_column (_("Plugins to be Connected to Insert"), acols.text);
|
2005-11-22 00:10:12 -05:00
|
|
|
added_list.set_headers_visible (true);
|
|
|
|
added_list.set_reorderable (false);
|
|
|
|
|
|
|
|
for (int i = 0; i <=3; i++) {
|
|
|
|
Gtk::TreeView::Column* column = ladspa_display.get_column(i);
|
|
|
|
column->set_sort_column(i);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
vmodel = ListStore::create(vcols);
|
|
|
|
vst_display.set_model (vmodel);
|
|
|
|
vst_display.append_column (_("Available plugins"), vcols.name);
|
|
|
|
vst_display.append_column (_("# Inputs"), vcols.ins);
|
|
|
|
vst_display.append_column (_("# Outputs"), vcols.outs);
|
|
|
|
vst_display.set_headers_visible (true);
|
|
|
|
vst_display.set_reorderable (false);
|
2005-12-02 14:18:26 -05:00
|
|
|
vscroller.set_border_width(10);
|
|
|
|
vscroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
|
|
|
vscroller.add(vst_display);
|
2005-11-22 00:10:12 -05:00
|
|
|
|
|
|
|
for (int i = 0; i <=2; i++) {
|
2006-01-11 01:10:07 -05:00
|
|
|
Gtk::TreeView::Column* column = vst_display.get_column(i);
|
2005-11-22 00:10:12 -05:00
|
|
|
column->set_sort_column(i);
|
|
|
|
}
|
|
|
|
#endif
|
2005-12-06 02:59:46 -05:00
|
|
|
ascroller.set_border_width(10);
|
|
|
|
ascroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
|
|
|
|
ascroller.add(added_list);
|
2006-04-26 12:04:04 -04:00
|
|
|
btn_add = manage(new Gtk::Button(Stock::ADD));
|
2005-09-25 14:42:24 -04:00
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip(*btn_add, _("Add a plugin to the effect list"));
|
2006-04-26 12:04:04 -04:00
|
|
|
btn_add->set_sensitive (false);
|
|
|
|
btn_remove = manage(new Gtk::Button(Stock::REMOVE));
|
|
|
|
btn_remove->set_sensitive (false);
|
2005-09-25 14:42:24 -04:00
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip(*btn_remove, _("Remove a plugin from the effect list"));
|
2006-04-19 16:42:17 -04:00
|
|
|
Gtk::Button *btn_update = manage(new Gtk::Button(Stock::REFRESH));
|
2005-09-25 14:42:24 -04:00
|
|
|
ARDOUR_UI::instance()->tooltips().set_tip(*btn_update, _("Update available plugins"));
|
|
|
|
|
|
|
|
btn_add->set_name("PluginSelectorButton");
|
|
|
|
btn_remove->set_name("PluginSelectorButton");
|
2005-12-02 14:18:26 -05:00
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
Gtk::Table* table = manage(new Gtk::Table(7, 10));
|
2005-09-25 16:33:00 -04:00
|
|
|
table->set_size_request(750, 500);
|
2005-09-25 14:42:24 -04:00
|
|
|
table->attach(notebook, 0, 7, 0, 5);
|
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
table->attach(*btn_add, 1, 2, 5, 6, Gtk::FILL, Gtk::FILL, 5, 5);
|
|
|
|
table->attach(*btn_remove, 3, 4, 5, 6, Gtk::FILL, Gtk::FILL, 5, 5);
|
|
|
|
table->attach(*btn_update, 5, 6, 5, 6, Gtk::FILL, Gtk::FILL, 5, 5);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-12-06 02:59:46 -05:00
|
|
|
table->attach(ascroller, 0, 7, 7, 9);
|
2005-11-27 12:59:03 -05:00
|
|
|
|
|
|
|
add_button (Stock::CANCEL, RESPONSE_CANCEL);
|
2006-04-22 11:28:59 -04:00
|
|
|
add_button (Stock::CONNECT, RESPONSE_APPLY);
|
2006-04-19 16:42:17 -04:00
|
|
|
set_default_response (RESPONSE_APPLY);
|
2006-04-26 12:04:04 -04:00
|
|
|
set_response_sensitive (RESPONSE_APPLY, false);
|
2005-11-27 12:59:03 -05:00
|
|
|
get_vbox()->pack_start (*table);
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
using namespace Gtk::Notebook_Helpers;
|
2005-12-02 14:18:26 -05:00
|
|
|
notebook.pages().push_back (TabElem (lscroller, _("LADSPA")));
|
2005-09-25 14:42:24 -04:00
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
if (Config->get_use_vst()) {
|
2005-12-02 14:18:26 -05:00
|
|
|
notebook.pages().push_back (TabElem (vscroller, _("VST")));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
table->set_name("PluginSelectorTable");
|
2006-04-19 16:42:17 -04:00
|
|
|
ladspa_display.set_name("PluginSelectorDisplay");
|
|
|
|
//ladspa_display.set_name("PluginSelectorList");
|
2005-11-22 00:10:12 -05:00
|
|
|
added_list.set_name("PluginSelectorList");
|
2005-09-25 14:42:24 -04:00
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
ladspa_display.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::row_clicked));
|
2005-09-25 14:42:24 -04:00
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
if (Config->get_use_vst()) {
|
2005-11-22 00:10:12 -05:00
|
|
|
vst_display.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::row_clicked));
|
2006-04-26 12:04:04 -04:00
|
|
|
vst_display.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::vst_display_selection_changed));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
#endif
|
2005-11-22 00:10:12 -05:00
|
|
|
|
2005-10-09 01:03:29 -04:00
|
|
|
btn_update->signal_clicked().connect (mem_fun(*this, &PluginSelector::btn_update_clicked));
|
2005-11-22 00:10:12 -05:00
|
|
|
btn_add->signal_clicked().connect(mem_fun(*this, &PluginSelector::btn_add_clicked));
|
2005-10-09 01:03:29 -04:00
|
|
|
btn_remove->signal_clicked().connect(mem_fun(*this, &PluginSelector::btn_remove_clicked));
|
2006-04-26 12:04:04 -04:00
|
|
|
ladspa_display.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::ladspa_display_selection_changed));
|
|
|
|
added_list.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::added_list_selection_changed));
|
2005-12-02 14:18:26 -05:00
|
|
|
|
|
|
|
input_refiller ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
void
|
|
|
|
PluginSelector::row_clicked(GdkEventButton* event)
|
|
|
|
{
|
|
|
|
if (event->type == GDK_2BUTTON_PRESS)
|
|
|
|
btn_add_clicked();
|
|
|
|
}
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
void
|
|
|
|
PluginSelector::set_session (Session* s)
|
|
|
|
{
|
2005-09-25 17:19:23 -04:00
|
|
|
ENSURE_GUI_THREAD(bind (mem_fun(*this, &PluginSelector::set_session), s));
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
session = s;
|
|
|
|
|
|
|
|
if (session) {
|
2005-09-25 17:19:23 -04:00
|
|
|
session->going_away.connect (bind (mem_fun(*this, &PluginSelector::set_session), static_cast<Session*> (0)));
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-22 00:10:12 -05:00
|
|
|
PluginSelector::_input_refiller (void *arg)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-12-02 14:18:26 -05:00
|
|
|
((PluginSelector *) arg)->input_refiller ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int compare(const void *left, const void *right)
|
|
|
|
{
|
|
|
|
return strcmp(*((char**)left), *((char**)right));
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-22 00:10:12 -05:00
|
|
|
PluginSelector::input_refiller ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
guint row;
|
|
|
|
list<PluginInfo *> &plugs = manager->ladspa_plugin_info ();
|
|
|
|
list<PluginInfo *>::iterator i;
|
|
|
|
char ibuf[16], obuf[16];
|
2005-12-02 14:18:26 -05:00
|
|
|
lmodel->clear();
|
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
vmodel->clear();
|
|
|
|
#endif
|
2005-09-25 14:42:24 -04:00
|
|
|
// Insert into GTK list
|
|
|
|
for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
|
|
|
|
snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
|
|
|
|
snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs);
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
Gtk::TreeModel::Row newrow = *(lmodel->append());
|
|
|
|
newrow[lcols.name] = (*i)->name.c_str();
|
|
|
|
newrow[lcols.type] = (*i)->category.c_str();
|
|
|
|
newrow[lcols.ins] = ibuf;
|
|
|
|
newrow[lcols.outs] = obuf;
|
|
|
|
newrow[lcols.plugin] = *i;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-12-02 14:18:26 -05:00
|
|
|
lmodel->set_sort_column (0, Gtk::SORT_ASCENDING);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
|
|
|
|
void
|
2005-11-22 00:10:12 -05:00
|
|
|
PluginSelector::_vst_refiller (void *arg)
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-22 00:10:12 -05:00
|
|
|
((PluginSelector *) arg)->vst_refiller ();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-22 00:10:12 -05:00
|
|
|
PluginSelector::vst_refiller ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
guint row;
|
|
|
|
list<PluginInfo *> &plugs = manager->vst_plugin_info ();
|
|
|
|
list<PluginInfo *>::iterator i;
|
|
|
|
char ibuf[16], obuf[16];
|
|
|
|
|
|
|
|
// Insert into GTK list
|
2005-11-22 00:10:12 -05:00
|
|
|
for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
|
2005-09-25 14:42:24 -04:00
|
|
|
|
|
|
|
snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
|
|
|
|
snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs);
|
|
|
|
|
2005-11-22 00:10:12 -05:00
|
|
|
Gtk::TreeModel::Row newrow = *(vmodel->append());
|
|
|
|
newrow[vcols.name] = (*i)->name.c_str();
|
|
|
|
newrow[vcols.ins] = ibuf;
|
|
|
|
newrow[vcols.outs] = obuf;
|
2006-01-11 01:47:28 -05:00
|
|
|
newrow[vcols.plugin] = *i;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-12-02 14:18:26 -05:00
|
|
|
vmodel->set_sort_column (0, Gtk::SORT_ASCENDING);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginSelector::use_plugin (PluginInfo* pi)
|
|
|
|
{
|
|
|
|
list<PluginInfo *>::iterator i;
|
|
|
|
|
|
|
|
if (pi == 0 || session == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Plugin *plugin = manager->load (*session, pi);
|
|
|
|
|
|
|
|
if (plugin) {
|
|
|
|
PluginCreated (plugin);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginSelector::btn_add_clicked()
|
|
|
|
{
|
2005-11-22 00:10:12 -05:00
|
|
|
bool vst = notebook.get_current_page(); // 0 = LADSPA, 1 = VST
|
|
|
|
std::string name;
|
|
|
|
ARDOUR::PluginInfo *pi;
|
|
|
|
Gtk::TreeModel::Row newrow = *(amodel->append());
|
|
|
|
|
|
|
|
if (vst) {
|
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
Gtk::TreeModel::Row row = *(vst_display.get_selection()->get_selected());
|
|
|
|
name = row[vcols.name];
|
|
|
|
pi = row[vcols.plugin];
|
|
|
|
added_plugins.push_back (row[vcols.plugin]);
|
|
|
|
#endif
|
|
|
|
} else {
|
|
|
|
Gtk::TreeModel::Row row = *(ladspa_display.get_selection()->get_selected());
|
|
|
|
name = row[lcols.name];
|
|
|
|
pi = row[lcols.plugin];
|
|
|
|
added_plugins.push_back (row[lcols.plugin]);
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
2005-11-22 00:10:12 -05:00
|
|
|
newrow[acols.text] = name;
|
|
|
|
newrow[acols.plugin] = pi;
|
2006-04-26 12:04:04 -04:00
|
|
|
|
|
|
|
if (!amodel->children().empty()) {
|
|
|
|
set_response_sensitive (RESPONSE_APPLY, true);
|
|
|
|
}
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginSelector::btn_remove_clicked()
|
|
|
|
{
|
2005-12-05 07:07:34 -05:00
|
|
|
list<PluginInfo*>::iterator i;
|
|
|
|
Gtk::TreeModel::iterator iter = added_list.get_selection()->get_selected();
|
|
|
|
for (i = added_plugins.begin(); (*i) != (*iter)[acols.plugin]; ++i);
|
|
|
|
|
|
|
|
added_plugins.erase(i);
|
|
|
|
amodel->erase(iter);
|
2006-04-26 12:04:04 -04:00
|
|
|
if (amodel->children().empty()) {
|
|
|
|
set_response_sensitive (RESPONSE_APPLY, false);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-27 12:59:03 -05:00
|
|
|
void
|
|
|
|
PluginSelector::btn_update_clicked()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
2005-11-27 12:59:03 -05:00
|
|
|
manager->refresh ();
|
|
|
|
input_refiller ();
|
|
|
|
}
|
|
|
|
|
2006-04-26 12:04:04 -04:00
|
|
|
#ifdef VST_SUPPORT
|
|
|
|
void
|
|
|
|
PluginSelector::vst_display_selection_changed()
|
|
|
|
{
|
|
|
|
if (vst_display.get_selection()->count_selected_rows() != 0) {
|
|
|
|
btn_add->set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
btn_add->set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginSelector::ladspa_display_selection_changed()
|
|
|
|
{
|
|
|
|
if (ladspa_display.get_selection()->count_selected_rows() != 0) {
|
|
|
|
btn_add->set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
btn_add->set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
PluginSelector::added_list_selection_changed()
|
|
|
|
{
|
|
|
|
if (added_list.get_selection()->count_selected_rows() != 0) {
|
|
|
|
btn_remove->set_sensitive (true);
|
|
|
|
} else {
|
|
|
|
btn_remove->set_sensitive (false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-11-27 12:59:03 -05:00
|
|
|
int
|
|
|
|
PluginSelector::run ()
|
|
|
|
{
|
|
|
|
ResponseType r;
|
2005-09-25 14:42:24 -04:00
|
|
|
list<PluginInfo*>::iterator i;
|
|
|
|
|
2005-11-27 12:59:03 -05:00
|
|
|
r = (ResponseType) Dialog::run ();
|
|
|
|
|
|
|
|
switch (r) {
|
2006-04-19 16:42:17 -04:00
|
|
|
case RESPONSE_APPLY:
|
2005-11-27 12:59:03 -05:00
|
|
|
for (i = added_plugins.begin(); i != added_plugins.end(); ++i){
|
|
|
|
use_plugin (*i);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
2005-11-27 12:59:03 -05:00
|
|
|
cleanup ();
|
|
|
|
|
|
|
|
return (int) r;
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2005-11-27 12:59:03 -05:00
|
|
|
PluginSelector::cleanup ()
|
2005-09-25 14:42:24 -04:00
|
|
|
{
|
|
|
|
hide();
|
|
|
|
added_plugins.clear();
|
2006-02-18 16:10:48 -05:00
|
|
|
amodel->clear();
|
2005-09-25 14:42:24 -04:00
|
|
|
}
|
|
|
|
|