try to make NewSessionDialog only show up when really needed, and only have necessary...
[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         int get_current_page();
90         void set_current_page (int);
91         void reset_recent();
92
93         // reset everything to default values.
94         void reset();
95
96         EngineControl engine_control;
97         void set_have_engine (bool yn);
98         void set_existing_session (bool yn);
99
100 protected:
101
102         void reset_name();
103         void reset_template();
104         
105         Gtk::Label * session_name_label;
106         Gtk::Label * session_location_label;
107         Gtk::Label * session_template_label;
108         Gtk::Label * chan_count_label_1;
109         Gtk::Label * chan_count_label_2;
110         Gtk::Label * chan_count_label_3;
111         Gtk::Label * chan_count_label_4;
112         Gtk::Table * advanced_table;
113         Gtk::HBox * input_port_limit_hbox;
114         Gtk::VBox * input_port_vbox;
115         Gtk::Table * input_table;
116         Gtk::HBox * input_hbox;
117
118         Gtk::Label * bus_label;
119         Gtk::Frame * bus_frame;
120         Gtk::Table * bus_table;
121         Gtk::HBox * bus_hbox;
122
123         Gtk::Label * input_label;
124         Gtk::Frame * input_frame;
125         Gtk::HBox * output_port_limit_hbox;
126         Gtk::VBox * output_port_vbox;
127         Gtk::VBox * output_conn_vbox;
128         Gtk::VBox * output_vbox;
129         Gtk::HBox * output_hbox;
130
131         Gtk::Label * output_label;
132         Gtk::Frame * output_frame;
133         Gtk::VBox * advanced_vbox;
134         Gtk::Label * advanced_label;
135         Gtk::Expander * advanced_expander;
136         Gtk::Table * new_session_table;
137         Gtk::HBox * open_session_hbox;
138         Gtk::ScrolledWindow * recent_scrolledwindow;
139
140         Gtk::Label * recent_sesion_label;
141         Gtk::Frame * recent_frame;
142         Gtk::VBox * open_session_vbox;
143         Gtk::Entry*  m_name;
144         Gtk::FileChooserButton* m_folder;
145         Gtk::FileChooserButton* m_template;
146         Gtk::Label * open_session_file_label;
147
148         Gtk::CheckButton* m_create_master_bus;
149         Gtk::SpinButton* m_master_bus_channel_count;
150         
151         Gtk::CheckButton* m_create_control_bus;
152         Gtk::SpinButton* m_control_bus_channel_count;
153
154         Gtk::CheckButton* m_connect_inputs;
155         Gtk::CheckButton* m_limit_input_ports;
156         Gtk::SpinButton* m_input_limit_count;
157
158         Gtk::CheckButton* m_connect_outputs;    
159         Gtk::CheckButton* m_limit_output_ports;
160         Gtk::SpinButton* m_output_limit_count;
161
162         Gtk::RadioButton* m_connect_outputs_to_master;
163         Gtk::RadioButton* m_connect_outputs_to_physical;
164         Gtk::Button* m_okbutton;
165
166         Gtk::FileChooserButton* m_open_filechooser;
167         Gtk::TreeView* m_treeview;
168         Gtk::Notebook* m_notebook;
169
170  private:
171         enum Pages {
172                 NewPage = 0x1,
173                 OpenPage = 0x2,
174                 EnginePage = 0x4
175         };
176
177         Pages page_set;
178
179         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
180             RecentSessionModelColumns() { 
181                     add (visible_name);
182                     add (fullpath);
183             }
184           Gtk::TreeModelColumn<std::string> visible_name;
185           Gtk::TreeModelColumn<std::string> fullpath;
186         };
187
188         RecentSessionModelColumns    recent_columns;
189         Glib::RefPtr<Gtk::TreeStore> recent_model;
190         bool in_destructor;
191
192         void recent_session_selection_changed ();
193         void nsd_redisplay_recent_sessions();
194         void nsd_recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
195         struct RecentSessionsSorter {
196           bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
197                     return cmp_nocase(a.first, b.first) == -1;
198             }
199         };
200         void on_new_session_name_entry_changed();
201         void notebook_page_changed (GtkNotebookPage*, uint);
202         void treeview_selection_changed ();
203         void file_chosen ();
204         void template_chosen ();
205         void recent_row_activated (const Gtk::TreePath&, Gtk::TreeViewColumn*);
206         void connect_inputs_clicked ();
207         void connect_outputs_clicked ();
208         void limit_inputs_clicked ();
209         void limit_outputs_clicked ();
210         void master_bus_button_clicked ();
211         void monitor_bus_button_clicked ();
212
213         bool on_new_session_page;
214         bool have_engine;
215 };
216
217 #endif // NEW_SESSION_DIALOG_H