extend filtering to VST + AU, tweak details, add filter-by-creator and by library

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2200 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-07-31 16:03:53 +00:00
parent e57dd28f33
commit 84b45aefde
4 changed files with 86 additions and 74 deletions

View file

@ -47,15 +47,16 @@ using namespace Gtk;
using namespace std; using namespace std;
static const char* _filter_mode_strings[] = { static const char* _filter_mode_strings[] = {
N_("Plugin name"), N_("Name contains"),
N_("Plugin type"), N_("Type contains"),
N_("Plugin creator"), N_("Author contains"),
N_("Library contains"),
0 0
}; };
PluginSelector::PluginSelector (PluginManager *mgr) PluginSelector::PluginSelector (PluginManager *mgr)
: ArdourDialog (_("ardour: plugins"), true, false), : ArdourDialog (_("ardour: plugins"), true, false),
filter_button (_("Clear")) filter_button (Stock::CLEAR)
{ {
set_position (Gtk::WIN_POS_MOUSE); set_position (Gtk::WIN_POS_MOUSE);
set_name ("PluginSelectorWindow"); set_name ("PluginSelectorWindow");
@ -81,7 +82,7 @@ PluginSelector::PluginSelector (PluginManager *mgr)
amodel = Gtk::ListStore::create(acols); amodel = Gtk::ListStore::create(acols);
added_list.set_model (amodel); added_list.set_model (amodel);
added_list.append_column (_("Plugins to be Connected to Insert"), acols.text); added_list.append_column (_("Plugins to be connected"), acols.text);
added_list.set_headers_visible (true); added_list.set_headers_visible (true);
added_list.set_reorderable (false); added_list.set_reorderable (false);
@ -170,7 +171,7 @@ PluginSelector::PluginSelector (PluginManager *mgr)
table->attach(*btn_add, 1, 2, 6, 7, FILL, FILL, 5, 5); table->attach(*btn_add, 1, 2, 6, 7, FILL, FILL, 5, 5);
table->attach(*btn_remove, 3, 4, 6, 7, FILL, FILL, 5, 5); table->attach(*btn_remove, 3, 4, 6, 7, FILL, FILL, 5, 5);
table->attach(*btn_update, 5, 6, 7, 8, FILL, FILL, 5, 5); table->attach(*btn_update, 5, 6, 6, 7, FILL, FILL, 5, 5);
table->attach(ascroller, 0, 7, 8, 10); table->attach(ascroller, 0, 7, 8, 10);
@ -288,6 +289,44 @@ PluginSelector::set_session (Session* s)
} }
} }
bool
PluginSelector::show_this_plugin (PluginInfoPtr& info, const std::string& filterstr)
{
std::string compstr;
std::string mode = filter_mode.get_active_text ();
if (!filterstr.empty()) {
if (mode == _("Name contains")) {
compstr = info->name;
} else if (mode == _("Type contains")) {
compstr = info->category;
} else if (mode == _("Author contains")) {
compstr = info->creator;
} else if (mode == _("Library contains")) {
compstr = info->path;
}
transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
if (compstr.find (filterstr) != string::npos) {
return true;
} else {
return false;
}
}
return true;
}
void
PluginSelector::setup_filter_string (string& filterstr)
{
filterstr = filter_entry.get_text ();
transform (filterstr.begin(), filterstr.end(), filterstr.begin(), ::toupper);
}
void void
PluginSelector::ladspa_refiller () PluginSelector::ladspa_refiller ()
{ {
@ -298,44 +337,15 @@ PluginSelector::ladspa_refiller ()
lmodel->clear(); lmodel->clear();
string mode = filter_mode.get_active_text (); std::string filterstr;
std::string compstr; setup_filter_string (filterstr);
std::string filterstr = filter_entry.get_text ();
transform (filterstr.begin(), filterstr.end(), filterstr.begin(), ::toupper);
// Insert into GTK list
for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) { for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
if (show_this_plugin (*i, filterstr)) {
snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs); snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs); snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs);
bool add;
add = false;
if (!filterstr.empty()) {
if (mode == _("Plugin name")) {
compstr = (*i)->name;
} else if (mode == _("Plugin type")) {
compstr = (*i)->category;
} else if (mode == _("Plugin creator")) {
compstr == "foo";
}
transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
if (compstr.find (filterstr) != string::npos) {
add = true;
}
} else {
add = true;
}
if (add) {
TreeModel::Row newrow = *(lmodel->append()); TreeModel::Row newrow = *(lmodel->append());
newrow[lcols.name] = (*i)->name.c_str(); newrow[lcols.name] = (*i)->name.c_str();
newrow[lcols.type] = (*i)->category.c_str(); newrow[lcols.type] = (*i)->category.c_str();
@ -350,12 +360,6 @@ PluginSelector::ladspa_refiller ()
#ifdef VST_SUPPORT #ifdef VST_SUPPORT
void
PluginSelector::_vst_refiller (void *arg)
{
((PluginSelector *) arg)->vst_refiller ();
}
void void
PluginSelector::vst_refiller () PluginSelector::vst_refiller ()
{ {
@ -365,9 +369,12 @@ PluginSelector::vst_refiller ()
char ibuf[16], obuf[16]; char ibuf[16], obuf[16];
vmodel->clear(); vmodel->clear();
// Insert into GTK list std::string filterstr;
setup_filter_string (filterstr);
for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) { for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
if (show_this_plugin (*i, filterstr)) {
snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs); snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs); snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs);
@ -377,6 +384,7 @@ PluginSelector::vst_refiller ()
newrow[vcols.outs] = obuf; newrow[vcols.outs] = obuf;
newrow[vcols.plugin] = *i; newrow[vcols.plugin] = *i;
} }
}
vmodel->set_sort_column (0, SORT_ASCENDING); vmodel->set_sort_column (0, SORT_ASCENDING);
} }
@ -396,12 +404,6 @@ PluginSelector::vst_display_selection_changed()
#ifdef HAVE_AUDIOUNIT #ifdef HAVE_AUDIOUNIT
void
PluginSelector::_au_refiller (void *arg)
{
((PluginSelector *) arg)->au_refiller ();
}
void void
PluginSelector::au_refiller () PluginSelector::au_refiller ()
{ {
@ -411,9 +413,13 @@ PluginSelector::au_refiller ()
char ibuf[16], obuf[16]; char ibuf[16], obuf[16];
aumodel->clear(); aumodel->clear();
// Insert into GTK list std::string filterstr;
setup_filter_string (filterstr);
for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) { for (row = 0, i=plugs.begin(); i != plugs.end(); ++i, ++row) {
if (show_this_plugin (*i, filterstr)) {
snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs); snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs); snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs);
@ -423,6 +429,8 @@ PluginSelector::au_refiller ()
newrow[aucols.outs] = obuf; newrow[aucols.outs] = obuf;
newrow[aucols.plugin] = *i; newrow[aucols.plugin] = *i;
} }
}
aumodel->set_sort_column (0, SORT_ASCENDING); aumodel->set_sort_column (0, SORT_ASCENDING);
} }

