Tweak Lua-doc processing:
[ardour.git] / gtk2_ardour / session_dialog.h
1 /*
2  * Copyright (C) 2013-2017 Paul Davis <paul@linuxaudiosystems.com>
3  * Copyright (C) 2014-2017 Robin Gareus <robin@gareus.org>
4  * Copyright (C) 2017 Ben Loftis <ben@harrisonconsoles.com>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20
21 #ifndef __gtk2_ardour_session_dialog_h__
22 #define __gtk2_ardour_session_dialog_h__
23
24 #include <string>
25
26 #include <gdkmm/pixbuf.h>
27 #include <gtkmm/label.h>
28 #include <gtkmm/drawingarea.h>
29 #include <gtkmm/expander.h>
30 #include <gtkmm/box.h>
31 #include <gtkmm/radiobutton.h>
32 #include <gtkmm/filechooserbutton.h>
33 #include <gtkmm/scrolledwindow.h>
34 #include <gtkmm/textview.h>
35 #include <gtkmm/treeview.h>
36 #include <gtkmm/treestore.h>
37 #include <gtkmm/checkbutton.h>
38 #include <gtkmm/table.h>
39 #include <gtkmm/frame.h>
40 #include <gtkmm/spinbutton.h>
41 #include <gtkmm/liststore.h>
42 #include <gtkmm/combobox.h>
43
44 #include "ardour/utils.h"
45
46 #include "ardour_dialog.h"
47
48 class EngineControl;
49
50 class SessionDialog : public ArdourDialog
51 {
52 public:
53         SessionDialog (bool require_new, const std::string& session_name, const std::string& session_path,
54                        const std::string& template_name, bool cancel_not_quit);
55         SessionDialog ();
56         ~SessionDialog ();
57
58         void clear_given ();
59
60         std::string session_name (bool& should_be_new);
61         std::string session_folder ();
62
63         bool use_session_template() const;
64         std::string session_template_name();
65
66         uint32_t master_channel_count();
67
68         void set_provided_session(const std::string& session_name, const std::string& session_path) {
69                 _provided_session_name = session_name;
70                 _provided_session_path = session_path;
71         }
72
73 private:
74         bool new_only;
75         std::string _provided_session_name;
76         std::string _provided_session_path;
77
78         bool on_delete_event (GdkEventAny*);
79
80         Gtk::Button* cancel_button;
81         Gtk::Button* open_button;
82         Gtk::Button* back_button;
83         Gtk::Button* quit_button;
84
85         bool back_button_pressed (GdkEventButton*);
86         bool open_button_pressed (GdkEventButton*);
87
88         Gtk::Frame info_frame;
89
90         /* initial choice page */
91
92         void setup_initial_choice_box ();
93         void setup_recent_sessions ();
94         Gtk::VBox ic_vbox;
95         Gtk::Button ic_new_session_button;
96         void new_session_button_clicked ();
97
98         /* recent sessions */
99
100         void setup_existing_session_page ();
101
102         struct RecentSessionsSorter
103         {
104                 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
105                         return ARDOUR::cmp_nocase(a.first, b.first) == -1;
106                 }
107         };
108
109         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
110                 RecentSessionModelColumns()
111                 {
112                         add (visible_name);
113                         add (tip);
114                         add (fullpath);
115                         add (sample_rate);
116                         add (disk_format);
117                         add (modified_with);
118                         add (time_modified);
119                         add (time_formatted);
120                 }
121                 Gtk::TreeModelColumn<std::string> visible_name;
122                 Gtk::TreeModelColumn<std::string> tip;
123                 Gtk::TreeModelColumn<std::string> fullpath;
124                 Gtk::TreeModelColumn<std::string> sample_rate;
125                 Gtk::TreeModelColumn<std::string> disk_format;
126                 Gtk::TreeModelColumn<std::string> modified_with;
127                 Gtk::TreeModelColumn<int64_t>     time_modified;
128                 Gtk::TreeModelColumn<std::string> time_formatted;
129         };
130
131         RecentSessionModelColumns    recent_session_columns;
132         Gtk::TreeView                recent_session_display;
133         Glib::RefPtr<Gtk::TreeStore> recent_session_model;
134         Gtk::ScrolledWindow          recent_scroller;
135         Gtk::Label                   recent_label;
136         Gtk::FileChooserButton       existing_session_chooser;
137         int redisplay_recent_sessions ();
138         void recent_session_row_selected ();
139         void recent_session_sort_changed ();
140         void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
141         bool recent_button_press (GdkEventButton*);
142         void recent_context_mennu (GdkEventButton*);
143         void recent_remove_selected ();
144
145         void existing_session_selected ();
146         void session_selected ();
147
148         /* new sessions */
149
150         void setup_new_session_page ();
151         Gtk::Entry new_name_entry;
152         Gtk::FileChooserButton new_folder_chooser;
153
154         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
155                 SessionTemplateColumns () {
156                         add (name);
157                         add (path);
158                         add (description);
159                         add (modified_with_short);
160                         add (modified_with_long);
161                 }
162
163                 Gtk::TreeModelColumn<std::string> name;
164                 Gtk::TreeModelColumn<std::string> path;
165                 Gtk::TreeModelColumn<std::string> description;
166                 Gtk::TreeModelColumn<std::string> modified_with_short;
167                 Gtk::TreeModelColumn<std::string> modified_with_long;
168         };
169
170         SessionTemplateColumns session_template_columns;
171
172         Glib::RefPtr<Gtk::TreeStore>  template_model;
173         Gtk::TreeView                 template_chooser;
174         Gtk::ScrolledWindow           template_scroller;
175
176         void template_row_selected ();
177
178         Gtk::TextView template_desc;
179         Gtk::Frame    template_desc_frame;
180
181         Gtk::VBox session_new_vbox;
182         Gtk::VBox session_existing_vbox;
183         std::string load_template_override;
184
185         void new_name_changed ();
186         void new_name_activated ();
187         void populate_session_templates ();
188
189         /* --disable plugins UI */
190         Gtk::CheckButton _disable_plugins;
191         void disable_plugins_clicked ();
192
193         /* meta-template */
194         uint32_t meta_master_bus_profile (std::string script) const;
195
196         /* always there */
197
198         Glib::RefPtr<Pango::Layout> layout;
199
200         bool _existing_session_chooser_used; ///< set to true when the existing session chooser has been used
201
202         Gtk::Label info_scroller_label;
203         std::string::size_type info_scroller_count;
204         bool info_scroller_update();
205         sigc::connection info_scroller_connection;
206         void updates_button_clicked ();
207 };
208
209 #endif /* __gtk2_ardour_session_dialog_h__ */