use new action map API instead of ActionManager::get_action
[ardour.git] / gtk2_ardour / session_dialog.h
1 /*
2     Copyright (C) 2010 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 __gtk2_ardour_session_dialog_h__
21 #define __gtk2_ardour_session_dialog_h__
22
23 #include <string>
24
25 #include <gdkmm/pixbuf.h>
26 #include <gtkmm/label.h>
27 #include <gtkmm/drawingarea.h>
28 #include <gtkmm/expander.h>
29 #include <gtkmm/box.h>
30 #include <gtkmm/radiobutton.h>
31 #include <gtkmm/filechooserbutton.h>
32 #include <gtkmm/scrolledwindow.h>
33 #include <gtkmm/textview.h>
34 #include <gtkmm/treeview.h>
35 #include <gtkmm/treestore.h>
36 #include <gtkmm/checkbutton.h>
37 #include <gtkmm/table.h>
38 #include <gtkmm/frame.h>
39 #include <gtkmm/spinbutton.h>
40 #include <gtkmm/liststore.h>
41 #include <gtkmm/combobox.h>
42
43 #include "ardour/utils.h"
44
45 #include "ardour_dialog.h"
46
47 class EngineControl;
48
49 class SessionDialog : public ArdourDialog
50 {
51 public:
52         SessionDialog (bool require_new, const std::string& session_name, const std::string& session_path,
53                        const std::string& template_name, bool cancel_not_quit);
54         SessionDialog ();
55         ~SessionDialog ();
56
57         void clear_given ();
58
59         std::string session_name (bool& should_be_new);
60         std::string session_folder ();
61
62         bool use_session_template() const;
63         std::string session_template_name();
64
65         uint32_t master_channel_count();
66
67         void set_provided_session(const std::string& session_name, const std::string& session_path) {
68                 _provided_session_name = session_name;
69                 _provided_session_path = session_path;
70         }
71
72 private:
73         bool new_only;
74         std::string _provided_session_name;
75         std::string _provided_session_path;
76
77         bool on_delete_event (GdkEventAny*);
78
79         Gtk::Button* cancel_button;
80         Gtk::Button* open_button;
81         Gtk::Button* back_button;
82         Gtk::Button* quit_button;
83
84         bool back_button_pressed (GdkEventButton*);
85         bool open_button_pressed (GdkEventButton*);
86
87         Gtk::Frame info_frame;
88
89         /* initial choice page */
90
91         void setup_initial_choice_box ();
92         void setup_recent_sessions ();
93         Gtk::VBox ic_vbox;
94         Gtk::Button ic_new_session_button;
95         void new_session_button_clicked ();
96
97         /* recent sessions */
98
99         void setup_existing_session_page ();
100
101         struct RecentSessionsSorter
102         {
103                 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
104                         return ARDOUR::cmp_nocase(a.first, b.first) == -1;
105                 }
106         };
107
108         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
109                 RecentSessionModelColumns()
110                 {
111                         add (visible_name);
112                         add (tip);
113                         add (fullpath);
114                         add (sample_rate);
115                         add (disk_format);
116                         add (modified_with);
117                         add (time_modified);
118                         add (time_formatted);
119                 }
120                 Gtk::TreeModelColumn<std::string> visible_name;
121                 Gtk::TreeModelColumn<std::string> tip;
122                 Gtk::TreeModelColumn<std::string> fullpath;
123                 Gtk::TreeModelColumn<std::string> sample_rate;
124                 Gtk::TreeModelColumn<std::string> disk_format;
125                 Gtk::TreeModelColumn<std::string> modified_with;
126                 Gtk::TreeModelColumn<int64_t>     time_modified;
127                 Gtk::TreeModelColumn<std::string> time_formatted;
128         };
129
130         RecentSessionModelColumns    recent_session_columns;
131         Gtk::TreeView                recent_session_display;
132         Glib::RefPtr<Gtk::TreeStore> recent_session_model;
133         Gtk::ScrolledWindow          recent_scroller;
134         Gtk::Label                   recent_label;
135         Gtk::FileChooserButton       existing_session_chooser;
136         int redisplay_recent_sessions ();
137         void recent_session_row_selected ();
138         void recent_session_sort_changed ();
139         void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
140         bool recent_button_press (GdkEventButton*);
141         void recent_context_mennu (GdkEventButton*);
142         void recent_remove_selected ();
143
144         void existing_session_selected ();
145         void session_selected ();
146
147         /* new sessions */
148
149         void setup_new_session_page ();
150         Gtk::Entry new_name_entry;
151         Gtk::FileChooserButton new_folder_chooser;
152
153         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
154                 SessionTemplateColumns () {
155                         add (name);
156                         add (path);
157                         add (description);
158                         add (modified_with_short);
159                         add (modified_with_long);
160                 }
161
162                 Gtk::TreeModelColumn<std::string> name;
163                 Gtk::TreeModelColumn<std::string> path;
164                 Gtk::TreeModelColumn<std::string> description;
165                 Gtk::TreeModelColumn<std::string> modified_with_short;
166                 Gtk::TreeModelColumn<std::string> modified_with_long;
167         };
168
169         SessionTemplateColumns session_template_columns;
170
171         Glib::RefPtr<Gtk::TreeStore>  template_model;
172         Gtk::TreeView                 template_chooser;
173         Gtk::ScrolledWindow           template_scroller;
174
175         void template_row_selected ();
176
177         Gtk::TextView template_desc;
178         Gtk::Frame    template_desc_frame;
179
180         Gtk::VBox session_new_vbox;
181         Gtk::VBox session_existing_vbox;
182         std::string load_template_override;
183
184         void new_name_changed ();
185         void new_name_activated ();
186         void populate_session_templates ();
187
188         /* --disable plugins UI */
189         Gtk::CheckButton _disable_plugins;
190         void disable_plugins_clicked ();
191
192         /* meta-template */
193         uint32_t meta_master_bus_profile (std::string script) const;
194
195         /* always there */
196
197         Glib::RefPtr<Pango::Layout> layout;
198
199         bool _existing_session_chooser_used; ///< set to true when the existing session chooser has been used
200
201         Gtk::Label info_scroller_label;
202         std::string::size_type info_scroller_count;
203         bool info_scroller_update();
204         sigc::connection info_scroller_connection;
205         void updates_button_clicked ();
206 };
207
208 #endif /* __gtk2_ardour_session_dialog_h__ */