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