#include <cstdio>
#include <lrdf.h>
+#include <algorithm>
+
#include <gtkmm/table.h>
#include <gtkmm/stock.h>
#include <gtkmm/button.h>
#include <gtkmm/notebook.h>
+#include <gtkmm2ext/utils.h>
+
+#include <pbd/convert.h>
+
#include <ardour/plugin_manager.h>
#include <ardour/plugin.h>
#include <ardour/configuration.h>
using namespace ARDOUR;
using namespace PBD;
using namespace Gtk;
+using namespace std;
+
+static const char* _filter_mode_strings[] = {
+ N_("Name contains"),
+ N_("Type contains"),
+ N_("Author contains"),
+ N_("Library contains"),
+ 0
+};
PluginSelector::PluginSelector (PluginManager *mgr)
- : ArdourDialog (_("ardour: plugins"), true, false)
+ : ArdourDialog (_("ardour: plugins"), true, false),
+ filter_button (Stock::CLEAR)
{
set_position (Gtk::WIN_POS_MOUSE);
set_name ("PluginSelectorWindow");
ladspa_display.append_column (_("# Inputs"),lcols.ins);
ladspa_display.append_column (_("# Outputs"), lcols.outs);
ladspa_display.set_headers_visible (true);
+ ladspa_display.set_headers_clickable (true);
ladspa_display.set_reorderable (false);
lscroller.set_border_width(10);
lscroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
amodel = Gtk::ListStore::create(acols);
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_reorderable (false);
vst_display.append_column (_("# Inputs"), vcols.ins);
vst_display.append_column (_("# Outputs"), vcols.outs);
vst_display.set_headers_visible (true);
+ vst_display.set_headers_clickable (true);
vst_display.set_reorderable (false);
vscroller.set_border_width(10);
vscroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
au_display.append_column (_("# Inputs"), aucols.ins);
au_display.append_column (_("# Outputs"), aucols.outs);
au_display.set_headers_visible (true);
+ au_display.set_headers_clickable (true);
au_display.set_reorderable (false);
auscroller.set_border_width(10);
auscroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
btn_add->set_name("PluginSelectorButton");
btn_remove->set_name("PluginSelectorButton");
- Gtk::Table* table = manage(new Gtk::Table(7, 10));
+ Gtk::Table* table = manage(new Gtk::Table(7, 11));
table->set_size_request(750, 500);
table->attach(notebook, 0, 7, 0, 5);
- 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);
+ HBox* filter_box = manage (new HBox);
+
+ vector<string> filter_strings = I18N (_filter_mode_strings);
+ Gtkmm2ext::set_popdown_strings (filter_mode, filter_strings);
+ filter_mode.set_active_text (filter_strings.front());
+
+ filter_box->pack_start (filter_mode, false, false);
+ filter_box->pack_start (filter_entry, true, true);
+ filter_box->pack_start (filter_button, false, false);
+
+ filter_entry.signal_changed().connect (mem_fun (*this, &PluginSelector::filter_entry_changed));
+ filter_button.signal_clicked().connect (mem_fun (*this, &PluginSelector::filter_button_clicked));
+ filter_mode.signal_changed().connect (mem_fun (*this, &PluginSelector::filter_mode_changed));
+
+ filter_box->show ();
+ filter_mode.show ();
+ filter_entry.show ();
+ filter_button.show ();
- table->attach(ascroller, 0, 7, 7, 9);
+ table->attach (*filter_box, 0, 7, 5, 6, FILL|EXPAND, 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_update, 5, 6, 6, 7, FILL, FILL, 5, 5);
+
+ table->attach(ascroller, 0, 7, 8, 10);
add_button (Stock::CANCEL, RESPONSE_CANCEL);
add_button (Stock::CONNECT, RESPONSE_APPLY);
set_response_sensitive (RESPONSE_APPLY, false);
get_vbox()->pack_start (*table);
+
// Notebook tab order must be the same in here as in set_correct_focus()
- using namespace Gtk::Notebook_Helpers;
+ using namespace Notebook_Helpers;
notebook.pages().push_back (TabElem (lscroller, _("LADSPA")));
#ifdef VST_SUPPORT
btn_remove->signal_clicked().connect(mem_fun(*this, &PluginSelector::btn_remove_clicked));
added_list.get_selection()->signal_changed().connect (mem_fun(*this, &PluginSelector::added_list_selection_changed));
- input_refiller ();
+ ladspa_refiller ();
#ifdef VST_SUPPORT
vst_refiller ();
}
}
-void
-PluginSelector::_input_refiller (void *arg)
+bool
+PluginSelector::show_this_plugin (PluginInfoPtr& info, const std::string& filterstr)
{
- ((PluginSelector *) arg)->input_refiller ();
+ 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;
}
-int compare(const void *left, const void *right)
+void
+PluginSelector::setup_filter_string (string& filterstr)
{
- return strcmp(*((char**)left), *((char**)right));
-}
+ filterstr = filter_entry.get_text ();
+ transform (filterstr.begin(), filterstr.end(), filterstr.begin(), ::toupper);
+}
void
-PluginSelector::input_refiller ()
+PluginSelector::ladspa_refiller ()
{
guint row;
PluginInfoList &plugs = manager->ladspa_plugin_info ();
PluginInfoList::iterator i;
char ibuf[16], obuf[16];
+
lmodel->clear();
- // Insert into GTK list
+ std::string filterstr;
+ setup_filter_string (filterstr);
+
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);
-
- 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;
+ if (show_this_plugin (*i, filterstr)) {
+ snprintf (ibuf, sizeof(ibuf)-1, "%u", (*i)->n_inputs.n_total());
+ snprintf (obuf, sizeof(obuf)-1, "%u", (*i)->n_outputs.n_total());
+
+ 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;
+ }
}
- lmodel->set_sort_column (0, Gtk::SORT_ASCENDING);
+ lmodel->set_sort_column (0, SORT_ASCENDING);
}
#ifdef VST_SUPPORT
-void
-PluginSelector::_vst_refiller (void *arg)
-{
- ((PluginSelector *) arg)->vst_refiller ();
-}
-
void
PluginSelector::vst_refiller ()
{
char ibuf[16], obuf[16];
vmodel->clear();
- // Insert into GTK list
+ std::string filterstr;
+ setup_filter_string (filterstr);
+
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);
-
- Gtk::TreeModel::Row newrow = *(vmodel->append());
- newrow[vcols.name] = (*i)->name.c_str();
- newrow[vcols.ins] = ibuf;
- newrow[vcols.outs] = obuf;
- newrow[vcols.plugin] = *i;
+ if (show_this_plugin (*i, filterstr)) {
+ snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
+ snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs);
+
+ TreeModel::Row newrow = *(vmodel->append());
+ newrow[vcols.name] = (*i)->name.c_str();
+ newrow[vcols.ins] = ibuf;
+ newrow[vcols.outs] = obuf;
+ newrow[vcols.plugin] = *i;
+ }
}
- vmodel->set_sort_column (0, Gtk::SORT_ASCENDING);
+ vmodel->set_sort_column (0, SORT_ASCENDING);
}
void
#ifdef HAVE_AUDIOUNIT
-void
-PluginSelector::_au_refiller (void *arg)
-{
- ((PluginSelector *) arg)->au_refiller ();
-}
-
void
PluginSelector::au_refiller ()
{
char ibuf[16], obuf[16];
aumodel->clear();
- // Insert into GTK list
+ std::string filterstr;
+ setup_filter_string (filterstr);
+
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);
-
- Gtk::TreeModel::Row newrow = *(aumodel->append());
- newrow[aucols.name] = (*i)->name.c_str();
- newrow[aucols.ins] = ibuf;
- newrow[aucols.outs] = obuf;
- newrow[aucols.plugin] = *i;
+ if (show_this_plugin (*i, filterstr)) {
+
+ snprintf (ibuf, sizeof(ibuf)-1, "%d", (*i)->n_inputs);
+ snprintf (obuf, sizeof(obuf)-1, "%d", (*i)->n_outputs);
+
+ TreeModel::Row newrow = *(aumodel->append());
+ newrow[aucols.name] = (*i)->name.c_str();
+ newrow[aucols.ins] = ibuf;
+ newrow[aucols.outs] = obuf;
+ newrow[aucols.plugin] = *i;
+ }
}
- aumodel->set_sort_column (0, Gtk::SORT_ASCENDING);
+
+ aumodel->set_sort_column (0, SORT_ASCENDING);
}
void
{
std::string name;
PluginInfoPtr pi;
- Gtk::TreeModel::Row newrow = *(amodel->append());
+ TreeModel::Row newrow = *(amodel->append());
- Gtk::TreeModel::Row row;
+ TreeModel::Row row;
switch (current_selection) {
case ARDOUR::LADSPA:
void
PluginSelector::btn_remove_clicked()
{
- Gtk::TreeModel::iterator iter = added_list.get_selection()->get_selected();
+ TreeModel::iterator iter = added_list.get_selection()->get_selected();
amodel->erase(iter);
if (amodel->children().empty()) {
PluginSelector::btn_update_clicked()
{
manager->refresh ();
- input_refiller ();
+ refill();
+}
+
+void
+PluginSelector::refill()
+{
+ ladspa_refiller ();
#ifdef VST_SUPPORT
vst_refiller ();
#endif
hide();
amodel->clear();
}
+
+void
+PluginSelector::filter_button_clicked ()
+{
+ filter_entry.set_text ("");
+}
+
+void
+PluginSelector::filter_entry_changed ()
+{
+ refill ();
+}
+
+void
+PluginSelector::filter_mode_changed ()
+{
+ refill ();
+}
+