Some fixes to the new session dialog.
[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     $Id$
19 */
20
21 // -*- c++ -*-
22
23 #ifndef NEW_SESSION_DIALOG_H
24 #define NEW_SESSION_DIALOG_H
25
26 #include <string>
27 #include <gtkmm/dialog.h>
28 #include <gtkmm/treeview.h>
29 #include <gtkmm/treestore.h>
30 #include <gtkmm/treepath.h>
31 #include <gtkmm/scrolledwindow.h>
32 #include <gtkmm/notebook.h>
33
34 #include <ardour/utils.h>
35
36 #include <glibmm/refptr.h>
37
38 namespace Gtk {
39         class Entry;
40         class FileChooserButton;
41         class SpinButton;
42         class CheckButton;
43         class RadioButton;
44         class TreeView;
45         class Notebook;
46 }
47
48 #include "glade_factory.h"
49
50 struct NewSessionDialogFactory : public GladeFactory
51 {
52         static GladeRef create();
53
54         static const char* top_level_widget_name();
55
56 private:
57
58         static const char* s_m_top_level_widget_name;
59         
60 };
61
62 class NewSessionDialog : public Gtk::Dialog
63 {
64 public:
65                 
66         NewSessionDialog(BaseObjectType* cobject,
67                          const Glib::RefPtr<Gnome::Glade::Xml>& xml);
68
69         void set_session_name(const Glib::ustring& name);
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         int get_current_page();
96         void reset_recent();
97
98         // reset everything to default values.
99         void reset();
100
101 protected:
102
103         void reset_name();
104         void reset_template();
105         
106         // references to widgets we care about.
107         Gtk::Dialog* m_new_session_dialog;
108         Gtk::Entry*  m_name;
109         Gtk::FileChooserButton* m_folder;
110         Gtk::FileChooserButton* m_template;
111         
112         Gtk::CheckButton* m_create_master_bus;
113         Gtk::SpinButton* m_master_bus_channel_count;
114         
115         Gtk::CheckButton* m_create_control_bus;
116         Gtk::SpinButton* m_control_bus_channel_count;
117
118         Gtk::CheckButton* m_connect_inputs;
119         Gtk::CheckButton* m_limit_input_ports;
120         Gtk::SpinButton* m_input_limit_count;
121
122         Gtk::CheckButton* m_connect_outputs;    
123         Gtk::CheckButton* m_limit_output_ports;
124         Gtk::SpinButton* m_output_limit_count;
125
126         Gtk::RadioButton* m_connect_outputs_to_master;
127         Gtk::RadioButton* m_connect_outputs_to_physical;
128         Gtk::Button* m_okbutton;
129
130         Gtk::FileChooserButton* m_open_filechooser;
131         Gtk::TreeView* m_treeview;
132         Gtk::Notebook* m_notebook;
133         Gtk::ScrolledWindow* m_scrolledwindow;
134  private:
135         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
136             RecentSessionModelColumns() { 
137                     add (visible_name);
138                     add (fullpath);
139             }
140           Gtk::TreeModelColumn<std::string> visible_name;
141           Gtk::TreeModelColumn<std::string> fullpath;
142         };
143
144         RecentSessionModelColumns    recent_columns;
145         Glib::RefPtr<Gtk::TreeStore> recent_model;
146
147         void recent_session_selection_changed ();
148         void nsd_redisplay_recent_sessions();
149         void nsd_recent_session_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
150         struct RecentSessionsSorter {
151           bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
152                     return cmp_nocase(a.first, b.first) == -1;
153             }
154         };
155         bool entry_key_release (GdkEventKey*);
156         void notebook_page_changed (GtkNotebookPage*, uint);
157         void treeview_selection_changed ();
158         void file_chosen ();
159         void recent_row_activated (const Gtk::TreePath&, Gtk::TreeViewColumn*);
160
161         
162 };
163
164 #endif // NEW_SESSION_DIALOG_H