Fly my pretties!
[ardour.git] / gtk2_ardour / connection_editor.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_gtk_connection_editor_h__
22 #define __ardour_gtk_connection_editor_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 <gtkmm/box.h>
32 #include <gtkmm/window.h>
33 #include <gtkmm/scrolledwindow.h>
34 #include <gtkmm/button.h>
35 #include <gtkmm/frame.h>
36 #include <gtkmm/notebook.h>
37 #include <gtkmm/clist.h>
38
39 #include "ardour_dialog.h"
40
41 #include <pbd/lockmonitor.h>
42
43 namespace ARDOUR {
44         class Session;
45         class Connection;
46 }
47
48 class ConnectionEditor : public ArdourDialog {
49   public:
50         ConnectionEditor ();
51         ~ConnectionEditor ();
52
53         void set_session (ARDOUR::Session *);
54
55   protected:
56         gint map_event_impl (GdkEventAny *);
57
58   private:
59         ARDOUR::Connection *current_connection;
60         int                 selected_port;
61         bool                push_at_front;
62
63         Gtk::CList input_connection_display;
64         Gtk::CList output_connection_display;
65         Gtk::ScrolledWindow input_scroller;
66         Gtk::ScrolledWindow output_scroller;
67
68         Gtk::Frame input_frame;
69         Gtk::Frame output_frame;
70         Gtk::VBox input_box;
71         Gtk::VBox output_box;
72         Gtk::VBox connection_box;
73
74         Gtk::HBox main_hbox;
75         Gtk::VBox main_vbox;
76
77         Gtk::VBox left_vbox;
78         Gtk::VBox right_vbox;
79         Gtk::VBox port_and_selector_box;
80         
81
82         Gtk::Button new_input_connection_button;
83         Gtk::Button new_output_connection_button;
84         Gtk::Button delete_connection_button;
85
86         /* client/port selection */
87
88         Gtk::Notebook notebook;
89         Gtk::Button clear_client_button;
90         Gtk::Frame selector_frame;
91         Gtk::VBox selector_box;
92         Gtk::HBox selector_button_box;
93
94         /* connection displays */
95
96         Gtk::HBox port_box;
97         Gtk::HBox port_button_box;
98         Gtk::VBox port_and_button_box;
99         Gtk::Frame port_frame;
100         Gtk::Button clear_button;
101         Gtk::Button add_port_button;
102
103         PBD::Lock port_display_lock;
104         slist<Gtk::ScrolledWindow *> port_displays;
105
106         Gtk::Button ok_button;
107         Gtk::Button cancel_button;
108         Gtk::Button rescan_button;
109
110         Gtk::Frame button_frame;
111         Gtk::HBox  button_box;
112
113         void new_connection (bool for_input);
114         void delete_connection ();
115
116         void display_ports ();
117         void display_connection_state (bool for_input);
118
119         void add_connection (ARDOUR::Connection *);
120         void add_connection_and_select (ARDOUR::Connection *);
121         void proxy_add_connection_and_select (ARDOUR::Connection *);
122         void proxy_remove_connection (ARDOUR::Connection *);
123         void remove_connection (ARDOUR::Connection *);
124         void refill_connection_display ();
125
126         void rescan ();
127         void clear ();
128         void cancel ();
129         void accept ();
130
131         void port_selection_handler (gint row, gint col, GdkEvent *ev, Gtk::CList *);
132
133         void add_port ();
134         void remove_port (int which_port);
135
136         void port_column_click (gint col, Gtk::CList *clist);
137         gint port_button_event (GdkEventButton *, Gtk::CList *clist);
138         gint connection_click (GdkEventButton *ev, Gtk::CList *clist);
139         void connection_selected (gint, gint, GdkEvent *, bool);
140
141         sigc::connection config_connection;
142         sigc::connection connect_connection;
143         void configuration_changed (bool);
144         void connections_changed (int, bool);
145 };
146
147 #endif /* __ardour_gtk_connection_editor_h__ */