Further tweaks to Plugin-Selector:
[ardour.git] / gtk2_ardour / plugin_selector.cc
1 /*
2     Copyright (C) 2000-2006 Paul Davis
3
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.
8
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.
13
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.
17
18 */
19 #ifdef WAF_BUILD
20 #include "gtk2ardour-config.h"
21 #endif
22
23 #include <cstdio>
24 #include <map>
25
26 #include <algorithm>
27
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>
35
36 #include "gtkmm2ext/utils.h"
37
38 #include "widgets/tooltips.h"
39
40 #include "pbd/convert.h"
41 #include "pbd/tokenizer.h"
42
43 #include "ardour/utils.h"
44
45 #include "plugin_selector.h"
46 #include "gui_thread.h"
47
48 #include "pbd/i18n.h"
49
50 using namespace ARDOUR;
51 using namespace PBD;
52 using namespace Gtk;
53 using namespace std;
54 using namespace ArdourWidgets;
55
56 static const uint32_t MAX_CREATOR_LEN = 24;
57
58 PluginSelector::PluginSelector (PluginManager& mgr)
59         : ArdourDialog (_("Plugin Manager"), true, false)
60         , search_clear_button (Stock::CLEAR)
61         , manager (mgr)
62         , inhibit_refill (false)
63 {
64         set_name ("PluginSelectorWindow");
65         add_events (Gdk::KEY_PRESS_MASK|Gdk::KEY_RELEASE_MASK);
66
67         _plugin_menu = 0;
68         in_row_change = false;
69
70         manager.PluginListChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::build_plugin_menu, this), gui_context());
71         manager.PluginListChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::refill, this), gui_context());
72         manager.PluginStatusesChanged.connect (plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::plugin_status_changed, this, _1, _2, _3), gui_context());
73         manager.PluginTagsChanged.connect(plugin_list_changed_connection, invalidator (*this), boost::bind (&PluginSelector::tags_changed, this, _1, _2, _3), gui_context());
74
75         plugin_model = Gtk::ListStore::create (plugin_columns);
76         plugin_display.set_model (plugin_model);
77         /* XXX translators: try to convert "Fav" into a short term
78          * related to "favorite" and "Hid" into a short term
79          * related to "hidden"
80          */
81         plugin_display.append_column (_("Fav"), plugin_columns.favorite);
82         plugin_display.append_column (_("Hide"), plugin_columns.hidden);
83         plugin_display.append_column (_("Name"), plugin_columns.name);
84         plugin_display.append_column (_("Tags"), plugin_columns.tags);
85         plugin_display.append_column (_("Creator"), plugin_columns.creator);
86         plugin_display.append_column (_("Type"), plugin_columns.type_name);
87         plugin_display.append_column (_("Audio I/O"),plugin_columns.audio_io);
88         plugin_display.append_column (_("MIDI I/O"), plugin_columns.midi_io);
89         plugin_display.set_headers_visible (true);
90         plugin_display.set_headers_clickable (true);
91         plugin_display.set_reorderable (false);
92         plugin_display.set_rules_hint (true);
93         plugin_display.add_object_drag (plugin_columns.plugin.index(), "PluginInfoPtr");
94         plugin_display.set_drag_column (plugin_columns.name.index());
95
96         // setting a sort-column prevents re-ordering via Drag/Drop
97         plugin_model->set_sort_column (plugin_columns.name.index(), Gtk::SORT_ASCENDING);
98
99         plugin_display.set_name("PluginSelectorDisplay");
100         plugin_display.signal_row_activated().connect_notify (sigc::mem_fun(*this, &PluginSelector::row_activated));
101         plugin_display.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &PluginSelector::display_selection_changed));
102
103         CellRendererToggle* fav_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (0));
104         fav_cell->property_activatable() = true;
105         fav_cell->property_radio() = true;
106         fav_cell->signal_toggled().connect (sigc::mem_fun (*this, &PluginSelector::favorite_changed));
107
108         CellRendererToggle* hidden_cell = dynamic_cast<CellRendererToggle*>(plugin_display.get_column_cell_renderer (1));
109         hidden_cell->property_activatable() = true;
110         hidden_cell->property_radio() = true;
111         hidden_cell->signal_toggled().connect (sigc::mem_fun (*this, &PluginSelector::hidden_changed));
112
113         scroller.set_border_width(10);
114         scroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
115         scroller.add(plugin_display);
116
117         amodel = Gtk::ListStore::create(acols);
118         added_list.set_model (amodel);
119         added_list.append_column (_("Plugins to be connected"), acols.text);
120         added_list.set_headers_visible (true);
121         added_list.set_reorderable (false);
122
123         for (int i = 2; i <= 7; i++) {
124                 Gtk::TreeView::Column* column = plugin_display.get_column(i);
125                 if (column) {
126                         column->set_sort_column(i);
127                 }
128         }
129
130         ascroller.set_border_width(10);
131         ascroller.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC);
132         ascroller.add(added_list);
133         btn_add = manage(new Gtk::Button(Stock::ADD));
134         set_tooltip(*btn_add, _("Add a plugin to the effect list"));
135         btn_add->set_sensitive (false);
136         btn_remove = manage(new Gtk::Button(Stock::REMOVE));
137         btn_remove->set_sensitive (false);
138         set_tooltip(*btn_remove, _("Remove a plugin from the effect list"));
139
140         btn_add->set_name("PluginSelectorButton");
141         btn_remove->set_name("PluginSelectorButton");
142
143         /* SEARCH */
144
145         Gtk::Table* search_table = manage(new Gtk::Table(2, 2));
146
147         search_entry.signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::search_entry_changed));
148         search_clear_button.signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::search_clear_button_clicked));
149
150         _search_name_checkbox = manage (new CheckButton (_("Name")));
151         _search_name_checkbox->set_active();
152
153         _search_tags_checkbox = manage (new CheckButton (_("Tags")));
154         _search_tags_checkbox->set_active();
155
156         _search_ignore_checkbox = manage (new CheckButton(_("Ignore Filters when searching")));
157         _search_ignore_checkbox->set_active();
158         _search_ignore_checkbox->signal_toggled().connect (sigc::mem_fun (*this, &PluginSelector::set_sensitive_widgets));
159
160         Gtk::Label* search_help_label1 = manage (new Label(
161                 _("All search terms must be matched."), Gtk::ALIGN_LEFT));
162
163         Gtk::Label* search_help_label2 = manage (new Label(
164                 _("Ex: \"ess dyn\" will find \"dynamic de-esser\" but not \"de-esser\"."), Gtk::ALIGN_LEFT));
165
166         search_table->attach (search_entry,            0, 3, 0, 1, FILL|EXPAND, FILL);
167         search_table->attach (search_clear_button,     3, 4, 0, 1, FILL, FILL);
168         search_table->attach (*_search_name_checkbox,  0, 1, 1, 2, FILL, FILL);
169         search_table->attach (*_search_tags_checkbox,  1, 2, 1, 2, FILL, FILL);
170         search_table->attach (*_search_ignore_checkbox,2, 3, 1, 2, FILL, FILL);
171         search_table->attach (*search_help_label1,     0, 3, 2, 3, FILL, FILL);
172         search_table->attach (*search_help_label2,     0, 3, 3, 4, FILL, FILL);
173
174         search_table->set_border_width (4);
175         search_table->set_col_spacings (4);
176         search_table->set_row_spacings (4);
177
178         Frame* search_frame = manage (new Frame);
179         search_frame->set_name ("BaseFrame");
180         search_frame->set_label (_("Search"));
181         search_frame->add (*search_table);
182         search_frame->show_all ();
183
184         _search_name_checkbox->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
185         _search_tags_checkbox->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
186
187         /* FILTER */
188
189         Gtk::Table* filter_table = manage(new Gtk::Table(1, 10));
190
191         Gtk::RadioButtonGroup fil_radio_group;
192
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")));
199
200         _fil_type_combo = manage (new ComboBoxText);
201         _fil_type_combo->append_text (_("Show All Formats"));
202         _fil_type_combo->append_text (X_("VST"));
203 #ifdef AUDIOUNIT_SUPPORT
204         _fil_type_combo->append_text (X_("AudioUnit"));
205 #endif
206 #ifdef LV2_SUPPORT
207         _fil_type_combo->append_text (X_("LV2"));
208 #endif
209         _fil_type_combo->append_text (X_("LUA"));
210         _fil_type_combo->append_text (X_("LADSPA"));
211         _fil_type_combo->set_active_text (_("Show All Formats"));
212
213         _fil_creator_combo = manage (new ComboBoxText);
214         //note: _fil_creator_combo menu gets filled in build_plugin_menu
215
216         _fil_channel_combo = manage (new ComboBoxText);
217         _fil_channel_combo->append_text (_("Audio I/O"));
218         _fil_channel_combo->append_text (_("Mono Audio I/O"));
219         _fil_channel_combo->append_text (_("Stereo Audio I/O"));
220         _fil_channel_combo->append_text (_("MIDI I/O (only)"));
221         _fil_channel_combo->append_text (_("Show All I/O"));
222 #ifdef MIXBUS
223         _fil_channel_combo->set_active_text (_("Audio I/O"));
224 #else
225         _fil_channel_combo->set_active_text (_("Show All I/O"));
226 #endif
227
228         int p = 0;
229         filter_table->attach (*_fil_effects_radio,       2, 3, p, p+1, FILL, FILL); p++;
230         filter_table->attach (*_fil_instruments_radio,   2, 3, p, p+1, FILL, FILL); p++;
231         filter_table->attach (*_fil_utils_radio,         2, 3, p, p+1, FILL, FILL); p++;
232         filter_table->attach (*_fil_favorites_radio,     2, 3, p, p+1, FILL, FILL); p++;
233         filter_table->attach (*_fil_hidden_radio,        2, 3, p, p+1, FILL, FILL); p++;
234         filter_table->attach (*_fil_all_radio,           2, 3, p, p+1, FILL, FILL); p++;
235         filter_table->attach (*_fil_type_combo,          2, 3, p, p+1, FILL, FILL); p++;
236         filter_table->attach (*_fil_creator_combo,       2, 3, p, p+1, FILL, FILL); p++;
237         filter_table->attach (*_fil_channel_combo,       2, 3, p, p+1, FILL, FILL); p++;
238
239         filter_table->set_border_width (4);
240         filter_table->set_col_spacings (4);
241         filter_table->set_row_spacings (4);
242
243         Frame* filter_frame = manage (new Frame);
244         filter_frame->set_name ("BaseFrame");
245         filter_frame->set_label (_("Filter"));
246         filter_frame->add (*filter_table);
247         filter_frame->show_all ();
248
249         _fil_effects_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
250         _fil_instruments_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
251         _fil_utils_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
252         _fil_favorites_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
253         _fil_hidden_radio->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::refill));
254
255         _fil_type_combo->signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::refill));
256         _fil_creator_combo->signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::refill));
257         _fil_channel_combo->signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::refill));
258
259         /* TAG entry */
260
261         Gtk::Table* tagging_table = manage(new Gtk::Table(1, 2));
262         tagging_table->set_border_width (4);
263         tagging_table->set_col_spacings (4);
264         tagging_table->set_row_spacings (4);
265
266         tag_entry = manage (new Gtk::Entry);
267         tag_entry_connection = tag_entry->signal_changed().connect (sigc::mem_fun (*this, &PluginSelector::tag_entry_changed));
268
269         Gtk::Button* tag_reset_button = manage (new Button (_("Reset")));
270         tag_reset_button->signal_clicked().connect (sigc::mem_fun (*this, &PluginSelector::tag_reset_button_clicked));
271
272         Gtk::Label* tagging_help_label1 = manage (new Label(
273                 _("Enter space-separated, one-word Tags for the selected plugin."), Gtk::ALIGN_LEFT));
274
275         Gtk::Label* tagging_help_label2 = manage (new Label(
276                 _("You can include dashes, colons or underscores in a Tag."), Gtk::ALIGN_LEFT));
277
278         Gtk::Label* tagging_help_label3 = manage (new Label(
279                 _("Ex: \"dynamic de-esser vocal\" applies 3 Tags."), Gtk::ALIGN_LEFT));
280
281         p = 0;
282         tagging_table->attach (*tag_entry,           0, 1, p, p+1, FILL|EXPAND, FILL);
283         tagging_table->attach (*tag_reset_button,    1, 2, p, p+1, FILL, FILL); p++;
284         tagging_table->attach (*tagging_help_label1, 0, 2, p, p+1, FILL, FILL); p++;
285         tagging_table->attach (*tagging_help_label2, 0, 2, p, p+1, FILL, FILL); p++;
286         tagging_table->attach (*tagging_help_label3, 0, 2, p, p+1, FILL, FILL); p++;
287
288         Frame* tag_frame = manage (new Frame);
289         tag_frame->set_name ("BaseFrame");
290         tag_frame->set_label (_("Tags for Selected Plugin"));
291         tag_frame->add (*tagging_table);
292         tag_frame->show_all ();
293
294         /* Add & remove buttons */
295
296         HBox* add_remove = manage (new HBox);
297         add_remove->pack_start (*btn_add, true, true);
298         add_remove->pack_start (*btn_remove, true, true);
299
300         btn_add->signal_clicked().connect(sigc::mem_fun(*this, &PluginSelector::btn_add_clicked));
301         btn_remove->signal_clicked().connect(sigc::mem_fun(*this, &PluginSelector::btn_remove_clicked));
302         added_list.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &PluginSelector::added_list_selection_changed));
303         added_list.signal_button_press_event().connect_notify (mem_fun(*this, &PluginSelector::added_row_clicked));
304
305         added_list.set_name("PluginSelectorList");
306
307         /* Top-level Layout */
308
309         VBox* to_be_inserted_vbox = manage (new VBox);
310         to_be_inserted_vbox->pack_start (ascroller);
311         to_be_inserted_vbox->pack_start (*add_remove, false, false);
312         to_be_inserted_vbox->set_size_request (200, -1);
313
314         Gtk::Table* table = manage(new Gtk::Table(3, 3));
315         table->set_size_request(-1, 600);
316         table->attach (scroller,               0, 3, 0, 5); /* this is the main plugin list */
317         table->attach (*search_frame,          0, 1, 6, 7, FILL, FILL, 5, 5);
318         table->attach (*tag_frame,             0, 1, 7, 8, FILL, FILL, 5, 5);
319         table->attach (*filter_frame,          1, 2, 6, 8, FILL, FILL, 5, 5);
320         table->attach (*to_be_inserted_vbox,   2, 3, 6, 8, FILL|EXPAND, FILL, 5, 5); /* to be inserted... */
321
322         add_button (Stock::CLOSE, RESPONSE_CLOSE);
323         add_button (_("Insert Plugin(s)"), RESPONSE_APPLY);
324         set_default_response (RESPONSE_APPLY);
325         set_response_sensitive (RESPONSE_APPLY, false);
326         get_vbox()->pack_start (*table);
327
328         table->set_name("PluginSelectorTable");
329
330         plugin_display.grab_focus();
331
332         build_plugin_menu ();
333 }
334
335 PluginSelector::~PluginSelector ()
336 {
337         delete _plugin_menu;
338 }
339
340 void
341 PluginSelector::row_activated(Gtk::TreeModel::Path, Gtk::TreeViewColumn*)
342 {
343         btn_add_clicked();
344 }
345
346 void
347 PluginSelector::added_row_clicked(GdkEventButton* event)
348 {
349         if (event->type == GDK_2BUTTON_PRESS)
350                 btn_remove_clicked();
351 }
352
353 bool
354 PluginSelector::show_this_plugin (const PluginInfoPtr& info, const std::string& searchstr)
355 {
356         string mode;
357         bool maybe_show = false;
358
359         if (!searchstr.empty()) {
360
361                 std::string compstr;
362
363                 if (_search_name_checkbox->get_active()) { /* name contains */
364                         compstr = info->name;
365                         transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
366                         if (compstr.find (searchstr) != string::npos) {
367                                 maybe_show = true;
368                         }
369                 }
370
371                 if (_search_tags_checkbox->get_active()) { /* tag contains */
372                         compstr = manager.get_tags_as_string (info);
373                         transform (compstr.begin(), compstr.end(), compstr.begin(), ::toupper);
374                         if (compstr.find (searchstr) != string::npos) {
375                                 maybe_show = true;
376                         }
377                 }
378
379                 if (!maybe_show) {
380                         return false;
381                 }
382
383                 /* user asked to ignore filters */
384                 if (maybe_show && _search_ignore_checkbox->get_active()) {
385                         return true;
386                 }
387         }
388
389         if (_fil_effects_radio->get_active() && !info->is_effect()) {
390                 return false;
391         }
392
393         if (_fil_instruments_radio->get_active() && !info->is_instrument()) {
394                 return false;
395         }
396
397         if (_fil_utils_radio->get_active() && !(info->is_utility() || info->is_analyzer())) {
398                 return false;
399         }
400
401         if (_fil_favorites_radio->get_active() && !(manager.get_status (info) == PluginManager::Favorite)) {
402                 return false;
403         }
404
405         if (_fil_hidden_radio->get_active() && !(manager.get_status (info) == PluginManager::Hidden)) {
406                 return false;
407         }
408
409         if (manager.get_status (info) == PluginManager::Hidden) {
410                 if (!_fil_hidden_radio->get_active() && !_fil_all_radio->get_active()) {
411                         return false;
412                 }
413         }
414
415         /* Filter "type" combobox */
416
417         if (_fil_type_combo->get_active_text() == X_("VST") && PluginManager::to_generic_vst(info->type) != LXVST) {
418                 return false;
419         }
420
421         if (_fil_type_combo->get_active_text() == X_("AudioUnit") && info->type != AudioUnit) {
422                 return false;
423         }
424
425 #ifdef LV2_SUPPORT
426         if (_fil_type_combo->get_active_text() == X_("LV2") && info->type != LV2) {
427                 return false;
428         }
429 #endif
430
431         if (_fil_type_combo->get_active_text() == X_("LUA") && info->type != Lua) {
432                 return false;
433         }
434
435         if (_fil_type_combo->get_active_text() == X_("LADSPA") && info->type != LADSPA) {
436                 return false;
437         }
438
439         /* Filter "creator" combobox */
440
441         if (_fil_creator_combo->get_active_text() != _("Show All Creators")) {
442                 string cmp = info->creator;
443                 if (cmp.length() > MAX_CREATOR_LEN) {
444                         cmp = cmp.substr (0, MAX_CREATOR_LEN);
445                         cmp.append("...");
446                 }
447                 if (_fil_creator_combo->get_active_text() != cmp) {
448                         return false;
449                 }
450         }
451
452         /* Filter "I/O" combobox */
453
454         if (_fil_channel_combo->get_active_text() != _("Show All I/O") || info->reconfigurable_io ()) {
455
456 #if 0
457                 if (info->reconfigurable_io ()) {
458                         return true; // who knows.... ?
459                 }
460 #endif
461
462                 if (_fil_channel_combo->get_active_text() == _("Audio I/O")) {
463                         if ((info->n_inputs.n_audio() == 0 || info->n_outputs.n_audio() == 0)) {
464                                 return false;
465                         }
466                 }
467
468                 if (_fil_channel_combo->get_active_text() == _("Mono Audio I/O")) {
469                         if (info->n_inputs.n_audio() != 1 || info->n_outputs.n_audio() != 1) {
470                                 return false;
471                         }
472                 }
473
474                 if (_fil_channel_combo->get_active_text() == _("Stereo Audio I/O")) {
475                         if (info->n_inputs.n_audio() != 2 || info->n_outputs.n_audio() != 2) {
476                                 return false;
477                         }
478                 }
479
480                 if (_fil_channel_combo->get_active_text() == _("MIDI I/O (only)")) {
481                         if ((info->n_inputs.n_audio() != 0 || info->n_outputs.n_audio() == 0)) {
482                                 return false;
483                         }
484                 }
485
486         }
487
488         return true;
489 }
490
491 void
492 PluginSelector::setup_search_string (string& searchstr)
493 {
494         searchstr = search_entry.get_text ();
495         transform (searchstr.begin(), searchstr.end(), searchstr.begin(), ::toupper);
496 }
497
498 void
499 PluginSelector::set_sensitive_widgets ()
500 {
501         if (_search_ignore_checkbox->get_active() && !search_entry.get_text().empty()) {
502                 _fil_effects_radio->set_sensitive(false);
503                 _fil_instruments_radio->set_sensitive(false);
504                 _fil_utils_radio->set_sensitive(false);
505                 _fil_favorites_radio->set_sensitive(false);
506                 _fil_hidden_radio->set_sensitive(false);
507                 _fil_all_radio->set_sensitive(false);
508                 _fil_type_combo->set_sensitive(false);
509                 _fil_creator_combo->set_sensitive(false);
510                 _fil_channel_combo->set_sensitive(false);
511         } else {
512                 _fil_effects_radio->set_sensitive(true);
513                 _fil_instruments_radio->set_sensitive(true);
514                 _fil_utils_radio->set_sensitive(true);
515                 _fil_favorites_radio->set_sensitive(true);
516                 _fil_hidden_radio->set_sensitive(true);
517                 _fil_all_radio->set_sensitive(true);
518                 _fil_type_combo->set_sensitive(true);
519                 _fil_creator_combo->set_sensitive(true);
520                 _fil_channel_combo->set_sensitive(true);
521         }
522         if (!search_entry.get_text().empty()) {
523                 refill ();
524         }
525 }
526
527 void
528 PluginSelector::refill ()
529 {
530         if (inhibit_refill) {
531                 return;
532         }
533
534         std::string searchstr;
535
536         in_row_change = true;
537
538         plugin_model->clear ();
539
540         setup_search_string (searchstr);
541
542         ladspa_refiller (searchstr);
543         lv2_refiller (searchstr);
544         vst_refiller (searchstr);
545         lxvst_refiller (searchstr);
546         mac_vst_refiller (searchstr);
547         au_refiller (searchstr);
548         lua_refiller (searchstr);
549
550         in_row_change = false;
551 }
552
553 void
554 PluginSelector::refiller (const PluginInfoList& plugs, const::std::string& searchstr, const char* type)
555 {
556         char buf[16];
557
558         for (PluginInfoList::const_iterator i = plugs.begin(); i != plugs.end(); ++i) {
559
560                 if (show_this_plugin (*i, searchstr)) {
561
562                         TreeModel::Row newrow = *(plugin_model->append());
563                         newrow[plugin_columns.favorite] = (manager.get_status (*i) == PluginManager::Favorite);
564                         newrow[plugin_columns.hidden] = (manager.get_status (*i) == PluginManager::Hidden);
565
566                         string name = (*i)->name;
567                         if (name.length() > 48) {
568                                 name = name.substr (0, 48);
569                                 name.append("...");
570                         }
571                         newrow[plugin_columns.name] = name;
572
573                         newrow[plugin_columns.type_name] = type;
574                         newrow[plugin_columns.category] = (*i)->category;
575
576                         /* Creator */
577                         string creator = (*i)->creator;
578                         string::size_type pos = 0;
579                         if ((*i)->type == ARDOUR::LADSPA) {
580                                 /* stupid LADSPA creator strings */
581 #ifdef PLATFORM_WINDOWS
582                                 while (pos < creator.length() && creator[pos] > -2 && creator[pos] < 256 && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
583 #else
584                                 while (pos < creator.length() && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
585 #endif
586                         } else {
587                                 pos = creator.length ();
588                         }
589                         // If there were too few characters to create a
590                         // meaningful name, mark this creator as 'Unknown'
591                         if (creator.length() < 2 || pos < 3) {
592                                 creator = "Unknown";
593                         } else{
594                                 creator = creator.substr (0, pos);
595                         }
596
597                         if (creator.length() > MAX_CREATOR_LEN) {
598                                 creator = creator.substr (0, MAX_CREATOR_LEN);
599                                 creator.append("...");
600                         }
601                         newrow[plugin_columns.creator] = creator;
602
603                         /* Tags */
604                         string tags = manager.get_tags_as_string(*i);
605                         if (tags.length() > 32) {
606                                 tags = tags.substr (0, 32);
607                                 tags.append("...");
608                         }
609                         newrow[plugin_columns.tags] = tags;
610
611                         if ((*i)->reconfigurable_io ()) {
612                                 newrow[plugin_columns.audio_io] = "* / *";
613                                 newrow[plugin_columns.midi_io] = "* / *";
614                         } else {
615                                 snprintf (buf, sizeof(buf), "%d / %d", (*i)->n_inputs.n_audio(), (*i)->n_outputs.n_audio());
616                                 newrow[plugin_columns.audio_io] = buf;
617                                 snprintf (buf, sizeof(buf), "%d / %d", (*i)->n_inputs.n_audio(), (*i)->n_outputs.n_audio());
618                                 newrow[plugin_columns.midi_io] = buf;
619                         }
620
621                         newrow[plugin_columns.plugin] = *i;
622                 }
623         }
624 }
625
626 void
627 PluginSelector::ladspa_refiller (const std::string& searchstr)
628 {
629         refiller (manager.ladspa_plugin_info(), searchstr, "LADSPA");
630 }
631
632 void
633 PluginSelector::lua_refiller (const std::string& searchstr)
634 {
635         refiller (manager.lua_plugin_info(), searchstr, "Lua");
636 }
637
638 void
639 PluginSelector::lv2_refiller (const std::string& searchstr)
640 {
641 #ifdef LV2_SUPPORT
642         refiller (manager.lv2_plugin_info(), searchstr, "LV2");
643 #endif
644 }
645
646 void
647 #ifdef WINDOWS_VST_SUPPORT
648 PluginSelector::vst_refiller (const std::string& searchstr)
649 #else
650 PluginSelector::vst_refiller (const std::string&)
651 #endif
652 {
653 #ifdef WINDOWS_VST_SUPPORT
654         refiller (manager.windows_vst_plugin_info(), searchstr, "VST");
655 #endif
656 }
657
658 void
659 #ifdef LXVST_SUPPORT
660 PluginSelector::lxvst_refiller (const std::string& searchstr)
661 #else
662 PluginSelector::lxvst_refiller (const std::string&)
663 #endif
664 {
665 #ifdef LXVST_SUPPORT
666         refiller (manager.lxvst_plugin_info(), searchstr, "LXVST");
667 #endif
668 }
669
670 void
671 #ifdef MACVST_SUPPORT
672 PluginSelector::mac_vst_refiller (const std::string& searchstr)
673 #else
674 PluginSelector::mac_vst_refiller (const std::string&)
675 #endif
676 {
677 #ifdef MACVST_SUPPORT
678         refiller (manager.mac_vst_plugin_info(), searchstr, "MacVST");
679 #endif
680 }
681
682 void
683 #ifdef AUDIOUNIT_SUPPORT
684 PluginSelector::au_refiller (const std::string& searchstr)
685 #else
686 PluginSelector::au_refiller (const std::string&)
687 #endif
688 {
689 #ifdef AUDIOUNIT_SUPPORT
690         refiller (manager.au_plugin_info(), searchstr, "AU");
691 #endif
692 }
693
694 PluginPtr
695 PluginSelector::load_plugin (PluginInfoPtr pi)
696 {
697         if (_session == 0) {
698                 return PluginPtr();
699         }
700
701         return pi->load (*_session);
702 }
703
704 void
705 PluginSelector::btn_add_clicked()
706 {
707         std::string name;
708         PluginInfoPtr pi;
709         TreeModel::Row newrow = *(amodel->append());
710         TreeModel::Row row;
711
712         row = *(plugin_display.get_selection()->get_selected());
713         name = row[plugin_columns.name];
714         pi = row[plugin_columns.plugin];
715
716         newrow[acols.text] = name;
717         newrow[acols.plugin] = pi;
718
719         if (!amodel->children().empty()) {
720                 set_response_sensitive (RESPONSE_APPLY, true);
721         }
722 }
723
724 void
725 PluginSelector::btn_remove_clicked()
726 {
727         TreeModel::iterator iter = added_list.get_selection()->get_selected();
728
729         amodel->erase(iter);
730         if (amodel->children().empty()) {
731                 set_response_sensitive (RESPONSE_APPLY, false);
732         }
733 }
734
735 void
736 PluginSelector::display_selection_changed()
737 {
738         tag_entry_connection.block ();
739         if (plugin_display.get_selection()->count_selected_rows() != 0) {
740
741                 /* a plugin row is selected; allow the user to edit the "tags" on it. */
742                 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
743                 string tags = manager.get_tags_as_string (row[plugin_columns.plugin]);
744                 tag_entry->set_text (tags);
745
746                 tag_entry->set_sensitive (true);
747                 btn_add->set_sensitive (true);
748
749         } else {
750                 tag_entry->set_text ("");
751
752                 tag_entry->set_sensitive (false);
753                 btn_add->set_sensitive (false);
754         }
755         tag_entry_connection.unblock ();
756 }
757
758 void
759 PluginSelector::added_list_selection_changed()
760 {
761         if (added_list.get_selection()->count_selected_rows() != 0) {
762                 btn_remove->set_sensitive (true);
763         } else {
764                 btn_remove->set_sensitive (false);
765         }
766 }
767
768 int
769 PluginSelector::run ()
770 {
771         ResponseType r;
772         TreeModel::Children::iterator i;
773
774         bool finish = false;
775
776         while (!finish) {
777
778                 SelectedPlugins plugins;
779                 r = (ResponseType) Dialog::run ();
780
781                 switch (r) {
782                 case RESPONSE_APPLY:
783                         for (i = amodel->children().begin(); i != amodel->children().end(); ++i) {
784                                 PluginInfoPtr pp = (*i)[acols.plugin];
785                                 PluginPtr p = load_plugin (pp);
786                                 if (p) {
787                                         plugins.push_back (p);
788                                 } else {
789                                         MessageDialog msg (string_compose (_("The plugin \"%1\" could not be loaded\n\nSee the Log window for more details (maybe)"), pp->name));
790                                         msg.run ();
791                                 }
792                         }
793                         if (interested_object && !plugins.empty()) {
794                                 finish = !interested_object->use_plugins (plugins);
795                         }
796
797                         break;
798
799                 default:
800                         finish = true;
801                         break;
802                 }
803         }
804
805
806         hide();
807         amodel->clear();
808         interested_object = 0;
809
810         if (_need_tag_save) {
811                 manager.save_tags();
812         }
813
814         if (_need_status_save) {
815                 manager.save_statuses();
816         }
817
818         if (_need_menu_rebuild) {
819                 build_plugin_menu();
820         }
821
822         return (int) r;
823 }
824
825 void
826 PluginSelector::search_clear_button_clicked ()
827 {
828         search_entry.set_text ("");
829 }
830
831 void
832 PluginSelector::tag_reset_button_clicked ()
833 {
834         /* XXX: this should probably be a backend function
835          * -> remove "category" from GUI and code-dup to set
836          * factory tags in PluginManager */
837         if (plugin_display.get_selection()->count_selected_rows() != 0) {
838                 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
839                 std::string str = row[plugin_columns.category];
840                 std::transform (str.begin(), str.end(), str.begin(), ::tolower);
841
842                 ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin];
843                 manager.set_tags (pi->type, pi->unique_id, str, true, true);
844                 _need_tag_save = true;
845         }
846 }
847
848 void
849 PluginSelector::search_entry_changed ()
850 {
851         set_sensitive_widgets();
852         if (search_entry.get_text().empty()) {
853                 refill ();
854         }
855 }
856
857 void
858 PluginSelector::tag_entry_changed ()
859 {
860         if (plugin_display.get_selection()->count_selected_rows() != 0) {
861                 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
862
863                 ARDOUR::PluginInfoPtr pi = row[plugin_columns.plugin];
864                 manager.set_tags (pi->type, pi->unique_id, tag_entry->get_text(), false);
865
866                 _need_tag_save = true;
867         }
868 }
869
870 void
871 PluginSelector::tags_changed (PluginType t, std::string unique_id, std::string tags)
872 {
873         if (plugin_display.get_selection()->count_selected_rows() != 0) {
874                 TreeModel::Row row = *(plugin_display.get_selection()->get_selected());
875                 if (tags.length() > 32) {
876                         tags = tags.substr (0, 32);
877                         tags.append ("...");
878                 }
879                 row[plugin_columns.tags] = tags;
880         }
881
882         /* A plugin's tags change while the user is entering them.
883          * defer a rebuilding of the "tag" menu until the dialog is closed.
884          */
885         _need_menu_rebuild = true;
886 }
887
888 void
889 PluginSelector::plugin_status_changed (PluginType t, std::string uid, PluginManager::PluginStatusType stat)
890 {
891         Gtk::TreeModel::iterator i;
892         for (i = plugin_model->children().begin(); i != plugin_model->children().end(); ++i) {
893                 PluginInfoPtr pp = (*i)[plugin_columns.plugin];
894                 if ((pp->type == t) && (pp->unique_id == uid)) {
895                         (*i)[plugin_columns.favorite] = (stat == PluginManager::Favorite) ? true : false;
896                         (*i)[plugin_columns.hidden] = (stat == PluginManager::Hidden) ? true : false;
897
898                         /* if plug was hidden, remove it from the view */
899                         if (stat == PluginManager::Hidden) {
900                                 if (!_fil_hidden_radio->get_active() && !_fil_all_radio->get_active()) {
901                                         plugin_model->erase(i);
902                                 }
903                         } else if (_fil_hidden_radio->get_active()) {
904                                 plugin_model->erase(i);
905                         }
906                         /* if no longer a favorite, remove it from the view */
907                         if (stat != PluginManager::Favorite && _fil_favorites_radio->get_active()) {
908                                         plugin_model->erase(i);
909                         }
910
911                         /* plugin menu must be re-built to accommodate Hidden and Favorite plugins */
912                         build_plugin_menu();
913
914                         return;
915                 }
916         }
917 }
918
919 void
920 PluginSelector::on_show ()
921 {
922         ArdourDialog::on_show ();
923         search_entry.grab_focus ();
924
925         refill ();
926
927         _need_tag_save = false;
928         _need_status_save = false;
929         _need_menu_rebuild = false;
930 }
931
932 struct PluginMenuCompareByCreator {
933         bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
934                 int cmp;
935
936                 cmp = cmp_nocase_utf8 (a->creator, b->creator);
937
938                 if (cmp < 0) {
939                         return true;
940                 } else if (cmp == 0) {
941                         /* same creator ... compare names */
942                         if (cmp_nocase_utf8 (a->name, b->name) < 0) {
943                                 return true;
944                         }
945                 }
946                 return false;
947         }
948 };
949
950 struct PluginMenuCompareByName {
951         bool operator() (PluginInfoPtr a, PluginInfoPtr b) const {
952                 int cmp;
953
954                 cmp = cmp_nocase_utf8 (a->name, b->name);
955
956                 if (cmp < 0) {
957                         return true;
958                 } else if (cmp == 0) {
959                         /* same name ... compare type */
960                         if (a->type < b->type) {
961                                 return true;
962                         }
963                 }
964                 return false;
965         }
966 };
967
968 /** @return Plugin menu. The caller should not delete it */
969 Gtk::Menu*
970 PluginSelector::plugin_menu()
971 {
972         return _plugin_menu;
973 }
974
975 void
976 PluginSelector::build_plugin_menu ()
977 {
978         PluginInfoList all_plugs;
979
980         all_plugs.insert (all_plugs.end(), manager.ladspa_plugin_info().begin(), manager.ladspa_plugin_info().end());
981         all_plugs.insert (all_plugs.end(), manager.lua_plugin_info().begin(), manager.lua_plugin_info().end());
982 #ifdef WINDOWS_VST_SUPPORT
983         all_plugs.insert (all_plugs.end(), manager.windows_vst_plugin_info().begin(), manager.windows_vst_plugin_info().end());
984 #endif
985 #ifdef LXVST_SUPPORT
986         all_plugs.insert (all_plugs.end(), manager.lxvst_plugin_info().begin(), manager.lxvst_plugin_info().end());
987 #endif
988 #ifdef MACVST_SUPPORT
989         all_plugs.insert (all_plugs.end(), manager.mac_vst_plugin_info().begin(), manager.mac_vst_plugin_info().end());
990 #endif
991 #ifdef AUDIOUNIT_SUPPORT
992         all_plugs.insert (all_plugs.end(), manager.au_plugin_info().begin(), manager.au_plugin_info().end());
993 #endif
994 #ifdef LV2_SUPPORT
995         all_plugs.insert (all_plugs.end(), manager.lv2_plugin_info().begin(), manager.lv2_plugin_info().end());
996 #endif
997
998         using namespace Menu_Helpers;
999
1000         delete _plugin_menu;
1001
1002         _plugin_menu = manage (new Menu);
1003         _plugin_menu->set_name("ArdourContextMenu");
1004
1005         MenuList& items = _plugin_menu->items();
1006         items.clear ();
1007
1008         Gtk::Menu* favs = create_favs_menu(all_plugs);
1009         items.push_back (MenuElem (_("Favorites"), *manage (favs)));
1010
1011         items.push_back (MenuElem (_("Plugin Manager..."), sigc::mem_fun (*this, &PluginSelector::show_manager)));
1012         items.push_back (SeparatorElem ());
1013
1014         Menu* by_creator = create_by_creator_menu(all_plugs);
1015         items.push_back (MenuElem (_("By Creator"), *manage (by_creator)));
1016
1017         Menu* by_tags = create_by_tags_menu(all_plugs);
1018         items.push_back (MenuElem (_("By Tags"), *manage (by_tags)));
1019 }
1020
1021 string
1022 GetPluginTypeStr(PluginInfoPtr info)
1023 {
1024         string type;
1025
1026         switch (info->type) {
1027         case LADSPA:
1028                 type = X_(" (LADSPA)");
1029                 break;
1030         case AudioUnit:
1031                 type = X_(" (AU)");
1032                 break;
1033         case LV2:
1034                 type = X_(" (LV2)");
1035                 break;
1036         case Windows_VST:
1037         case LXVST:
1038         case MacVST:
1039                 type = X_(" (VST)");
1040                 break;
1041         case Lua:
1042                 type = X_(" (Lua)");
1043                 break;
1044         }
1045
1046         return type;
1047 }
1048
1049 Gtk::Menu*
1050 PluginSelector::create_favs_menu (PluginInfoList& all_plugs)
1051 {
1052         using namespace Menu_Helpers;
1053
1054         Menu* favs = new Menu();
1055         favs->set_name("ArdourContextMenu");
1056
1057         PluginMenuCompareByName cmp_by_name;
1058         all_plugs.sort (cmp_by_name);
1059
1060         for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1061                 if (manager.get_status (*i) == PluginManager::Favorite) {
1062                         string typ = GetPluginTypeStr(*i);
1063                         MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1064                         elem.get_child()->set_use_underline (false);
1065                         favs->items().push_back (elem);
1066                 }
1067         }
1068         return favs;
1069 }
1070
1071 Gtk::Menu*
1072 PluginSelector::create_by_creator_menu (ARDOUR::PluginInfoList& all_plugs)
1073 {
1074         inhibit_refill = true;
1075         _fil_creator_combo->clear();
1076         _fil_creator_combo->append_text (_("Show All Creators"));
1077         _fil_creator_combo->set_active_text (_("Show All Creators"));
1078         inhibit_refill = false;
1079
1080         using namespace Menu_Helpers;
1081
1082         typedef std::map<std::string,Gtk::Menu*> SubmenuMap;
1083         SubmenuMap creator_submenu_map;
1084
1085         Menu* by_creator = new Menu();
1086         by_creator->set_name("ArdourContextMenu");
1087
1088         MenuList& by_creator_items = by_creator->items();
1089         PluginMenuCompareByCreator cmp_by_creator;
1090         all_plugs.sort (cmp_by_creator);
1091
1092         for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1093
1094                 if (manager.get_status (*i) == PluginManager::Hidden) continue;
1095
1096                 string creator = (*i)->creator;
1097                 string::size_type pos = 0;
1098
1099                 if ((*i)->type == ARDOUR::LADSPA) {
1100                         /* stupid LADSPA creator strings */
1101 #ifdef PLATFORM_WINDOWS
1102                         while (pos < creator.length() && creator[pos] > -2 && creator[pos] < 256 && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
1103 #else
1104                         while (pos < creator.length() && (isalnum (creator[pos]) || isspace (creator[pos]))) ++pos;
1105 #endif
1106                 } else {
1107                         pos = creator.length ();
1108                 }
1109
1110                 /* If there were too few characters to create a
1111                  * meaningful name, mark this creator as 'Unknown'
1112                  */
1113                 if (creator.length() < 2 || pos < 3) {
1114                         creator = "Unknown";
1115                 } else{
1116                         creator = creator.substr (0, pos);
1117                 }
1118
1119                 /* trim the creator length so we don't make a giant pulldown menu */
1120                 if (creator.length() > MAX_CREATOR_LEN) {
1121                         creator = creator.substr (0, MAX_CREATOR_LEN);
1122                         creator.append("...");
1123                 }
1124
1125                 SubmenuMap::iterator x;
1126                 Gtk::Menu* submenu;
1127                 if ((x = creator_submenu_map.find (creator)) != creator_submenu_map.end()) {
1128                         submenu = x->second;
1129                 } else {
1130
1131                         _fil_creator_combo->append_text(creator);
1132
1133                         submenu = new Gtk::Menu;
1134                         by_creator_items.push_back (MenuElem (creator, *manage (submenu)));
1135                         creator_submenu_map.insert (pair<std::string,Menu*> (creator, submenu));
1136                         submenu->set_name("ArdourContextMenu");
1137                 }
1138                 string typ = GetPluginTypeStr(*i);
1139                 MenuElem elem ((*i)->name+typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1140                 elem.get_child()->set_use_underline (false);
1141                 submenu->items().push_back (elem);
1142         }
1143
1144         return by_creator;
1145 }
1146
1147 Gtk::Menu*
1148 PluginSelector::create_by_tags_menu (ARDOUR::PluginInfoList& all_plugs)
1149 {
1150         using namespace Menu_Helpers;
1151
1152         typedef std::map<std::string,Gtk::Menu*> SubmenuMap;
1153         SubmenuMap tags_submenu_map;
1154
1155         Menu* by_tags = new Menu();
1156         by_tags->set_name("ArdourContextMenu");
1157         MenuList& by_tags_items = by_tags->items();
1158
1159         std::vector<std::string> all_tags = manager.get_all_tags(false);
1160         for (vector<string>::iterator t = all_tags.begin(); t != all_tags.end(); ++t) {
1161                 Gtk::Menu *submenu = new Gtk::Menu;
1162                 by_tags_items.push_back (MenuElem (*t, *manage (submenu)));
1163                 tags_submenu_map.insert (pair<std::string,Menu*> (*t, submenu));
1164                 submenu->set_name("ArdourContextMenu");
1165         }
1166
1167         PluginMenuCompareByName cmp_by_name;
1168         all_plugs.sort (cmp_by_name);
1169
1170         for (PluginInfoList::const_iterator i = all_plugs.begin(); i != all_plugs.end(); ++i) {
1171
1172                 if (manager.get_status (*i) == PluginManager::Hidden) continue;
1173
1174                 /* for each tag in the plugins tag list, add it to that submenu */
1175                 vector<string> tokens = manager.get_tags(*i);
1176                 for (vector<string>::iterator t = tokens.begin(); t != tokens.end(); ++t) {
1177                         SubmenuMap::iterator x;
1178                         Gtk::Menu* submenu;
1179                         if ((x = tags_submenu_map.find (*t)) != tags_submenu_map.end()) {
1180                                 submenu = x->second;
1181                         } else {
1182                         }
1183                         string typ = GetPluginTypeStr(*i);
1184                         MenuElem elem ((*i)->name + typ, (sigc::bind (sigc::mem_fun (*this, &PluginSelector::plugin_chosen_from_menu), *i)));
1185                         elem.get_child()->set_use_underline (false);
1186                         submenu->items().push_back (elem);
1187                 }
1188         }
1189         return by_tags;
1190 }
1191
1192 void
1193 PluginSelector::plugin_chosen_from_menu (const PluginInfoPtr& pi)
1194 {
1195         PluginPtr p = load_plugin (pi);
1196
1197         if (p && interested_object) {
1198                 SelectedPlugins plugins;
1199                 plugins.push_back (p);
1200                 interested_object->use_plugins (plugins);
1201         }
1202
1203         interested_object = 0;
1204 }
1205
1206 void
1207 PluginSelector::favorite_changed (const std::string& path)
1208 {
1209         PluginInfoPtr pi;
1210
1211         if (in_row_change) {
1212                 return;
1213         }
1214
1215         in_row_change = true;
1216
1217         TreeModel::iterator iter = plugin_model->get_iter (path);
1218
1219         if (iter) {
1220
1221                 bool favorite = !(*iter)[plugin_columns.favorite];
1222
1223                 /* change state */
1224
1225                 PluginManager::PluginStatusType status = (favorite ? PluginManager::Favorite : PluginManager::Normal);
1226
1227                 /* save new statuses list */
1228
1229                 pi = (*iter)[plugin_columns.plugin];
1230
1231                 manager.set_status (pi->type, pi->unique_id, status);
1232
1233                 _need_status_save = true;
1234         }
1235         in_row_change = false;
1236 }
1237
1238 void
1239 PluginSelector::hidden_changed (const std::string& path)
1240 {
1241         PluginInfoPtr pi;
1242
1243         if (in_row_change) {
1244                 return;
1245         }
1246
1247         in_row_change = true;
1248
1249         TreeModel::iterator iter = plugin_model->get_iter (path);
1250
1251         if (iter) {
1252
1253                 bool hidden = !(*iter)[plugin_columns.hidden];
1254
1255                 /* change state */
1256
1257                 PluginManager::PluginStatusType status = (hidden ? PluginManager::Hidden : PluginManager::Normal);
1258
1259                 /* save new statuses list */
1260
1261                 pi = (*iter)[plugin_columns.plugin];
1262
1263                 manager.set_status (pi->type, pi->unique_id, status);
1264
1265                 _need_status_save = true;
1266         }
1267         in_row_change = false;
1268 }
1269
1270 void
1271 PluginSelector::show_manager ()
1272 {
1273         show_all();
1274         run ();
1275 }
1276
1277 void
1278 PluginSelector::set_interested_object (PluginInterestedObject& obj)
1279 {
1280         interested_object = &obj;
1281 }