2 cleanup patches from nickm, plus work on mixer_ui.cc so that it compiles
[ardour.git] / gtk2_ardour / io_selector.h
1 /*
2     Copyright (C) 2002 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     $Id$
19 */
20
21 #ifndef __ardour_ui_io_selector_h__
22 #define __ardour_ui_io_selector_h__
23
24 #if __GNUC__ >= 3
25 #include <ext/slist>
26 using __gnu_cxx::slist;
27 #else
28 #include <slist.h>
29 #endif
30
31 #include <string>
32 #include <gtkmm.h>
33
34 #include <ardour_dialog.h>
35
36 namespace ARDOUR {
37         class IO;
38         class Session;
39         class PortInsert;
40         class Port;
41         class Redirect;
42 }
43
44 class IOSelector : public Gtk::VBox {
45   public:
46         IOSelector (ARDOUR::Session&, ARDOUR::IO&, bool for_input);
47         ~IOSelector ();
48
49         void redisplay ();
50
51         enum Result {
52                 Cancelled,
53                 Accepted
54         };
55
56         sigc::signal<void,Result> Finished;
57
58   protected:
59         ARDOUR::Session& session;
60
61   private:
62         ARDOUR::IO& io;
63         bool for_input;
64         ARDOUR::Port *selected_port;
65
66         Gtk::VBox main_box;
67         Gtk::HBox port_and_selector_box;
68
69         /* client/port selection */
70
71         Gtk::Notebook notebook;
72         Gtk::Frame selector_frame;
73         Gtk::VBox selector_box;
74         Gtk::HBox selector_button_box;
75
76         /* ports */
77
78         Gtk::VBox port_box;
79         Gtk::HBox port_button_box;
80         Gtk::VBox port_and_button_box;
81         Gtk::Frame port_frame;
82         Gtk::Button add_port_button;
83         Gtk::Button remove_port_button;
84         Gtk::Button clear_connections_button;
85         Gtk::ScrolledWindow port_display_scroller;
86
87         PBD::Lock port_display_lock;
88         slist<Gtk::TreeView *> port_displays;
89         void display_ports ();
90
91         void rescan ();
92         void clear_connections ();
93
94         void port_selection_changed();
95
96         void ports_changed (ARDOUR::IOChange, void *);
97         void name_changed (void*);
98
99         void add_port ();
100         void remove_port ();
101         gint remove_port_when_idle (ARDOUR::Port *);
102
103         gint port_column_button_release (GdkEventButton*, Gtk::TreeView*);
104         gint connection_click (GdkEventButton *, Gtk::TreeView*);
105         
106         void select_clist(Gtk::TreeView*);
107         void select_next_clist ();
108 };
109
110 class IOSelectorWindow : public ArdourDialog
111 {
112   public:
113         IOSelectorWindow (ARDOUR::Session&, ARDOUR::IO&, bool for_input, bool can_cancel=false);
114         ~IOSelectorWindow ();
115
116         IOSelector& selector() { return _selector; }
117
118   protected:
119         bool on_map (GdkEventAny *);
120         
121   private:
122         IOSelector _selector;
123
124         Gtk::VBox vbox;
125
126         /* overall operation buttons */
127
128         Gtk::Button ok_button;
129         Gtk::Button cancel_button;
130         Gtk::Button rescan_button;
131         Gtk::HBox button_box;
132
133         void rescan ();
134         void cancel ();
135         void accept ();
136 };
137
138
139 class PortInsertUI : public Gtk::VBox
140 {
141   public: 
142         PortInsertUI (ARDOUR::Session&, ARDOUR::PortInsert&);
143         
144         void redisplay ();
145         void finished (IOSelector::Result);
146
147   private:
148         
149         Gtk::HBox  hbox;
150         IOSelector input_selector;
151         IOSelector output_selector;
152         
153 };
154
155 class PortInsertWindow : public ArdourDialog
156 {
157   public: 
158         PortInsertWindow (ARDOUR::Session&, ARDOUR::PortInsert&, bool can_cancel=false);
159         
160   protected:
161         bool on_map (GdkEventAny *);
162         
163   private:
164         
165         PortInsertUI _portinsertui;
166         Gtk::VBox vbox;
167         
168         Gtk::Button ok_button;
169         Gtk::Button cancel_button;
170         Gtk::Button rescan_button;
171         Gtk::Frame button_frame;
172         Gtk::HBox button_box;
173         
174         void rescan ();
175         void cancel ();
176         void accept ();
177
178         void plugin_going_away (ARDOUR::Redirect*);
179 };
180
181
182 #endif /* __ardour_ui_io_selector_h__ */