fix commentary
[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/button.h>
24 #include <gtkmm/checkbutton.h>
25 #include <gtkmm/comboboxtext.h>
26 #include <gtkmm/entry.h>
27 #include <gtkmm/liststore.h>
28 #include <gtkmm/notebook.h>
29 #include <gtkmm/scrolledwindow.h>
30 #include <gtkmm/treemodel.h>
31 #include <gtkmm/treeview.h>
32
33 #include "widgets/ardour_button.h"
34 #include "widgets/ardour_dropdown.h"
35
36 #include "gtkmm2ext/dndtreeview.h"
37
38 #include "ardour/plugin.h"
39 #include "ardour/plugin_manager.h"
40 #include "ardour/session_handle.h"
41
42 #include "widgets/ardour_button.h"
43
44 #include "plugin_interest.h"
45 #include "ardour_dialog.h"
46
47 namespace ARDOUR {
48         class Session;
49         class PluginManager;
50 }
51
52 class PluginSelector : public ArdourDialog
53 {
54 public:
55         PluginSelector (ARDOUR::PluginManager&);
56         ~PluginSelector ();
57
58         void set_interested_object (PluginInterestedObject&);
59
60         int run (); // XXX should we try not to overload the non-virtual Gtk::Dialog::run() ?
61
62         void on_show ();
63
64         Gtk::Menu* plugin_menu ();
65         void show_manager ();
66
67 private:
68
69         //search
70         ArdourWidgets::ArdourButton* _search_name_checkbox;
71         ArdourWidgets::ArdourButton* _search_tags_checkbox;
72         ArdourWidgets::ArdourButton* _search_ignore_checkbox;
73
74         //radio-button filters
75         Gtk::RadioButton *_fil_effects_radio;
76         Gtk::RadioButton *_fil_instruments_radio;
77         Gtk::RadioButton *_fil_utils_radio;
78         Gtk::RadioButton *_fil_favorites_radio;
79         Gtk::RadioButton *_fil_hidden_radio;
80         Gtk::RadioButton *_fil_all_radio;
81
82         /* combobox filters */
83         ArdourWidgets::ArdourDropdown _fil_type_combo;
84         ArdourWidgets::ArdourDropdown _fil_creator_combo;
85
86         PluginInterestedObject* interested_object;
87
88         Gtk::ScrolledWindow scroller;   // Available plugins
89         Gtk::ScrolledWindow ascroller;  // Added plugins
90
91         Gtk::Entry search_entry;
92         Gtk::Button search_clear_button;
93
94         Gtk::Entry *tag_entry;
95         Gtk::Button* tag_reset_button;
96         void tag_reset_button_clicked ();
97
98         void set_sensitive_widgets();
99
100         void search_clear_button_clicked ();
101         void search_entry_changed ();
102
103         void tag_entry_changed ();
104         sigc::connection tag_entry_connection;
105
106         void tags_changed ( ARDOUR::PluginType t, std::string unique_id, std::string tag);
107
108         struct PluginColumns : public Gtk::TreeModel::ColumnRecord {
109                 PluginColumns () {
110                         add (favorite);
111                         add (hidden);
112                         add (name);
113                         add (tags);
114                         add (creator);
115                         add (type_name);
116                         add (audio_io);
117                         add (midi_io);
118                         add (plugin);
119                 }
120                 Gtk::TreeModelColumn<bool> favorite;
121                 Gtk::TreeModelColumn<bool> hidden;
122                 Gtk::TreeModelColumn<std::string> name;
123                 Gtk::TreeModelColumn<std::string> type_name;
124                 Gtk::TreeModelColumn<std::string> creator;
125                 Gtk::TreeModelColumn<std::string> tags;
126                 Gtk::TreeModelColumn<std::string> audio_io;
127                 Gtk::TreeModelColumn<std::string> midi_io;
128                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
129         };
130         PluginColumns plugin_columns;
131         Glib::RefPtr<Gtk::ListStore> plugin_model;
132         Gtkmm2ext::DnDTreeView<ARDOUR::PluginInfoPtr> plugin_display;
133         Gtk::Button* btn_add;
134         Gtk::Button* btn_remove;
135
136         struct AddedColumns : public Gtk::TreeModel::ColumnRecord {
137                 AddedColumns () {
138                         add (text);
139                         add (plugin);
140                 }
141                 Gtk::TreeModelColumn<std::string> text;
142                 Gtk::TreeModelColumn<ARDOUR::PluginInfoPtr> plugin;
143         };
144         AddedColumns acols;
145         Glib::RefPtr<Gtk::ListStore> amodel;
146         Gtk::TreeView added_list;
147
148         void refill ();
149         void refiller (const ARDOUR::PluginInfoList& plugs, const::std::string& filterstr, const char* type);
150         void ladspa_refiller (const std::string&);
151         void lv2_refiller (const std::string&);
152         void vst_refiller (const std::string&);
153         void lxvst_refiller (const std::string&);
154         void mac_vst_refiller (const std::string&);
155         void au_refiller (const std::string&);
156         void lua_refiller (const std::string&);
157
158         Gtk::Menu* _plugin_menu;
159         ARDOUR::PluginManager& manager;
160
161         void row_activated(Gtk::TreeModel::Path path, Gtk::TreeViewColumn* col);
162         void btn_add_clicked();
163         void btn_remove_clicked();
164         void added_list_selection_changed();
165         void added_row_clicked(GdkEventButton* event);
166         void display_selection_changed();
167         void btn_apply_clicked();
168         ARDOUR::PluginPtr load_plugin (ARDOUR::PluginInfoPtr);
169         bool show_this_plugin (const ARDOUR::PluginInfoPtr&, const std::string&);
170
171         void setup_search_string (std::string&);
172
173         void favorite_changed (const std::string& path);
174         void hidden_changed (const std::string& path);
175         bool in_row_change;
176
177         void plugin_chosen_from_menu (const ARDOUR::PluginInfoPtr&);
178
179         void plugin_status_changed ( ARDOUR::PluginType t, std::string unique_id, ARDOUR::PluginManager::PluginStatusType s );
180
181         Gtk::Menu* create_favs_menu (ARDOUR::PluginInfoList&);
182         Gtk::Menu* create_by_creator_menu (ARDOUR::PluginInfoList&);
183         Gtk::Menu* create_by_tags_menu (ARDOUR::PluginInfoList&);
184         void build_plugin_menu ();
185         PBD::ScopedConnectionList plugin_list_changed_connection;
186
187         bool _need_tag_save;
188         bool _need_status_save;
189         bool _need_menu_rebuild;
190
191         bool _inhibit_refill;
192 };
193
194 #endif // __ardour_plugin_selector_h__
195