Add EngineControl::stop_engine method to show errors when stopping engine
[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 #include "ardour/session_handle.h"
30 #include "plugin_interest.h"
31
32 #include "ardour_dialog.h"
33
34 namespace ARDOUR {
35         class Session;
36         class PluginManager;
37 }
38
39 class PluginSelector : public ArdourDialog
40 {
41   public:
42         PluginSelector (ARDOUR::PluginManager&);
43         ~PluginSelector ();
44
45         void set_interested_object (PluginInterestedObject&);
46
47         int run (); // XXX should we try not to overload the non-virtual Gtk::Dialog::run() ?
48
49         void on_show ();
50
51         Gtk::Menu* plugin_menu ();
52         void show_manager ();
53
54   private:
55         PluginInterestedObject* interested_object;
56
57         Gtk::ScrolledWindow scroller;   // Available plugins
58         Gtk::ScrolledWindow ascroller;  // Added plugins
59
60         Gtk::ComboBoxText filter_mode;
61         Gtk::Entry filter_entry;
62         Gtk::Button filter_button;
63
64         void filter_button_clicked ();
65         void filter_entry_changed ();
66         void filter_mode_changed ();
67
68         struct PluginColumns : public Gtk::TreeModel::ColumnRecord {
69                 PluginColumns () {
70                         add (favorite);
71                         add (hidden);
72                         add (name);
73                         add (type_name);
74                         add (category);
75                         add (creator);
76                         add (audio_ins);
77                         add (audio_outs);
78                         add (midi_ins);
79                         add (midi_outs);
80                         add (plugin);
81                 }
82                 Gtk::TreeModelColumn<bool> favorite;
83                 Gtk::TreeModelColumn<bool> hidden;
84                 Gtk::TreeModelColumn<std::string> name;
85                 Gtk::TreeModelColumn<std::string> type_name;
86                 Gtk::TreeModelColumn<std::string> category;
87                 Gtk::TreeModelColumn<std::string> creator;
88                 Gtk::TreeModelColumn<std::string> audio_ins;
89                 Gtk::TreeModelColumn<std::string> audio_outs;
90                 Gtk::TreeModelColumn<std::string> midi_ins;
91                 Gtk::TreeModelColumn<std::string> midi_outs;
92                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
93         };
94         PluginColumns plugin_columns;
95         Glib::RefPtr<Gtk::ListStore> plugin_model;
96         Gtk::TreeView plugin_display;
97         Gtk::Button* btn_add;
98         Gtk::Button* btn_remove;
99
100         struct AddedColumns : public Gtk::TreeModel::ColumnRecord {
101                 AddedColumns () {
102                         add (text);
103                         add (plugin);
104                 }
105                 Gtk::TreeModelColumn<std::string> text;
106                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
107         };
108         AddedColumns acols;
109         Glib::RefPtr<Gtk::ListStore> amodel;
110         Gtk::TreeView added_list;
111
112         void refill ();
113         void refiller (const ARDOUR::PluginInfoList& plugs, const::std::string& filterstr, const char* type);
114         void ladspa_refiller (const std::string&);
115         void lv2_refiller (const std::string&);
116         void vst_refiller (const std::string&);
117         void lxvst_refiller (const std::string&);
118         void au_refiller (const std::string&);
119
120         Gtk::Menu* _plugin_menu;
121         ARDOUR::PluginManager& manager;
122
123         void row_activated(Gtk::TreeModel::Path path, Gtk::TreeViewColumn* col);
124         void btn_add_clicked();
125         void btn_remove_clicked();
126         void added_list_selection_changed();
127         void added_row_clicked(GdkEventButton* event);
128         void display_selection_changed();
129         void btn_apply_clicked();
130         ARDOUR::PluginPtr load_plugin (ARDOUR::PluginInfoPtr);
131         bool show_this_plugin (const ARDOUR::PluginInfoPtr&, const std::string&);
132         void setup_filter_string (std::string&);
133
134         void favorite_changed (const std::string& path);
135         void hidden_changed (const std::string& path);
136         bool in_row_change;
137
138         void plugin_chosen_from_menu (const ARDOUR::PluginInfoPtr&);
139
140         Gtk::Menu* create_favs_menu (ARDOUR::PluginInfoList&);
141         Gtk::Menu* create_by_creator_menu (ARDOUR::PluginInfoList&);
142         Gtk::Menu* create_by_category_menu (ARDOUR::PluginInfoList&);
143         void build_plugin_menu ();
144         PBD::ScopedConnectionList plugin_list_changed_connection;
145 };
146
147 #endif // __ardour_plugin_selector_h__
148