Speed up plugin-selector refill.
[ardour.git] / gtk2_ardour / plugin_selector.h
1 /*
2     Copyright (C) 2000 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
20 #ifndef __ardour_plugin_selector_h__
21 #define __ardour_plugin_selector_h__
22
23 #include <gtkmm/button.h>
24 #include <gtkmm/checkbutton.h>
25 #include <gtkmm/comboboxtext.h>
26 #include <gtkmm/entry.h>
27 #include <gtkmm/liststore.h>
28 #include <gtkmm/notebook.h>
29 #include <gtkmm/scrolledwindow.h>
30 #include <gtkmm/treemodel.h>
31 #include <gtkmm/treeview.h>
32
33 #include "widgets/ardour_button.h"
34 #include "widgets/ardour_dropdown.h"
35
36 #include "gtkmm2ext/dndtreeview.h"
37
38 #include "ardour/plugin.h"
39 #include "ardour/plugin_manager.h"
40 #include "ardour/session_handle.h"
41
42 #include "widgets/ardour_button.h"
43
44 #include "plugin_interest.h"
45 #include "ardour_dialog.h"
46
47 namespace ARDOUR {
48         class Session;
49         class PluginManager;
50 }
51
52 class PluginSelector : public ArdourDialog
53 {
54 public:
55         PluginSelector (ARDOUR::PluginManager&);
56         ~PluginSelector ();
57
58         void set_interested_object (PluginInterestedObject&);
59
60         int run (); // XXX should we try not to overload the non-virtual Gtk::Dialog::run() ?
61
62         void on_show ();
63
64         Gtk::Menu* plugin_menu ();
65         void show_manager ();
66
67 private:
68
69         //search
70         ArdourWidgets::ArdourButton* _search_name_checkbox;
71         ArdourWidgets::ArdourButton* _search_tags_checkbox;
72         ArdourWidgets::ArdourButton* _search_ignore_checkbox;
73
74         //radio-button filters
75         Gtk::RadioButton *_fil_effects_radio;
76         Gtk::RadioButton *_fil_instruments_radio;
77         Gtk::RadioButton *_fil_utils_radio;
78         Gtk::RadioButton *_fil_favorites_radio;
79         Gtk::RadioButton *_fil_hidden_radio;
80         Gtk::RadioButton *_fil_all_radio;
81
82         /* combobox filters */
83         ArdourWidgets::ArdourDropdown _fil_type_combo;
84         ArdourWidgets::ArdourDropdown _fil_creator_combo;
85         ArdourWidgets::ArdourDropdown _fil_channel_combo;
86
87         PluginInterestedObject* interested_object;
88
89         Gtk::ScrolledWindow scroller;   // Available plugins
90         Gtk::ScrolledWindow ascroller;  // Added plugins
91
92         Gtk::Entry search_entry;
93         Gtk::Button search_clear_button;
94
95         Gtk::Entry *tag_entry;
96         Gtk::Button* tag_reset_button;
97         void tag_reset_button_clicked ();
98
99         void set_sensitive_widgets();
100
101         void search_clear_button_clicked ();
102         void search_entry_changed ();
103
104         void tag_entry_changed ();
105         sigc::connection tag_entry_connection;
106
107         void tags_changed ( ARDOUR::PluginType t, std::string unique_id, std::string tag);
108
109         struct PluginColumns : public Gtk::TreeModel::ColumnRecord {
110                 PluginColumns () {
111                         add (favorite);
112                         add (hidden);
113                         add (name);
114                         add (tags);
115                         add (creator);
116                         add (type_name);
117                         add (audio_io);
118                         add (midi_io);
119                         add (plugin);
120                 }
121                 Gtk::TreeModelColumn<bool> favorite;
122                 Gtk::TreeModelColumn<bool> hidden;
123                 Gtk::TreeModelColumn<std::string> name;
124                 Gtk::TreeModelColumn<std::string> type_name;
125                 Gtk::TreeModelColumn<std::string> creator;
126                 Gtk::TreeModelColumn<std::string> tags;
127                 Gtk::TreeModelColumn<std::string> audio_io;
128                 Gtk::TreeModelColumn<std::string> midi_io;
129                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
130         };
131         PluginColumns plugin_columns;
132         Glib::RefPtr<Gtk::ListStore> plugin_model;
133         Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr> plugin_display;
134         Gtk::Button* btn_add;
135         Gtk::Button* btn_remove;
136
137         struct AddedColumns : public Gtk::TreeModel::ColumnRecord {
138                 AddedColumns () {
139                         add (text);
140                         add (plugin);
141                 }
142                 Gtk::TreeModelColumn<std::string> text;
143                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
144         };
145         AddedColumns acols;
146         Glib::RefPtr<Gtk::ListStore> amodel;
147         Gtk::TreeView added_list;
148
149         void refill ();
150         void refiller (const ARDOUR::PluginInfoList& plugs, const::std::string& filterstr, const char* type);
151         void ladspa_refiller (const std::string&);
152         void lv2_refiller (const std::string&);
153         void vst_refiller (const std::string&);
154         void lxvst_refiller (const std::string&);
155         void mac_vst_refiller (const std::string&);
156         void au_refiller (const std::string&);
157         void lua_refiller (const std::string&);
158
159         Gtk::Menu* _plugin_menu;
160         ARDOUR::PluginManager& manager;
161
162         void row_activated(Gtk::TreeModel::Path path, Gtk::TreeViewColumn* col);
163         void btn_add_clicked();
164         void btn_remove_clicked();
165         void added_list_selection_changed();
166         void added_row_clicked(GdkEventButton* event);
167         void display_selection_changed();
168         void btn_apply_clicked();
169         ARDOUR::PluginPtr load_plugin (ARDOUR::PluginInfoPtr);
170         bool show_this_plugin (const ARDOUR::PluginInfoPtr&, const std::string&);
171
172         void setup_search_string (std::string&);
173
174         void favorite_changed (const std::string& path);
175         void hidden_changed (const std::string& path);
176         bool in_row_change;
177
178         void plugin_chosen_from_menu (const ARDOUR::PluginInfoPtr&);
179
180         void plugin_status_changed ( ARDOUR::PluginType t, std::string unique_id, ARDOUR::PluginManager::PluginStatusType s );
181
182         Gtk::Menu* create_favs_menu (ARDOUR::PluginInfoList&);
183         Gtk::Menu* create_by_creator_menu (ARDOUR::PluginInfoList&);
184         Gtk::Menu* create_by_tags_menu (ARDOUR::PluginInfoList&);
185         void build_plugin_menu ();
186         PBD::ScopedConnectionList plugin_list_changed_connection;
187
188         bool _need_tag_save;
189         bool _need_status_save;
190         bool _need_menu_rebuild;
191
192         bool _inhibit_refill;
193 };
194
195 #endif // __ardour_plugin_selector_h__
196