Heavy-duty abstraction work to split type-specific classes into
[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 namespace ARDOUR {
29         class Session;
30         class PluginManager;
31         class Plugin;
32         class PluginInfo;
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;
49         Gtk::ScrolledWindow vscroller;
50         Gtk::ScrolledWindow ascroller;
51
52         // page 1
53         struct LadspaColumns : public Gtk::TreeModel::ColumnRecord {
54                 LadspaColumns () {
55                         add (name);
56                     add (type);
57                         add (ins);
58                         add (outs);
59                         add (plugin);
60                 }
61             Gtk::TreeModelColumn<std::string> name;
62                 Gtk::TreeModelColumn<std::string> type;
63                 Gtk::TreeModelColumn<std::string> ins;
64                 Gtk::TreeModelColumn<std::string> outs;
65             Gtk::TreeModelColumn<ARDOUR::PluginInfo *> plugin;
66         };
67         LadspaColumns lcols;
68         Glib::RefPtr<Gtk::ListStore> lmodel;
69         Glib::RefPtr<Gtk::TreeSelection> lselection;
70         Gtk::TreeView ladspa_display;
71         Gtk::Button* btn_add;
72         Gtk::Button* btn_remove;
73
74         struct AddedColumns : public Gtk::TreeModel::ColumnRecord {
75                 AddedColumns () {
76                         add (text);
77                         add (plugin);
78                 }
79                 Gtk::TreeModelColumn<std::string> text;
80                 Gtk::TreeModelColumn<ARDOUR::PluginInfo *> plugin;
81         };
82         AddedColumns acols;
83         Glib::RefPtr<Gtk::ListStore> amodel;
84         Glib::RefPtr<Gtk::TreeSelection> aselection;
85         Gtk::TreeView added_list;
86
87 #ifdef VST_SUPPORT
88         // page 2
89         struct VstColumns : public Gtk::TreeModel::ColumnRecord {
90                 VstColumns () {
91                         add (name);
92                         add (ins);
93                         add (outs);
94                         add (plugin);
95                 }
96             Gtk::TreeModelColumn<std::string> name;
97                 Gtk::TreeModelColumn<std::string> ins;
98                 Gtk::TreeModelColumn<std::string> outs;
99             Gtk::TreeModelColumn<ARDOUR::PluginInfo *> plugin;
100         };
101         VstColumns vcols;
102         Glib::RefPtr<Gtk::ListStore> vmodel;
103         Glib::RefPtr<Gtk::TreeSelection> vselection;
104         Gtk::TreeView vst_display;
105         static void _vst_refiller (void *);
106         void vst_refiller ();
107         void vst_display_selection_changed();
108 #endif // VST_SUPPORT
109
110 #ifdef HAVE_COREAUDIO
111         // page 3
112         struct AUColumns : public Gtk::TreeModel::ColumnRecord {
113                 AUColumns () {
114                         add (name);
115                         add (ins);
116                         add (outs);
117                         add (plugin);
118                 }
119                 Gtk::TreeModelColumn<std::string> name;
120                 Gtk::TreeModelColumn<std::string> ins;
121                 Gtk::TreeModelColumn<std::string> outs;
122                 Gtk::TreeModelColumn<ARDOUR::PluginInfo *> plugin;
123         };
124         AUColumns aucols;
125         Glib::RefPtr<Gtk::ListStore> aumodel;
126         Glib::RefPtr<Gtk::TreeSelection> auselection;
127         Gtk::TreeView au_display;
128         static void _au_refiller (void *);
129         void au_refiller ();
130         void au_display_selection_changed();
131 #endif //HAVE_COREAUDIO
132
133         ARDOUR::PluginInfo* i_selected_plug;
134
135         // We need an integer for the output side because
136         // the name isn't promised to be unique.
137         gint o_selected_plug;
138
139         ARDOUR::PluginManager *manager;
140         list<ARDOUR::PluginInfo*> added_plugins;
141
142         static void _input_refiller (void *);
143         
144         void input_refiller ();
145         void row_clicked(GdkEventButton *);
146         void btn_add_clicked();
147         void btn_remove_clicked();
148         void btn_update_clicked();
149         void added_list_selection_changed();
150         void ladspa_display_selection_changed();
151         void btn_apply_clicked();
152         void use_plugin (ARDOUR::PluginInfo*);
153         void cleanup ();
154 };
155
156 #endif // __ardour_plugin_selector_h__
157