2 Copyright (C) 2000-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #include "gtk2ardour-config.h"
28 #include <gtkmm/button.h>
29 #include <gtkmm/comboboxtext.h>
30 #include <gtkmm/frame.h>
31 #include <gtkmm/messagedialog.h>
32 #include <gtkmm/notebook.h>
33 #include <gtkmm/stock.h>
34 #include <gtkmm/table.h>
36 #include "gtkmm2ext/utils.h"
38 #include "widgets/tooltips.h"
40 #include "pbd/convert.h"
41 #include "pbd/tokenizer.h"
43 #include "ardour/utils.h"
45 #include "plugin_selector.h"
46 #include "gui_thread.h"
47 #include "ui_config.h"
51 using namespace ARDOUR;
55 using namespace ArdourWidgets;
57 static const uint32_t MAX_CREATOR_LEN = 24;
59 PluginSelector::PluginSelector (PluginManager& mgr)
60 : ArdourDialog (_("Plugin Manager"), true, false)
61 , search_clear_button (Stock::CLEAR)
63 , inhibit_refill (false)
65 set_name ("PluginSelectorWindow");
66 add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
69 in_row_change = false;
71 manager.PluginListChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::build_plugin_menu, this), gui_context());
72 manager.PluginListChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::refill, this), gui_context());
73 manager.PluginStatusesChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::plugin_status_changed, this, _1, _2, _3), gui_context());
74 manager.PluginTagsChanged.connect(plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::tags_changed, this, _1, _2, _3), gui_context());
76 plugin_model = Gtk::ListStore::create (plugin_columns);
77 plugin_display.set_model (plugin_model);
78 /* XXX translators: try to convert "Fav" into a short term
79 * related to "favorite" and "Hid" into a short term
82 plugin_display.append_column (_("Fav"), plugin_columns.favorite);
83 plugin_display.append_column (_("Hide"), plugin_columns.hidden);
84 plugin_display.append_column (_("Name"), plugin_columns.name);
85 plugin_display.append_column (_("Tags"), plugin_columns.tags);
86 plugin_display.append_column (_("Creator"), plugin_columns.creator);
87 plugin_display.append_column (_("Type"), plugin_columns.type_name);
88 plugin_display.append_column (_("Audio I/O"),plugin_columns.audio_io);
89 plugin_display.append_column (_("MIDI I/O"), plugin_columns.midi_io);
90 plugin_display.set_headers_visible (true);
91 plugin_display.set_headers_clickable (true);
92 plugin_display.set_reorderable (false);
93 plugin_display.set_rules_hint (true);
94 plugin_display.add_object_drag (plugin_columns.plugin.index(), "PluginInfoPtr");
95 plugin_display.set_drag_column (plugin_columns.name.index());
97 // setting a sort-column prevents re-ordering via Drag/Drop
98 plugin_model->set_sort_column (plugin_columns.name.index(), Gtk::SORT_ASCENDING);
100 plugin_display.set_name("PluginSelectorDisplay");
101 plugin_display.signal_row_activated().connect_notify (sigc::mem_fun(*this, &PluginSelector::row_activated));
102 plugin_display.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &PluginSelector::display_selection_changed));
104 CellRendererToggle* fav_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (0));
105 fav_cell->property_activatable() = true;
106 fav_cell->property_radio() = true;
107 fav_cell->signal_toggled().connect (sigc::mem_fun (*this, &PluginSelector::favorite_changed));
109 CellRendererToggle* hidden_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (1));
110 hidden_cell->property_activatable() = true;
111 hidden_cell->property_radio() = true;
112 hidden_cell->signal_toggled().connect (sigc::mem_fun (*this, &PluginSelector::hidden_changed));
114 scroller.set_border_width(10);
115 scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
116 scroller.add(plugin_display);
118 amodel = Gtk::ListStore::create(acols);
119 added_list.set_model (amodel);
120 added_list.append_column (_("Plugins to be connected"), acols.text);
121 added_list.set_headers_visible (true);
122 added_list.set_reorderable (false);
124 for (int i = 2; i <= 7; ++i) {
125 Gtk::TreeView::Column* column = plugin_display.get_column(i);
127 column->set_sort_column(i);
131 ascroller.set_border_width(10);
132 ascroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
133 ascroller.add(added_list);
134 btn_add = manage(new Gtk::Button(Stock::ADD));
135 set_tooltip(*btn_add, _("Add a plugin to the effect list"));
136 btn_add->set_sensitive (false);
137 btn_remove = manage(new Gtk::Button(Stock::REMOVE));
138 btn_remove->set_sensitive (false);
139 set_tooltip(*btn_remove, _("Remove a plugin from the effect list"));
141 btn_add->set_name("PluginSelectorButton");
142 btn_remove->set_name("PluginSelectorButton");
146 Gtk::Table* search_table = manage(new Gtk::Table(2, 2));
148 search_entry.signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::search_entry_changed));
149 search_clear_button.signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::search_clear_button_clicked));
151 _search_name_checkbox = manage (new ArdourButton (_("Name"), ArdourButton::led_default_elements, true));
152 _search_name_checkbox->set_active(true);
153 _search_name_checkbox->set_name ("pluginlist filter button");
155 _search_tags_checkbox = manage (new ArdourButton (_("Tags"), ArdourButton::led_default_elements, true));
156 _search_tags_checkbox->set_active(true);
157 _search_tags_checkbox->set_name ("pluginlist filter button");
159 _search_ignore_checkbox = manage (new ArdourButton(_("Ignore Filters when searching"), ArdourButton::led_default_elements, true));
160 _search_ignore_checkbox->set_active(true);
161 _search_ignore_checkbox->set_name ("pluginlist filter button");
163 Gtk::Label* search_help_label = manage (new Label(
164 _("All search terms must be matched.\n"
165 "Ex: \"ess dyn\" will find \"dynamic de-esser\" but not \"de-esser\"."
166 ), Gtk::ALIGN_LEFT));
168 search_table->attach (search_entry, 0, 3, 0, 1, FILL|EXPAND, FILL);
169 search_table->attach (search_clear_button, 3, 4, 0, 1, FILL, FILL);
170 search_table->attach (*_search_name_checkbox, 0, 1, 1, 2, FILL, FILL);
171 search_table->attach (*_search_tags_checkbox, 1, 2, 1, 2, FILL, FILL);
172 search_table->attach (*_search_ignore_checkbox,2, 3, 1, 2, FILL, FILL);
173 search_table->attach (*search_help_label, 0, 3, 2, 3, FILL, FILL);
175 search_table->set_border_width (4);
176 search_table->set_col_spacings (4);
177 search_table->set_row_spacings (4);
179 Frame* search_frame = manage (new Frame);
180 search_frame->set_name ("BaseFrame");
181 search_frame->set_label (_("Search"));
182 search_frame->add (*search_table);
183 search_frame->show_all ();
185 _search_name_checkbox->signal_clicked.connect (sigc::mem_fun (*this, &PluginSelector::refill));
186 _search_tags_checkbox->signal_clicked.connect (sigc::mem_fun (*this, &PluginSelector::refill));
187 _search_ignore_checkbox->signal_clicked.connect (sigc::mem_fun (*this, &PluginSelector::set_sensitive_widgets));
191 Gtk::RadioButtonGroup fil_radio_group;
193 _fil_effects_radio = manage (new RadioButton (fil_radio_group, _("Show Effects Only")));
194 _fil_instruments_radio = manage (new RadioButton (fil_radio_group, _("Show Instruments Only")));
195 _fil_utils_radio = manage (new RadioButton (fil_radio_group, _("Show Utilities Only")));
196 _fil_favorites_radio = manage (new RadioButton (fil_radio_group, _("Show Favorites Only")));
197 _fil_hidden_radio = manage (new RadioButton (fil_radio_group, _("Show Hidden Only")));
198 _fil_all_radio = manage (new RadioButton (fil_radio_group, _("Show All")));
200 //_fil_type_combo = manage (new ComboBoxText);
201 _fil_type_combo.append_text_item (_("Show All Formats"));
202 _fil_type_combo.append_text_item (X_("VST"));
203 #ifdef AUDIOUNIT_SUPPORT
204 _fil_type_combo.append_text_item (X_("AudioUnit"));
207 _fil_type_combo.append_text_item (X_("LV2"));
209 _fil_type_combo.append_text_item (X_("LUA"));
210 _fil_type_combo.append_text_item (X_("LADSPA"));
211 _fil_type_combo.set_text (_("Show All Formats"));
213 /* note: _fil_creator_combo menu gets filled in build_plugin_menu */
214 _fil_creator_combo.set_text_ellipsize (Pango::ELLIPSIZE_END);
215 _fil_creator_combo.set_layout_ellipsize_width (PANGO_SCALE * 160 * UIConfiguration::instance ().get_ui_scale ());
217 _fil_channel_combo.append_text_item (_("Audio I/O"));
218 _fil_channel_combo.append_text_item (_("Mono Audio I/O"));
219 _fil_channel_combo.append_text_item (_("Stereo Audio I/O"));
220 _fil_channel_combo.append_text_item (_("MIDI I/O (only)"));
221 _fil_channel_combo.append_text_item (_("Show All I/O"));
223 _fil_channel_combo.set_text (_("Audio I/O"));
225 _fil_channel_combo.set_text (_("Show All I/O"));
228 VBox* filter_vbox = manage (new VBox);
229 filter_vbox->pack_start (*_fil_effects_radio, false, false);
230 filter_vbox->pack_start (*_fil_instruments_radio, false, false);
231 filter_vbox->pack_start (*_fil_utils_radio, false, false);
232 filter_vbox->pack_start (*_fil_favorites_radio, false, false);
233 filter_vbox->pack_start (*_fil_hidden_radio, false, false);
234 filter_vbox->pack_start (*_fil_all_radio, false, false);
235 filter_vbox->pack_start (_fil_type_combo, false, false);
236 filter_vbox->pack_start (_fil_creator_combo, false, false);
237 filter_vbox->pack_start (_fil_channel_combo, false, false);
239 filter_vbox->set_border_width (4);
240 filter_vbox->set_spacing (4);
242 Frame* filter_frame = manage (new Frame);
243 filter_frame->set_name ("BaseFrame");
244 filter_frame->set_label (_("Filter"));
245 filter_frame->add (*filter_vbox);
246 filter_frame->show_all ();
248 _fil_effects_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
249 _fil_instruments_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
250 _fil_utils_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
251 _fil_favorites_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
252 _fil_hidden_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
254 _fil_type_combo.StateChanged.connect (sigc::mem_fun (*this, &PluginSelector::refill));
255 _fil_creator_combo.StateChanged.connect (sigc::mem_fun (*this, &PluginSelector::refill));
256 _fil_channel_combo.StateChanged.connect (sigc::mem_fun (*this, &PluginSelector::refill));
260 Gtk::Table* tagging_table = manage(new Gtk::Table(1, 2));
261 tagging_table->set_border_width (4);
262 tagging_table->set_col_spacings (4);
263 tagging_table->set_row_spacings (4);
265 tag_entry = manage (new Gtk::Entry);
266 tag_entry_connection = tag_entry->signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::tag_entry_changed));
268 tag_reset_button = manage (new Button (_("Reset")));
269 tag_reset_button->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::tag_reset_button_clicked));
271 Gtk::Label* tagging_help_label = manage (new Label(
272 _("Enter space-separated, one-word Tags for the selected plugin.\n"
273 "You can include dashes, colons or underscores in a Tag.\n"
274 "Ex: \"dynamic de-esser vocal\" applies 3 Tags."
275 ), Gtk::ALIGN_LEFT));
278 tagging_table->attach (*tag_entry, 0, 1, p, p+1, FILL|EXPAND, FILL);
279 tagging_table->attach (*tag_reset_button, 1, 2, p, p+1, FILL, FILL); p++;
280 tagging_table->attach (*tagging_help_label, 0, 2, p, p+1, FILL, FILL); p++;
282 Frame* tag_frame = manage (new Frame);
283 tag_frame->set_name ("BaseFrame");
284 tag_frame->set_label (_("Tags for Selected Plugin"));
285 tag_frame->add (*tagging_table);
286 tag_frame->show_all ();
288 /* Add & remove buttons */
290 HBox* add_remove = manage (new HBox);
291 add_remove->pack_start (*btn_add, true, true);
292 add_remove->pack_start (*btn_remove, true, true);
294 btn_add->signal_clicked().connect(sigc::mem_fun(*this, &PluginSelector::btn_add_clicked));
295 btn_remove->signal_clicked().connect(sigc::mem_fun(*this, &PluginSelector::btn_remove_clicked));
296 added_list.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &PluginSelector::added_list_selection_changed));
297 added_list.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::added_row_clicked));
299 added_list.set_name("PluginSelectorList");
301 /* Top-level Layout */
303 VBox* to_be_inserted_vbox = manage (new VBox);
304 to_be_inserted_vbox->pack_start (ascroller);
305 to_be_inserted_vbox->pack_start (*add_remove, false, false);
306 to_be_inserted_vbox->set_size_request (200, -1);
308 Gtk::Table* table = manage(new Gtk::Table(3, 3));
309 table->set_size_request(-1, 600);
310 table->attach (scroller, 0, 3, 0, 5); /* this is the main plugin list */
311 table->attach (*search_frame, 0, 1, 6, 7, FILL, FILL, 5, 5);
312 table->attach (*tag_frame, 0, 1, 7, 8, FILL, FILL, 5, 5);
313 table->attach (*filter_frame, 1, 2, 6, 8, FILL, FILL, 5, 5);
314 table->attach (*to_be_inserted_vbox, 2, 3, 6, 8, FILL|EXPAND, FILL, 5, 5); /* to be inserted... */
316 add_button (Stock::CLOSE, RESPONSE_CLOSE);
317 add_button (_("Insert Plugin(s)"), RESPONSE_APPLY);
318 set_default_response (RESPONSE_APPLY);
319 set_response_sensitive (RESPONSE_APPLY, false);
320 get_vbox()->pack_start (*table);
322 table->set_name("PluginSelectorTable");
324 plugin_display.grab_focus();
326 build_plugin_menu ();
327 display_selection_changed ();
330 PluginSelector::~PluginSelector ()
336 PluginSelector::row_activated(Gtk::TreeModel::Path, Gtk::TreeViewColumn*)
342 PluginSelector::added_row_clicked(GdkEventButton* event)
344 if (event->type == GDK_2BUTTON_PRESS)
345 btn_remove_clicked();
349 PluginSelector::show_this_plugin (const PluginInfoPtr& info, const std::string& searchstr)
352 bool maybe_show = false;
354 if (!searchstr.empty()) {
358 if (_search_name_checkbox->get_active()) { /* name contains */
359 compstr = info->name;
360 transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
361 if (compstr.find (searchstr) != string::npos) {
366 if (_search_tags_checkbox->get_active()) { /* tag contains */
367 compstr = manager.get_tags_as_string (info);
368 transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
369 if (compstr.find (searchstr) != string::npos) {
378 /* user asked to ignore filters */
379 if (maybe_show && _search_ignore_checkbox->get_active()) {
384 if (_fil_effects_radio->get_active() && !info->is_effect()) {
388 if (_fil_instruments_radio->get_active() && !info->is_instrument()) {
392 if (_fil_utils_radio->get_active() && !(info->is_utility() || info->is_analyzer())) {
396 if (_fil_favorites_radio->get_active() && !(manager.get_status (info) == PluginManager::Favorite)) {
400 if (_fil_hidden_radio->get_active() && !(manager.get_status (info) == PluginManager::Hidden)) {
404 if (manager.get_status (info) == PluginManager::Hidden) {
405 if (!_fil_hidden_radio->get_active() && !_fil_all_radio->get_active()) {
410 /* Filter "type" combobox */
412 if (_fil_type_combo.get_text() == X_("VST") && PluginManager::to_generic_vst(info->type) != LXVST) {
416 if (_fil_type_combo.get_text() == X_("AudioUnit") && info->type != AudioUnit) {
421 if (_fil_type_combo.get_text() == X_("LV2") && info->type != LV2) {
426 if (_fil_type_combo.get_text() == X_("LUA") && info->type != Lua) {
430 if (_fil_type_combo.get_text() == X_("LADSPA") && info->type != LADSPA) {
434 /* Filter "creator" combobox */
436 if (_fil_creator_combo.get_text() != _("Show All Creators")) {
437 if (_fil_creator_combo.get_text() != info->creator) {
442 /* Filter "I/O" combobox */
444 if (_fil_channel_combo.get_text() != _("Show All I/O") || info->reconfigurable_io ()) {
447 if (info->reconfigurable_io ()) {
448 return true; // who knows.... ?
452 if (_fil_channel_combo.get_text() == _("Audio I/O")) {
453 if ((info->n_inputs.n_audio() == 0 || info->n_outputs.n_audio() == 0)) {
458 if (_fil_channel_combo.get_text() == _("Mono Audio I/O")) {
459 if (info->n_inputs.n_audio() != 1 || info->n_outputs.n_audio() != 1) {
464 if (_fil_channel_combo.get_text() == _("Stereo Audio I/O")) {
465 if (info->n_inputs.n_audio() != 2 || info->n_outputs.n_audio() != 2) {
470 if (_fil_channel_combo.get_text() == _("MIDI I/O (only)")) {
471 if ((info->n_inputs.n_audio() != 0 || info->n_outputs.n_audio() == 0)) {
482 PluginSelector::setup_search_string (string& searchstr)
484 searchstr = search_entry.get_text ();
485 transform (searchstr.begin(), searchstr.end(), searchstr.begin(), ::toupper);
489 PluginSelector::set_sensitive_widgets ()
491 if (_search_ignore_checkbox->get_active() && !search_entry.get_text().empty()) {
492 _fil_effects_radio->set_sensitive(false);
493 _fil_instruments_radio->set_sensitive(false);
494 _fil_utils_radio->set_sensitive(false);
495 _fil_favorites_radio->set_sensitive(false);
496 _fil_hidden_radio->set_sensitive(false);
497 _fil_all_radio->set_sensitive(false);
498 _fil_type_combo.set_sensitive(false);
499 _fil_creator_combo.set_sensitive(false);
500 _fil_channel_combo.set_sensitive(false);
502 _fil_effects_radio->set_sensitive(true);
503 _fil_instruments_radio->set_sensitive(true);
504 _fil_utils_radio->set_sensitive(true);
505 _fil_favorites_radio->set_sensitive(true);
506 _fil_hidden_radio->set_sensitive(true);
507 _fil_all_radio->set_sensitive(true);
508 _fil_type_combo.set_sensitive(true);
509 _fil_creator_combo.set_sensitive(true);
510 _fil_channel_combo.set_sensitive(true);
512 if (!search_entry.get_text().empty()) {
518 PluginSelector::refill ()
520 if (inhibit_refill) {
524 std::string searchstr;
526 in_row_change = true;
528 plugin_model->clear ();
530 setup_search_string (searchstr);
532 ladspa_refiller (searchstr);
533 lv2_refiller (searchstr);
534 vst_refiller (searchstr);
535 lxvst_refiller (searchstr);
536 mac_vst_refiller (searchstr);
537 au_refiller (searchstr);
538 lua_refiller (searchstr);
540 in_row_change = false;
544 PluginSelector::refiller (const PluginInfoList& plugs, const::std::string& searchstr, const char* type)
548 for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
550 if (show_this_plugin (*i, searchstr)) {
552 TreeModel::Row newrow = *(plugin_model->append());
553 newrow[plugin_columns.favorite] = (manager.get_status (*i) == PluginManager::Favorite);
554 newrow[plugin_columns.hidden] = (manager.get_status (*i) == PluginManager::Hidden);
556 string name = (*i)->name;
557 if (name.length() > 48) {
558 name = name.substr (0, 48);
561 newrow[plugin_columns.name] = name;
563 newrow[plugin_columns.type_name] = type;
566 string creator = (*i)->creator;
567 string::size_type pos = 0;
568 if ((*i)->type == ARDOUR::LADSPA) {
569 /* stupid LADSPA creator strings */
570 #ifdef PLATFORM_WINDOWS
571 while (pos < creator.length() && creator[pos] > -2 && creator[pos] < 256 && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
573 while (pos < creator.length() && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
576 pos = creator.length ();
578 // If there were too few characters to create a
579 // meaningful name, mark this creator as 'Unknown'
580 if (creator.length() < 2 || pos < 3) {
583 creator = creator.substr (0, pos);
586 if (creator.length() > MAX_CREATOR_LEN) {
587 creator = creator.substr (0, MAX_CREATOR_LEN);
588 creator.append("...");
590 newrow[plugin_columns.creator] = creator;
593 string tags = manager.get_tags_as_string(*i);
594 if (tags.length() > 32) {
595 tags = tags.substr (0, 32);
598 newrow[plugin_columns.tags] = tags;
600 if ((*i)->reconfigurable_io ()) {
601 newrow[plugin_columns.audio_io] = "* / *";
602 newrow[plugin_columns.midi_io] = "* / *";
604 snprintf (buf, sizeof(buf), "%d / %d", (*i)->n_inputs.n_audio(), (*i)->n_outputs.n_audio());
605 newrow[plugin_columns.audio_io] = buf;
606 snprintf (buf, sizeof(buf), "%d / %d", (*i)->n_inputs.n_audio(), (*i)->n_outputs.n_audio());
607 newrow[plugin_columns.midi_io] = buf;
610 newrow[plugin_columns.plugin] = *i;
616 PluginSelector::ladspa_refiller (const std::string& searchstr)
618 refiller (manager.ladspa_plugin_info(), searchstr, "LADSPA");
622 PluginSelector::lua_refiller (const std::string& searchstr)
624 refiller (manager.lua_plugin_info(), searchstr, "Lua");
628 PluginSelector::lv2_refiller (const std::string& searchstr)
631 refiller (manager.lv2_plugin_info(), searchstr, "LV2");
636 #ifdef WINDOWS_VST_SUPPORT
637 PluginSelector::vst_refiller (const std::string& searchstr)
639 PluginSelector::vst_refiller (const std::string&)
642 #ifdef WINDOWS_VST_SUPPORT
643 refiller (manager.windows_vst_plugin_info(), searchstr, "VST");
649 PluginSelector::lxvst_refiller (const std::string& searchstr)
651 PluginSelector::lxvst_refiller (const std::string&)
655 refiller (manager.lxvst_plugin_info(), searchstr, "LXVST");
660 #ifdef MACVST_SUPPORT
661 PluginSelector::mac_vst_refiller (const std::string& searchstr)
663 PluginSelector::mac_vst_refiller (const std::string&)
666 #ifdef MACVST_SUPPORT
667 refiller (manager.mac_vst_plugin_info(), searchstr, "MacVST");
672 #ifdef AUDIOUNIT_SUPPORT
673 PluginSelector::au_refiller (const std::string& searchstr)
675 PluginSelector::au_refiller (const std::string&)
678 #ifdef AUDIOUNIT_SUPPORT
679 refiller (manager.au_plugin_info(), searchstr, "AU");
684 PluginSelector::load_plugin (PluginInfoPtr pi)
690 return pi->load (*_session);
694 PluginSelector::btn_add_clicked()
696 if (plugin_display.get_selection()->count_selected_rows() == 0) {
697 /* may happen with ctrl + double-click un-selecting but activating a row */
702 TreeModel::Row newrow = *(amodel->append());
705 row = *(plugin_display.get_selection()->get_selected());
706 name = row[plugin_columns.name];
707 pi = row[plugin_columns.plugin];
709 newrow[acols.text] = name;
710 newrow[acols.plugin] = pi;
712 if (!amodel->children().empty()) {
713 set_response_sensitive (RESPONSE_APPLY, true);
718 PluginSelector::btn_remove_clicked()
720 TreeModel::iterator iter = added_list.get_selection()->get_selected();
723 if (amodel->children().empty()) {
724 set_response_sensitive (RESPONSE_APPLY, false);
729 PluginSelector::display_selection_changed()
731 tag_entry_connection.block ();
732 if (plugin_display.get_selection()->count_selected_rows() != 0) {
734 /* a plugin row is selected; allow the user to edit the "tags" on it. */
735 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
736 string tags = manager.get_tags_as_string (row[plugin_columns.plugin]);
737 tag_entry->set_text (tags);
739 tag_entry->set_sensitive (true);
740 tag_reset_button->set_sensitive (true);
741 btn_add->set_sensitive (true);
744 tag_entry->set_text ("");
746 tag_entry->set_sensitive (false);
747 tag_reset_button->set_sensitive (false);
748 btn_add->set_sensitive (false);
750 tag_entry_connection.unblock ();
754 PluginSelector::added_list_selection_changed()
756 if (added_list.get_selection()->count_selected_rows() != 0) {
757 btn_remove->set_sensitive (true);
759 btn_remove->set_sensitive (false);
764 PluginSelector::run ()
767 TreeModel::Children::iterator i;
773 SelectedPlugins plugins;
774 r = (ResponseType) Dialog::run ();
778 for (i = amodel->children().begin(); i != amodel->children().end(); ++i) {
779 PluginInfoPtr pp = (*i)[acols.plugin];
780 PluginPtr p = load_plugin (pp);
782 plugins.push_back (p);
784 MessageDialog msg (string_compose (_("The plugin \"%1\" could not be loaded\n\nSee the Log window for more details (maybe)"), pp->name));
788 if (interested_object && !plugins.empty()) {
789 finish = !interested_object->use_plugins (plugins);
803 interested_object = 0;
805 if (_need_tag_save) {
809 if (_need_status_save) {
810 manager.save_statuses();
813 if (_need_menu_rebuild) {
821 PluginSelector::search_clear_button_clicked ()
823 search_entry.set_text ("");
827 PluginSelector::tag_reset_button_clicked ()
829 if (plugin_display.get_selection()->count_selected_rows() != 0) {
830 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
831 ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin];
832 manager.reset_tags (pi);
833 display_selection_changed ();
834 _need_tag_save = true;
839 PluginSelector::search_entry_changed ()
841 set_sensitive_widgets();
842 if (search_entry.get_text().empty()) {
848 PluginSelector::tag_entry_changed ()
850 if (plugin_display.get_selection()->count_selected_rows() != 0) {
851 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
853 ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin];
854 manager.set_tags (pi->type, pi->unique_id, tag_entry->get_text(), false);
856 _need_tag_save = true;
861 PluginSelector::tags_changed (PluginType t, std::string unique_id, std::string tags)
863 if (plugin_display.get_selection()->count_selected_rows() != 0) {
864 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
865 if (tags.length() > 32) {
866 tags = tags.substr (0, 32);
869 row[plugin_columns.tags] = tags;
872 /* A plugin's tags change while the user is entering them.
873 * defer a rebuilding of the "tag" menu until the dialog is closed.
875 _need_menu_rebuild = true;
879 PluginSelector::plugin_status_changed (PluginType t, std::string uid, PluginManager::PluginStatusType stat)
881 Gtk::TreeModel::iterator i;
882 for (i = plugin_model->children().begin(); i != plugin_model->children().end(); ++i) {
883 PluginInfoPtr pp = (*i)[plugin_columns.plugin];
884 if ((pp->type == t) && (pp->unique_id == uid)) {
885 (*i)[plugin_columns.favorite] = (stat == PluginManager::Favorite) ? true : false;
886 (*i)[plugin_columns.hidden] = (stat == PluginManager::Hidden) ? true : false;
888 /* if plug was hidden, remove it from the view */
889 if (stat == PluginManager::Hidden) {
890 if (!_fil_hidden_radio->get_active() && !_fil_all_radio->get_active()) {
891 plugin_model->erase(i);
893 } else if (_fil_hidden_radio->get_active()) {
894 plugin_model->erase(i);
896 /* if no longer a favorite, remove it from the view */
897 if (stat != PluginManager::Favorite && _fil_favorites_radio->get_active()) {
898 plugin_model->erase(i);
901 /* plugin menu must be re-built to accommodate Hidden and Favorite plugins */
910 PluginSelector::on_show ()
912 ArdourDialog::on_show ();
913 search_entry.grab_focus ();
917 _need_tag_save = false;
918 _need_status_save = false;
919 _need_menu_rebuild = false;
922 struct PluginMenuCompareByCreator {
923 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
926 cmp = cmp_nocase_utf8 (a->creator, b->creator);
930 } else if (cmp == 0) {
931 /* same creator ... compare names */
932 if (cmp_nocase_utf8 (a->name, b->name) < 0) {
940 struct PluginMenuCompareByName {
941 bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
944 cmp = cmp_nocase_utf8 (a->name, b->name);
948 } else if (cmp == 0) {
949 /* same name ... compare type */
950 if (a->type < b->type) {
958 /** @return Plugin menu. The caller should not delete it */
960 PluginSelector::plugin_menu()
966 PluginSelector::build_plugin_menu ()
968 PluginInfoList all_plugs;
970 all_plugs.insert (all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
971 all_plugs.insert (all_plugs.end(), manager.lua_plugin_info().begin(), manager.lua_plugin_info().end());
972 #ifdef WINDOWS_VST_SUPPORT
973 all_plugs.insert (all_plugs.end(), manager.windows_vst_plugin_info().begin(), manager.windows_vst_plugin_info().end());
976 all_plugs.insert (all_plugs.end(), manager.lxvst_plugin_info().begin(), manager.lxvst_plugin_info().end());
978 #ifdef MACVST_SUPPORT
979 all_plugs.insert (all_plugs.end(), manager.mac_vst_plugin_info().begin(), manager.mac_vst_plugin_info().end());
981 #ifdef AUDIOUNIT_SUPPORT
982 all_plugs.insert (all_plugs.end(), manager.au_plugin_info().begin(), manager.au_plugin_info().end());
985 all_plugs.insert (all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end());
988 using namespace Menu_Helpers;
992 _plugin_menu = manage (new Menu);
993 _plugin_menu->set_name("ArdourContextMenu");
995 MenuList& items = _plugin_menu->items();
998 Gtk::Menu* favs = create_favs_menu(all_plugs);
999 items.push_back (MenuElem (_("Favorites"), *manage (favs)));
1001 items.push_back (MenuElem (_("Plugin Manager..."), sigc::mem_fun (*this, &PluginSelector::show_manager)));
1002 items.push_back (SeparatorElem ());
1004 Menu* by_creator = create_by_creator_menu(all_plugs);
1005 items.push_back (MenuElem (_("By Creator"), *manage (by_creator)));
1007 Menu* by_tags = create_by_tags_menu(all_plugs);
1008 items.push_back (MenuElem (_("By Tags"), *manage (by_tags)));
1012 GetPluginTypeStr(PluginInfoPtr info)
1016 switch (info->type) {
1018 type = X_(" (LADSPA)");
1024 type = X_(" (LV2)");
1029 type = X_(" (VST)");
1032 type = X_(" (Lua)");
1040 PluginSelector::create_favs_menu (PluginInfoList& all_plugs)
1042 using namespace Menu_Helpers;
1044 Menu* favs = new Menu();
1045 favs->set_name("ArdourContextMenu");
1047 PluginMenuCompareByName cmp_by_name;
1048 all_plugs.sort (cmp_by_name);
1050 for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1051 if (manager.get_status (*i) == PluginManager::Favorite) {
1052 string typ = GetPluginTypeStr(*i);
1053 MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1054 elem.get_child()->set_use_underline (false);
1055 favs->items().push_back (elem);
1062 PluginSelector::create_by_creator_menu (ARDOUR::PluginInfoList& all_plugs)
1064 inhibit_refill = true;
1065 _fil_creator_combo.clear_items ();
1066 _fil_creator_combo.append_text_item (_("Show All Creators"));
1067 _fil_creator_combo.set_text (_("Show All Creators"));
1068 inhibit_refill = false;
1070 using namespace Menu_Helpers;
1072 typedef std::map<std::string,Gtk::Menu*> SubmenuMap;
1073 SubmenuMap creator_submenu_map;
1075 Menu* by_creator = new Menu();
1076 by_creator->set_name("ArdourContextMenu");
1078 MenuList& by_creator_items = by_creator->items();
1079 PluginMenuCompareByCreator cmp_by_creator;
1080 all_plugs.sort (cmp_by_creator);
1082 for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1084 if (manager.get_status (*i) == PluginManager::Hidden) continue;
1086 string creator = (*i)->creator;
1088 /* If there were too few characters to create a
1089 * meaningful name, mark this creator as 'Unknown'
1091 if (creator.length() < 2) {
1092 creator = "Unknown";
1095 SubmenuMap::iterator x;
1097 if ((x = creator_submenu_map.find (creator)) != creator_submenu_map.end()) {
1098 submenu = x->second;
1101 _fil_creator_combo.append_text_item (creator);
1103 submenu = new Gtk::Menu;
1104 by_creator_items.push_back (MenuElem (creator, *manage (submenu)));
1105 creator_submenu_map.insert (pair<std::string,Menu*> (creator, submenu));
1106 submenu->set_name("ArdourContextMenu");
1108 string typ = GetPluginTypeStr(*i);
1109 MenuElem elem ((*i)->name+typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1110 elem.get_child()->set_use_underline (false);
1111 submenu->items().push_back (elem);
1118 PluginSelector::create_by_tags_menu (ARDOUR::PluginInfoList& all_plugs)
1120 using namespace Menu_Helpers;
1122 typedef std::map<std::string,Gtk::Menu*> SubmenuMap;
1123 SubmenuMap tags_submenu_map;
1125 Menu* by_tags = new Menu();
1126 by_tags->set_name("ArdourContextMenu");
1127 MenuList& by_tags_items = by_tags->items();
1129 std::vector<std::string> all_tags = manager.get_all_tags(false);
1130 for (vector<string>::iterator t = all_tags.begin(); t != all_tags.end(); ++t) {
1131 Gtk::Menu *submenu = new Gtk::Menu;
1132 by_tags_items.push_back (MenuElem (*t, *manage (submenu)));
1133 tags_submenu_map.insert (pair<std::string,Menu*> (*t, submenu));
1134 submenu->set_name("ArdourContextMenu");
1137 PluginMenuCompareByName cmp_by_name;
1138 all_plugs.sort (cmp_by_name);
1140 for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1142 if (manager.get_status (*i) == PluginManager::Hidden) continue;
1144 /* for each tag in the plugins tag list, add it to that submenu */
1145 vector<string> tokens = manager.get_tags(*i);
1146 for (vector<string>::iterator t = tokens.begin(); t != tokens.end(); ++t) {
1147 SubmenuMap::iterator x;
1149 if ((x = tags_submenu_map.find (*t)) != tags_submenu_map.end()) {
1150 submenu = x->second;
1153 string typ = GetPluginTypeStr(*i);
1154 MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1155 elem.get_child()->set_use_underline (false);
1156 submenu->items().push_back (elem);
1163 PluginSelector::plugin_chosen_from_menu (const PluginInfoPtr& pi)
1165 PluginPtr p = load_plugin (pi);
1167 if (p && interested_object) {
1168 SelectedPlugins plugins;
1169 plugins.push_back (p);
1170 interested_object->use_plugins (plugins);
1173 interested_object = 0;
1177 PluginSelector::favorite_changed (const std::string& path)
1181 if (in_row_change) {
1185 in_row_change = true;
1187 TreeModel::iterator iter = plugin_model->get_iter (path);
1191 bool favorite = !(*iter)[plugin_columns.favorite];
1195 PluginManager::PluginStatusType status = (favorite ? PluginManager::Favorite : PluginManager::Normal);
1197 /* save new statuses list */
1199 pi = (*iter)[plugin_columns.plugin];
1201 manager.set_status (pi->type, pi->unique_id, status);
1203 _need_status_save = true;
1205 in_row_change = false;
1209 PluginSelector::hidden_changed (const std::string& path)
1213 if (in_row_change) {
1217 in_row_change = true;
1219 TreeModel::iterator iter = plugin_model->get_iter (path);
1223 bool hidden = !(*iter)[plugin_columns.hidden];
1227 PluginManager::PluginStatusType status = (hidden ? PluginManager::Hidden : PluginManager::Normal);
1229 /* save new statuses list */
1231 pi = (*iter)[plugin_columns.plugin];
1233 manager.set_status (pi->type, pi->unique_id, status);
1235 _need_status_save = true;
1237 in_row_change = false;
1241 PluginSelector::show_manager ()
1248 PluginSelector::set_interested_object (PluginInterestedObject& obj)
1250 interested_object = &obj;