* Some Export GUI tweaks
[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 */
19
20 #ifndef __ardour_gtk_connection_editor_h__
21 #define __ardour_gtk_connection_editor_h__
22
23 #if __GNUC__ >= 3
24 #include <ext/slist>
25 using __gnu_cxx::slist;
26 #else
27 #include <slist.h>
28 #endif
29
30 #include <gtkmm/box.h>
31 #include <gtkmm/window.h>
32 #include <gtkmm/scrolledwindow.h>
33 #include <gtkmm/button.h>
34 #include <gtkmm/frame.h>
35 #include <gtkmm/notebook.h>
36 #include <gtkmm/treeview.h>
37 #include <gtkmm/liststore.h>
38
39 #include "ardour_dialog.h"
40
41 #include <glibmm/thread.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         void on_map ();
57
58   private:
59         ARDOUR::Connection *current_connection;
60         int                 selected_port;
61         bool                push_at_front;
62
63
64         struct ConnectionDisplayModelColumns : public Gtk::TreeModel::ColumnRecord {
65             ConnectionDisplayModelColumns() { 
66                     add (name);
67                     add (connection);
68             }
69             Gtk::TreeModelColumn<Glib::ustring> name;
70             Gtk::TreeModelColumn<ARDOUR::Connection*> connection;
71         };
72
73         ConnectionDisplayModelColumns connection_columns;
74
75         Glib::RefPtr<Gtk::ListStore> input_connection_model;
76         Glib::RefPtr<Gtk::ListStore> output_connection_model;
77
78         Gtk::TreeView input_connection_display;
79         Gtk::TreeView output_connection_display;
80         Gtk::ScrolledWindow input_scroller;
81         Gtk::ScrolledWindow output_scroller;
82
83         Gtk::Frame input_frame;
84         Gtk::Frame output_frame;
85         Gtk::VBox input_box;
86         Gtk::VBox output_box;
87         Gtk::VBox connection_box;
88
89         Gtk::HBox main_hbox;
90         Gtk::VBox main_vbox;
91
92         Gtk::VBox left_vbox;
93         Gtk::VBox right_vbox;
94         Gtk::VBox port_and_selector_box;
95         
96
97         Gtk::Button new_input_connection_button;
98         Gtk::Button new_output_connection_button;
99         Gtk::Button delete_connection_button;
100
101         /* client/port selection */
102
103         Gtk::Notebook notebook;
104         Gtk::Button clear_client_button;
105         Gtk::Frame selector_frame;
106         Gtk::VBox selector_box;
107         Gtk::HBox selector_button_box;
108
109         /* connection displays */
110
111         Gtk::HBox port_box;
112         Gtk::HBox port_button_box;
113         Gtk::VBox port_and_button_box;
114         Gtk::Frame port_frame;
115         Gtk::Button clear_button;
116         Gtk::Button add_port_button;
117
118         Glib::Mutex port_display_lock;
119         slist<Gtk::ScrolledWindow *> port_displays;
120
121         Gtk::Button ok_button;
122         Gtk::Button cancel_button;
123         Gtk::Button rescan_button;
124
125         Gtk::Frame button_frame;
126         Gtk::HBox  button_box;
127
128         void new_connection (bool for_input);
129         void delete_connection ();
130
131         void display_ports ();
132         void display_connection_state (bool for_input);
133
134         void add_connection (ARDOUR::Connection *);
135         void add_connection_and_select (ARDOUR::Connection *);
136         void proxy_add_connection_and_select (ARDOUR::Connection *);
137         void proxy_remove_connection (ARDOUR::Connection *);
138         void remove_connection (ARDOUR::Connection *);
139         void refill_connection_display ();
140
141         void rescan ();
142         void clear ();
143         void cancel ();
144         void accept ();
145
146         void selection_changed (Gtk::TreeView* display);
147
148         void add_port ();
149         void remove_port (int which_port);
150
151         void port_column_click (gint col, Gtk::TreeView* );
152         gint port_button_event (GdkEventButton *, Gtk::TreeView*);
153         gint connection_click (GdkEventButton *ev, Gtk::TreeView*);
154         void connection_selection_changed (Gtk::TreeView&, Glib::RefPtr<Gtk::ListStore>&);
155
156         sigc::connection config_connection;
157         sigc::connection connect_connection;
158         void configuration_changed (bool);
159         void connections_changed (int, bool);
160 };
161
162 #endif /* __ardour_gtk_connection_editor_h__ */