View file

@ -113,7 +113,6 @@ class PluginSelector : public ArdourDialog
Glib::RefPtr<Gtk::ListStore> vmodel; Glib::RefPtr<Gtk::ListStore> vmodel;
Glib::RefPtr<Gtk::TreeSelection> vselection; Glib::RefPtr<Gtk::TreeSelection> vselection;
Gtk::TreeView vst_display; Gtk::TreeView vst_display;
static void _vst_refiller (void *);
void vst_refiller (); void vst_refiller ();
void vst_display_selection_changed(); void vst_display_selection_changed();
#endif // VST_SUPPORT #endif // VST_SUPPORT
@ -136,7 +135,6 @@ class PluginSelector : public ArdourDialog
Glib::RefPtr<Gtk::ListStore> aumodel; Glib::RefPtr<Gtk::ListStore> aumodel;
Glib::RefPtr<Gtk::TreeSelection> auselection; Glib::RefPtr<Gtk::TreeSelection> auselection;
Gtk::TreeView au_display; Gtk::TreeView au_display;
static void _au_refiller (void *);
void au_refiller (); void au_refiller ();
void au_display_selection_changed(); void au_display_selection_changed();
#endif //HAVE_AUDIOUNIT #endif //HAVE_AUDIOUNIT
@ -156,6 +154,8 @@ class PluginSelector : public ArdourDialog
void use_plugin (ARDOUR::PluginInfoPtr); void use_plugin (ARDOUR::PluginInfoPtr);
void cleanup (); void cleanup ();
void refill (); void refill ();
bool show_this_plugin (ARDOUR::PluginInfoPtr&, const std::string&);
void setup_filter_string (std::string&);
void set_correct_focus(); void set_correct_focus();
}; };

View file

@ -22,6 +22,7 @@
#include <boost/shared_ptr.hpp> #include <boost/shared_ptr.hpp>
#include <sigc++/signal.h> #include <sigc++/signal.h>
#include <glibmm/ustring.h>
#include <pbd/statefuldestructible.h> #include <pbd/statefuldestructible.h>
#include <pbd/controllable.h> #include <pbd/controllable.h>
@ -53,11 +54,13 @@ class PluginInfo {
PluginInfo () { } PluginInfo () { }
PluginInfo (const PluginInfo &o) PluginInfo (const PluginInfo &o)
: name(o.name), n_inputs(o.n_inputs), n_outputs(o.n_outputs), : name(o.name), n_inputs(o.n_inputs), n_outputs(o.n_outputs),
unique_id(o.unique_id), path (o.path), index(o.index) {} path (o.path), unique_id(o.unique_id), index(o.index) {}
virtual ~PluginInfo () { } virtual ~PluginInfo () { }
string name; string name;
string category; string category;
Glib::ustring creator;
Glib::ustring path;
uint32_t n_inputs; uint32_t n_inputs;
uint32_t n_outputs; uint32_t n_outputs;
ARDOUR::PluginType type; ARDOUR::PluginType type;
@ -68,7 +71,6 @@ class PluginInfo {
protected: protected:
friend class PluginManager; friend class PluginManager;
string path;
uint32_t index; uint32_t index;
}; };

View file

@ -248,6 +248,7 @@ PluginManager::ladspa_discover (string path)
PluginInfoPtr info(new LadspaPluginInfo); PluginInfoPtr info(new LadspaPluginInfo);
info->name = descriptor->Name; info->name = descriptor->Name;
info->category = get_ladspa_category(descriptor->UniqueID); info->category = get_ladspa_category(descriptor->UniqueID);
info->creator = descriptor->Maker;
info->path = path; info->path = path;
info->index = i; info->index = i;
info->n_inputs = 0; info->n_inputs = 0;
@ -393,6 +394,7 @@ PluginManager::vst_discover (string path)
info->category = "VST"; info->category = "VST";
info->path = path; info->path = path;
// need to set info->creator but FST doesn't provide it
info->index = 0; info->index = 0;
info->n_inputs = finfo->numInputs; info->n_inputs = finfo->numInputs;
info->n_outputs = finfo->numOutputs; info->n_outputs = finfo->numOutputs;