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