71d201cd8df2a3bfe2022ae5bccff71e40feb841
[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/treeview.h>
38 #include <gtkmm/liststore.h>
39
40 #include "ardour_dialog.h"
41
42 #include <glibmm/thread.h>
43
44 namespace ARDOUR {
45         class Session;
46         class Connection;
47 }
48
49 class ConnectionEditor : public ArdourDialog {
50   public:
51         ConnectionEditor ();
52         ~ConnectionEditor ();
53
54         void set_session (ARDOUR::Session *);
55
56   protected:
57         void on_map ();
58
59   private:
60         ARDOUR::Connection *current_connection;
61         int                 selected_port;
62         bool                push_at_front;
63
64
65         struct ConnectionDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
66             ConnectionDisplayModelColumns() { 
67                     add (name);
68                     add (connection);
69             }
70             Gtk::TreeModelColumn<Glib::ustring> name;
71             Gtk::TreeModelColumn<ARDOUR::Connection*> connection;
72         };
73
74         ConnectionDisplayModelColumns connection_columns;
75
76         Glib::RefPtr<Gtk::ListStore> input_connection_model;
77         Glib::RefPtr<Gtk::ListStore> output_connection_model;
78
79         Gtk::TreeView input_connection_display;
80         Gtk::TreeView output_connection_display;
81         Gtk::ScrolledWindow input_scroller;
82         Gtk::ScrolledWindow output_scroller;
83
84         Gtk::Frame input_frame;
85         Gtk::Frame output_frame;
86         Gtk::VBox input_box;
87         Gtk::VBox output_box;
88         Gtk::VBox connection_box;
89
90         Gtk::HBox main_hbox;
91         Gtk::VBox main_vbox;
92
93         Gtk::VBox left_vbox;
94         Gtk::VBox right_vbox;
95         Gtk::VBox port_and_selector_box;
96         
97
98         Gtk::Button new_input_connection_button;
99         Gtk::Button new_output_connection_button;
100         Gtk::Button delete_connection_button;
101
102         /* client/port selection */
103
104         Gtk::Notebook notebook;
105         Gtk::Button clear_client_button;
106         Gtk::Frame selector_frame;
107         Gtk::VBox selector_box;
108         Gtk::HBox selector_button_box;
109
110         /* connection displays */
111
112         Gtk::HBox port_box;
113         Gtk::HBox port_button_box;
114         Gtk::VBox port_and_button_box;
115         Gtk::Frame port_frame;
116         Gtk::Button clear_button;
117         Gtk::Button add_port_button;
118
119         Glib::Mutex port_display_lock;
120         slist<Gtk::ScrolledWindow *> port_displays;
121
122         Gtk::Button ok_button;
123         Gtk::Button cancel_button;
124         Gtk::Button rescan_button;
125
126         Gtk::Frame button_frame;
127         Gtk::HBox  button_box;
128
129         void new_connection (bool for_input);
130         void delete_connection ();
131
132         void display_ports ();
133         void display_connection_state (bool for_input);
134
135         void add_connection (ARDOUR::Connection *);
136         void add_connection_and_select (ARDOUR::Connection *);
137         void proxy_add_connection_and_select (ARDOUR::Connection *);
138         void proxy_remove_connection (ARDOUR::Connection *);
139         void remove_connection (ARDOUR::Connection *);
140         void refill_connection_display ();
141
142         void rescan ();
143         void clear ();
144         void cancel ();
145         void accept ();
146
147         void selection_changed (Gtk::TreeView* display);
148
149         void add_port ();
150         void remove_port (int which_port);
151
152         void port_column_click (gint col, Gtk::TreeView* );
153         gint port_button_event (GdkEventButton *, Gtk::TreeView*);
154         gint connection_click (GdkEventButton *ev, Gtk::TreeView*);
155         void connection_selection_changed (Gtk::TreeView&, Glib::RefPtr<Gtk::ListStore>&);
156
157         sigc::connection config_connection;
158         sigc::connection connect_connection;
159         void configuration_changed (bool);
160         void connections_changed (int, bool);
161 };
162
163 #endif /* __ardour_gtk_connection_editor_h__ */