Merge libs/ardour and gtk2_ardour with 2.0-ongoing R2837.
[ardour.git] / gtk2_ardour / new_session_dialog.h
1 /*
2     Copyright (C) 2005 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 // -*- c++ -*-
21
22 #ifndef NEW_SESSION_DIALOG_H
23 #define NEW_SESSION_DIALOG_H
24
25 #include <string>
26 #include <gtkmm/treeview.h>
27 #include <gtkmm/treestore.h>
28 #include <gtkmm/treepath.h>
29 #include <gtkmm/scrolledwindow.h>
30 #include <gtkmm/notebook.h>
31 #include <gtkmm/table.h>
32 #include <gtkmm/alignment.h>
33 #include <gtkmm/frame.h>
34 #include <gtkmm/expander.h>
35
36 #include <ardour/utils.h>
37
38 #include <glibmm/refptr.h>
39
40 #include "ardour_dialog.h"
41 #include "engine_dialog.h"
42
43 namespace Gtk {
44         class Entry;
45         class FileChooserButton;
46         class SpinButton;
47         class CheckButton;
48         class RadioButton;
49         class TreeView;
50         class Notebook;
51 }
52
53 class NewSessionDialog : public ArdourDialog
54 {
55 public:
56                 
57         NewSessionDialog();
58         ~NewSessionDialog ();
59
60         int run ();
61
62         void set_session_name(const Glib::ustring& name);
63         void set_session_folder(const Glib::ustring& folder);
64
65         std::string session_name() const;
66         std::string session_folder() const;
67         
68         bool use_session_template() const;
69         std::string session_template_name() const;
70
71         // advanced.
72
73         bool create_master_bus() const;
74         int master_channel_count() const;
75
76         bool create_control_bus() const;
77         int control_channel_count() const;
78
79         bool connect_inputs() const;
80         bool limit_inputs_used_for_connection() const;
81         int input_limit_count() const;
82
83         bool connect_outputs() const;
84         bool limit_outputs_used_for_connection() const;
85         int output_limit_count() const;
86
87         bool connect_outs_to_master() const;
88         bool connect_outs_to_physical() const ;
89
90         bool on_newable_page() const;
91         int  get_current_page () const;
92         void set_current_page (int);
93         void reset_recent();
94
95         // reset everything to default values.
96         void reset();
97
98         EngineControl engine_control;
99         void set_have_engine (bool yn);
100         void set_existing_session (bool yn);
101
102 protected:
103
104         void reset_name();
105         void reset_template();
106
107         Gtk::Label * session_name_label;
108         Gtk::Label * session_location_label;
109         Gtk::Label * session_template_label;
110         Gtk::Label * chan_count_label_1;
111         Gtk::Label * chan_count_label_2;
112         Gtk::Label * chan_count_label_3;
113         Gtk::Label * chan_count_label_4;
114         Gtk::Table * advanced_table;
115         Gtk::HBox * input_port_limit_hbox;
116         Gtk::VBox * input_port_vbox;
117         Gtk::Table * input_table;
118         Gtk::HBox * input_hbox;
119
120         Gtk::Label * bus_label;
121         Gtk::Frame * bus_frame;
122         Gtk::Table * bus_table;
123         Gtk::HBox * bus_hbox;
124
125         Gtk::Label * input_label;
126         Gtk::Frame * input_frame;
127         Gtk::HBox * output_port_limit_hbox;
128         Gtk::VBox * output_port_vbox;
129         Gtk::VBox * output_conn_vbox;
130         Gtk::VBox * output_vbox;
131         Gtk::HBox * output_hbox;
132
133         Gtk::Label * output_label;
134         Gtk::Frame * output_frame;
135         Gtk::VBox * advanced_vbox;
136         Gtk::Label * advanced_label;
137         Gtk::Expander * advanced_expander;
138         Gtk::Table * new_session_table;
139         Gtk::HBox * open_session_hbox;
140         Gtk::ScrolledWindow * recent_scrolledwindow;
141
142         Gtk::Label * recent_sesion_label;
143         Gtk::Frame * recent_frame;
144         Gtk::VBox * open_session_vbox;
145         Gtk::Entry*  m_name;
146         Gtk::FileChooserButton* m_folder;
147         Gtk::FileChooserButton* m_template;
148         Gtk::Label * open_session_file_label;
149
150         Gtk::CheckButton* m_create_master_bus;
151         Gtk::SpinButton* m_master_bus_channel_count;
152         
153         Gtk::CheckButton* m_create_control_bus;
154         Gtk::SpinButton* m_control_bus_channel_count;
155
156         Gtk::CheckButton* m_connect_inputs;
157         Gtk::CheckButton* m_limit_input_ports;
158         Gtk::SpinButton* m_input_limit_count;
159
160         Gtk::CheckButton* m_connect_outputs;    
161         Gtk::CheckButton* m_limit_output_ports;
162         Gtk::SpinButton* m_output_limit_count;
163
164         Gtk::RadioButton* m_connect_outputs_to_master;
165         Gtk::RadioButton* m_connect_outputs_to_physical;
166         Gtk::Button* m_okbutton;
167
168         Gtk::FileChooserButton* m_open_filechooser;
169         Gtk::TreeView* m_treeview;
170         Gtk::Notebook* m_notebook;
171
172  private:
173         enum Pages {
174                 NewPage = 0x1,
175                 OpenPage = 0x2,
176                 EnginePage = 0x4
177         };
178
179         Pages page_set;
180
181         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
182             RecentSessionModelColumns() { 
183                     add (visible_name);
184                     add (fullpath);
185             }
186           Gtk::TreeModelColumn<std::string> visible_name;
187           Gtk::TreeModelColumn<std::string> fullpath;
188         };
189
190         RecentSessionModelColumns    recent_columns;
191         Glib::RefPtr<Gtk::TreeStore> recent_model;
192
193         bool in_destructor;
194
195         void recent_session_selection_changed ();
196         void nsd_redisplay_recent_sessions();
197         void nsd_recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
198         struct RecentSessionsSorter {
199           bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
200                     return cmp_nocase(a.first, b.first) == -1;
201             }
202         };
203         void on_new_session_name_entry_changed();
204         void notebook_page_changed (GtkNotebookPage*, uint);
205         void treeview_selection_changed ();
206         void file_chosen ();
207         void template_chosen ();
208         void recent_row_activated (const Gtk::TreePath&, Gtk::TreeViewColumn*);
209         void connect_inputs_clicked ();
210         void connect_outputs_clicked ();
211         void limit_inputs_clicked ();
212         void limit_outputs_clicked ();
213         void master_bus_button_clicked ();
214         void monitor_bus_button_clicked ();
215
216         bool have_engine;
217 };
218
219 #endif // NEW_SESSION_DIALOG_H