* Improved export error handling, streamlined ExportFailed
[ardour.git] / gtk2_ardour / export_main_dialog.h
1 /*
2     Copyright (C) 2008 Paul Davis
3     Author: Sakari Bergen
4
5     This program is free software; you can redistribute it and/or modify
6     it under the terms of the GNU General Public License as published by
7     the Free Software Foundation; either version 2 of the License, or
8     (at your option) any later version.
9
10     This program is distributed in the hope that it will be useful,
11     but WITHOUT ANY WARRANTY; without even the implied warranty of
12     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13     GNU General Public License for more details.
14
15     You should have received a copy of the GNU General Public License
16     along with this program; if not, write to the Free Software
17     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18
19 */
20
21 #ifndef __export_main_dialog_h__
22 #define __export_main_dialog_h__
23
24 #include <boost/shared_ptr.hpp>
25
26 #include <ardour/export_handler.h>
27 #include <ardour/export_profile_manager.h>
28
29 #include "public_editor.h"
30 #include "export_timespan_selector.h"
31 #include "export_channel_selector.h"
32 #include "export_format_selector.h"
33 #include "export_filename_selector.h"
34 #include "ardour_dialog.h"
35
36 #include <gtkmm.h>
37
38 namespace ARDOUR {
39         class ExportFilename;
40         class ExportFormatSpecification;
41         class ExportChannelConfiguration;
42         class ExportStatus;
43 }
44
45 class ExportTimespanSelector;
46 class ExportChannelSelector;
47 class ExportFormatSelector;
48 class ExportFilenameSelector;
49
50 class ExportMainDialog : public ArdourDialog {
51
52   public:
53
54         explicit ExportMainDialog (PublicEditor & editor);
55         ~ExportMainDialog ();
56         
57         void set_session (ARDOUR::Session* s);
58         
59         void select_timespan (Glib::ustring id);
60         
61         /* Responses */
62
63         enum Responses {
64                 RESPONSE_RT,
65                 RESPONSE_FAST,
66                 RESPONSE_CANCEL
67         };
68
69   private:
70
71         void notify_errors ();
72         void close_dialog ();
73         
74         void sync_with_manager ();
75         void update_warnings ();
76         void show_conflicting_files ();
77         
78         typedef boost::shared_ptr<ARDOUR::ExportTimespan> TimespanPtr;
79         typedef boost::shared_ptr<std::list<TimespanPtr> > TimespanList;
80         
81         typedef boost::shared_ptr<ARDOUR::ExportChannelConfiguration> ChannelConfigPtr;
82         typedef std::list<ChannelConfigPtr> ChannelConfigList;
83         
84         typedef boost::shared_ptr<ARDOUR::ExportFilename> FilenamePtr;
85         
86         typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
87         typedef boost::shared_ptr<ARDOUR::ExportFormatSpecification> FormatPtr;
88         typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ManagerPtr;
89         typedef boost::shared_ptr<ARDOUR::ExportStatus> StatusPtr;
90
91         void export_rt ();
92         void export_fw ();
93         
94         void show_progress ();
95         Glib::ustring get_nth_format_name (uint32_t n);
96         gint progress_timeout ();
97         
98         /* Other stuff */
99         
100         PublicEditor &  editor;
101         HandlerPtr      handler;
102         ManagerPtr      profile_manager;
103         StatusPtr       status;
104         
105         /*** GUI components ***/
106         
107         Gtk::Table          main_table;
108         
109         /* Presets */
110         
111         typedef ARDOUR::ExportProfileManager::PresetPtr PresetPtr;
112         typedef ARDOUR::ExportProfileManager::PresetList PresetList;
113         
114         sigc::connection preset_select_connection;
115         
116         void select_preset ();
117         void save_current_preset ();
118         void remove_current_preset ();
119         
120         struct PresetCols : public Gtk::TreeModelColumnRecord
121         {
122           public:
123                 Gtk::TreeModelColumn<PresetPtr>      preset;
124                 Gtk::TreeModelColumn<Glib::ustring>  label;
125         
126                 PresetCols () { add (preset); add (label); }
127         };
128         PresetCols                   preset_cols;
129         Glib::RefPtr<Gtk::ListStore> preset_list;
130         PresetPtr                    current_preset;
131         PresetPtr                    previous_preset;
132         
133         Gtk::Alignment      preset_align;
134         Gtk::HBox           preset_hbox;
135         Gtk::Label          preset_label;
136         Gtk::ComboBoxEntry  preset_entry;
137         
138         Gtk::Button         preset_save_button;
139         Gtk::Button         preset_remove_button;
140         Gtk::Button         preset_new_button;
141         
142         /* File Notebook */
143         
144         class FilePage : public Gtk::VBox {
145           public:
146                 FilePage (ARDOUR::Session * s, ManagerPtr profile_manager, ExportMainDialog * parent, uint32_t number, 
147                           ARDOUR::ExportProfileManager::FormatStatePtr format_state,
148                           ARDOUR::ExportProfileManager::FilenameStatePtr filename_state);
149                 
150                 virtual ~FilePage ();
151                 
152                 Gtk::Widget & get_tab_widget () { return tab_widget; }
153                 void set_remove_sensitive (bool value);
154                 Glib::ustring get_format_name () const;
155                 
156                 ARDOUR::ExportProfileManager::FormatStatePtr   get_format_state () const { return format_state; }
157                 ARDOUR::ExportProfileManager::FilenameStatePtr get_filename_state () const { return filename_state; }
158                 
159                 sigc::signal<void> CriticalSelectionChanged;
160                 
161           private:
162                 void save_format_to_manager (FormatPtr format);
163                 void update_tab_label ();
164                 
165                 ARDOUR::ExportProfileManager::FormatStatePtr   format_state;
166                 ARDOUR::ExportProfileManager::FilenameStatePtr filename_state;
167                 ManagerPtr                                     profile_manager;
168         
169                 /* GUI components */
170         
171                 Gtk::Label              format_label;
172                 Gtk::Alignment          format_align;
173                 ExportFormatSelector    format_selector;
174         
175                 Gtk::Label              filename_label;
176                 Gtk::Alignment          filename_align;
177                 ExportFilenameSelector  filename_selector;
178         
179                 Gtk::HBox               tab_widget;
180                 Gtk::Label              tab_label;
181                 Gtk::Alignment          tab_close_alignment;
182                 Gtk::Button             tab_close_button;
183                 uint32_t                tab_number;
184         };
185         
186         void add_new_file_page ();
187         void add_file_page (ARDOUR::ExportProfileManager::FormatStatePtr format_state, ARDOUR::ExportProfileManager::FilenameStatePtr filename_state);
188         void remove_file_page (FilePage * page);
189         void update_remove_file_page_sensitivity ();
190         
191         sigc::connection page_change_connection;
192         void handle_page_change (GtkNotebookPage*, uint32_t page);
193         
194         uint32_t last_visible_page;
195         uint32_t page_counter;
196         
197         /* Warning area */
198         
199         Gtk::VBox           warn_container;
200         
201         Gtk::HBox           warn_hbox;
202         Gtk::Label          warn_label;
203         Glib::ustring       warn_string;
204         
205         Gtk::HBox           list_files_hbox;
206         Gtk::Label          list_files_label;
207         Gtk::Button         list_files_button;
208         Glib::ustring       list_files_string;
209         
210         void add_error (Glib::ustring const & text);
211         void add_warning (Glib::ustring const & text);
212         
213         /* Progress bar */
214         
215         Gtk::VBox               progress_container;
216         Gtk::Label              progress_label;
217         Gtk::ProgressBar        progress_bar;
218         sigc::connection        progress_connection;
219         
220         /* Everything else */
221
222         Gtk::Label              timespan_label;
223         Gtk::Alignment          timespan_align;
224         ExportTimespanSelector  timespan_selector;
225         
226         Gtk::Label              channels_label;
227         Gtk::Alignment          channels_align;
228         ExportChannelSelector   channel_selector;
229         
230         Gtk::Notebook           file_notebook;
231         
232         Gtk::HBox               new_file_hbox;
233         Gtk::Button             new_file_button;
234         Gtk::VBox               new_file_dummy;
235         
236         Gtk::Button *           cancel_button;
237         Gtk::Button *           rt_export_button;
238         Gtk::Button *           fast_export_button;
239
240 };
241
242 #endif /* __ardour_export_main_dialog_h__ */