Enable Menu > Quit to work again after startup on macOS
[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         std::string session_name (bool& should_be_new);
59         std::string session_folder ();
60
61         bool use_session_template() const;
62         std::string session_template_name();
63
64         uint32_t master_channel_count();
65
66         void set_provided_session (std::string const & name, std::string const & path);
67         void clear_name ();
68
69 private:
70         bool new_only;
71
72         bool on_delete_event (GdkEventAny*);
73
74         Gtk::Button* cancel_button;
75         Gtk::Button* open_button;
76         Gtk::Button* back_button;
77         Gtk::Button* quit_button;
78
79         bool back_button_pressed (GdkEventButton*);
80         bool open_button_pressed (GdkEventButton*);
81
82         Gtk::Frame info_frame;
83
84         /* initial choice page */
85
86         void setup_initial_choice_box ();
87         void setup_recent_sessions ();
88         Gtk::VBox ic_vbox;
89         Gtk::Button ic_new_session_button;
90         void new_session_button_clicked ();
91
92         /* recent sessions */
93
94         void setup_existing_session_page ();
95
96         struct RecentSessionsSorter
97         {
98                 bool operator() (std::pair<std::string,std::string> a, std::pair<std::string,std::string> b) const {
99                         return ARDOUR::cmp_nocase(a.first, b.first) == -1;
100                 }
101         };
102
103         struct RecentSessionModelColumns : public Gtk::TreeModel::ColumnRecord {
104                 RecentSessionModelColumns()
105                 {
106                         add (visible_name);
107                         add (tip);
108                         add (fullpath);
109                         add (sample_rate);
110                         add (disk_format);
111                         add (modified_with);
112                         add (time_modified);
113                         add (time_formatted);
114                 }
115                 Gtk::TreeModelColumn<std::string> visible_name;
116                 Gtk::TreeModelColumn<std::string> tip;
117                 Gtk::TreeModelColumn<std::string> fullpath;
118                 Gtk::TreeModelColumn<std::string> sample_rate;
119                 Gtk::TreeModelColumn<std::string> disk_format;
120                 Gtk::TreeModelColumn<std::string> modified_with;
121                 Gtk::TreeModelColumn<int64_t>     time_modified;
122                 Gtk::TreeModelColumn<std::string> time_formatted;
123         };
124
125         RecentSessionModelColumns    recent_session_columns;
126         Gtk::TreeView                recent_session_display;
127         Glib::RefPtr<Gtk::TreeStore> recent_session_model;
128         Gtk::ScrolledWindow          recent_scroller;
129         Gtk::Label                   recent_label;
130         Gtk::FileChooserButton       existing_session_chooser;
131         int redisplay_recent_sessions ();
132         void recent_session_row_selected ();
133         void recent_session_sort_changed ();
134         void recent_row_activated (const Gtk::TreePath& path, Gtk::TreeViewColumn* col);
135         bool recent_button_press (GdkEventButton*);
136         void recent_context_mennu (GdkEventButton*);
137         void recent_remove_selected ();
138
139         void existing_session_selected ();
140         void session_selected ();
141
142         /* new sessions */
143
144         void setup_new_session_page ();
145         Gtk::Entry new_name_entry;
146         Gtk::FileChooserButton new_folder_chooser;
147
148         struct SessionTemplateColumns : public Gtk::TreeModel::ColumnRecord {
149                 SessionTemplateColumns () {
150                         add (name);
151                         add (path);
152                         add (description);
153                         add (modified_with_short);
154                         add (modified_with_long);
155                 }
156
157                 Gtk::TreeModelColumn<std::string> name;
158                 Gtk::TreeModelColumn<std::string> path;
159                 Gtk::TreeModelColumn<std::string> description;
160                 Gtk::TreeModelColumn<std::string> modified_with_short;
161                 Gtk::TreeModelColumn<std::string> modified_with_long;
162         };
163
164         SessionTemplateColumns session_template_columns;
165
166         Glib::RefPtr<Gtk::TreeStore>  template_model;
167         Gtk::TreeView                 template_chooser;
168         Gtk::ScrolledWindow           template_scroller;
169
170         void template_row_selected ();
171
172         Gtk::TextView template_desc;
173         Gtk::Frame    template_desc_frame;
174
175         Gtk::VBox session_new_vbox;
176         Gtk::VBox session_existing_vbox;
177         std::string load_template_override;
178
179         void new_name_changed ();
180         void new_name_activated ();
181         void populate_session_templates ();
182
183         /* --disable plugins UI */
184         Gtk::CheckButton _disable_plugins;
185         void disable_plugins_clicked ();
186
187         /* meta-template */
188         static uint32_t meta_master_bus_profile (std::string script);
189
190         /* always there */
191
192         Glib::RefPtr<Pango::Layout> layout;
193
194         bool _existing_session_chooser_used; ///< set to true when the existing session chooser has been used
195
196         Gtk::Label info_scroller_label;
197         std::string::size_type info_scroller_count;
198         bool info_scroller_update();
199         sigc::connection info_scroller_connection;
200         void updates_button_clicked ();
201 };
202
203 #endif /* __gtk2_ardour_session_dialog_h__ */