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