ac300638d728ad8418cd3a5a8d549782d1714734
[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::ScrolledWindow scroller;  // Available plugins
48         Gtk::ScrolledWindow ascroller;  // Added plugins
49
50         Gtk::ComboBoxText filter_mode;
51         Gtk::Entry filter_entry;
52         Gtk::Button filter_button;
53
54         void filter_button_clicked ();
55         void filter_entry_changed ();
56         void filter_mode_changed ();
57         
58         struct PluginColumns : public Gtk::TreeModel::ColumnRecord {
59                 PluginColumns () {
60                         add (name);
61                         add (type_name);
62                         add (category);
63                         add (creator);
64                         add (ins);
65                         add (outs);
66                         add (plugin);
67                 }
68                 Gtk::TreeModelColumn<std::string> name;
69                 Gtk::TreeModelColumn<std::string> type_name;
70                 Gtk::TreeModelColumn<std::string> category;
71                 Gtk::TreeModelColumn<std::string> creator;
72                 Gtk::TreeModelColumn<std::string> ins;
73                 Gtk::TreeModelColumn<std::string> outs;
74                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
75         };
76         PluginColumns plugin_columns;
77         Glib::RefPtr<Gtk::ListStore> plugin_model;
78         Gtk::TreeView plugin_display;
79         Gtk::Button* btn_add;
80         Gtk::Button* btn_remove;
81
82         struct AddedColumns : public Gtk::TreeModel::ColumnRecord {
83                 AddedColumns () {
84                         add (text);
85                         add (plugin);
86                 }
87                 Gtk::TreeModelColumn<std::string> text;
88                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
89         };
90         AddedColumns acols;
91         Glib::RefPtr<Gtk::ListStore> amodel;
92         Gtk::TreeView added_list;
93
94         void refill ();
95         void refiller (const ARDOUR::PluginInfoList& plugs, const::std::string& filterstr, const char* type);
96         void ladspa_refiller (const std::string&);
97         void vst_refiller (const std::string&);
98         void au_refiller (const std::string&);
99
100         ARDOUR::PluginManager *manager;
101
102         void row_clicked(GdkEventButton *);
103         void btn_add_clicked();
104         void btn_remove_clicked();
105         void btn_update_clicked();
106         void added_list_selection_changed();
107         void display_selection_changed();
108         void btn_apply_clicked();
109         void use_plugin (ARDOUR::PluginInfoPtr);
110         void cleanup ();
111         bool show_this_plugin (const ARDOUR::PluginInfoPtr&, const std::string&);
112         void setup_filter_string (std::string&);
113 };
114
115 #endif // __ardour_plugin_selector_h__
116