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