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