add filtering to plugin selection dialog
[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/dialog.h>
24 #include <gtkmm/notebook.h>
25 #include <gtkmm/treeview.h>
26 #include <gtkmm2ext/selector.h>
27
28 #include <ardour/plugin.h>
29
30 namespace ARDOUR {
31         class Session;
32         class PluginManager;
33 }
34
35 class PluginSelector : public ArdourDialog
36 {
37   public:
38         PluginSelector (ARDOUR::PluginManager *);
39         sigc::signal<void,boost::shared_ptr<ARDOUR::Plugin> > PluginCreated;
40
41         int run (); // XXX should we try not to overload the non-virtual Gtk::Dialog::run() ?
42
43         void set_session (ARDOUR::Session*);
44
45   private:
46         ARDOUR::Session* session;
47         Gtk::Notebook notebook;
48         Gtk::ScrolledWindow lscroller;  // ladspa
49         Gtk::ScrolledWindow vscroller;  // vst
50         Gtk::ScrolledWindow auscroller; // AudioUnit
51         Gtk::ScrolledWindow ascroller;  // Added plugins
52
53         Gtk::ComboBoxText filter_mode;
54         Gtk::Entry filter_entry;
55         Gtk::Button filter_button;
56
57         void filter_button_clicked ();
58         void filter_entry_changed ();
59         void filter_mode_changed ();
60         
61         ARDOUR::PluginType current_selection;
62
63         // page 1
64         struct LadspaColumns : public Gtk::TreeModel::ColumnRecord {
65                 LadspaColumns () {
66                         add (name);
67                     add (type);
68                         add (ins);
69                         add (outs);
70                         add (plugin);
71                 }
72             Gtk::TreeModelColumn<std::string> name;
73                 Gtk::TreeModelColumn<std::string> type;
74                 Gtk::TreeModelColumn<std::string> ins;
75                 Gtk::TreeModelColumn<std::string> outs;
76             Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
77         };
78         LadspaColumns lcols;
79         Glib::RefPtr<Gtk::ListStore> lmodel;
80         Glib::RefPtr<Gtk::TreeSelection> lselection;
81         Gtk::TreeView ladspa_display;
82         Gtk::Button* btn_add;
83         Gtk::Button* btn_remove;
84
85         struct AddedColumns : public Gtk::TreeModel::ColumnRecord {
86                 AddedColumns () {
87                         add (text);
88                         add (plugin);
89                 }
90                 Gtk::TreeModelColumn<std::string> text;
91                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
92         };
93         AddedColumns acols;
94         Glib::RefPtr<Gtk::ListStore> amodel;
95         Glib::RefPtr<Gtk::TreeSelection> aselection;
96         Gtk::TreeView added_list;
97
98 #ifdef VST_SUPPORT
99         // page 2
100         struct VstColumns : public Gtk::TreeModel::ColumnRecord {
101                 VstColumns () {
102                         add (name);
103                         add (ins);
104                         add (outs);
105                         add (plugin);
106                 }
107             Gtk::TreeModelColumn<std::string> name;
108                 Gtk::TreeModelColumn<std::string> ins;
109                 Gtk::TreeModelColumn<std::string> outs;
110             Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
111         };
112         VstColumns vcols;
113         Glib::RefPtr<Gtk::ListStore> vmodel;
114         Glib::RefPtr<Gtk::TreeSelection> vselection;
115         Gtk::TreeView vst_display;
116         static void _vst_refiller (void *);
117         void vst_refiller ();
118         void vst_display_selection_changed();
119 #endif // VST_SUPPORT
120
121 #ifdef HAVE_AUDIOUNIT
122         // page 3
123         struct AUColumns : public Gtk::TreeModel::ColumnRecord {
124                 AUColumns () {
125                         add (name);
126                         add (ins);
127                         add (outs);
128                         add (plugin);
129                 }
130                 Gtk::TreeModelColumn<std::string> name;
131                 Gtk::TreeModelColumn<std::string> ins;
132                 Gtk::TreeModelColumn<std::string> outs;
133                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
134         };
135         AUColumns aucols;
136         Glib::RefPtr<Gtk::ListStore> aumodel;
137         Glib::RefPtr<Gtk::TreeSelection> auselection;
138         Gtk::TreeView au_display;
139         static void _au_refiller (void *);
140         void au_refiller ();
141         void au_display_selection_changed();
142 #endif //HAVE_AUDIOUNIT
143
144         ARDOUR::PluginManager *manager;
145
146         static void _ladspa_refiller (void *);
147         
148         void ladspa_refiller ();
149         void row_clicked(GdkEventButton *);
150         void btn_add_clicked();
151         void btn_remove_clicked();
152         void btn_update_clicked();
153         void added_list_selection_changed();
154         void ladspa_display_selection_changed();
155         void btn_apply_clicked();
156         void use_plugin (ARDOUR::PluginInfoPtr);
157         void cleanup ();
158         void refill ();
159
160         void set_correct_focus();
161 };
162
163 #endif // __ardour_plugin_selector_h__
164