Superficial code cleanup.
[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 <ardour/export_handler.h>
25 #include <ardour/export_profile_manager.h>
26
27 #include "public_editor.h"
28 #include "export_timespan_selector.h"
29 #include "export_channel_selector.h"
30 #include "export_format_selector.h"
31 #include "export_filename_selector.h"
32 #include "ardour_dialog.h"
33
34 #include <gtkmm.h>
35
36 namespace ARDOUR {
37         class ExportFilename;
38         class ExportFormatSpecification;
39         class ExportChannelConfiguration;
40 }
41
42 class ExportTimespanSelector;
43 class ExportChannelSelector;
44 class ExportFormatSelector;
45 class ExportFilenameSelector;
46
47 class ExportMainDialog : public ArdourDialog {
48
49   public:
50
51         explicit ExportMainDialog (PublicEditor & editor);
52         ~ExportMainDialog ();
53         
54         void set_session (ARDOUR::Session* s);
55         
56         void select_timespan (Glib::ustring id);
57         
58         /* Responses */
59
60         enum Responses {
61                 RESPONSE_RT,
62                 RESPONSE_FAST,
63                 RESPONSE_CANCEL
64         };
65
66   private:
67         
68         void close_dialog ();
69         
70         void sync_with_manager ();
71         void update_warnings ();
72         void show_conflicting_files ();
73         
74         typedef boost::shared_ptr<ARDOUR::ExportTimespan> TimespanPtr;
75         typedef boost::shared_ptr<std::list<TimespanPtr> > TimespanList;
76         
77         typedef boost::shared_ptr<ARDOUR::ExportChannelConfiguration> ChannelConfigPtr;
78         typedef std::list<ChannelConfigPtr> ChannelConfigList;
79         
80         typedef boost::shared_ptr<ARDOUR::ExportFilename> FilenamePtr;
81         
82         typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
83         typedef boost::shared_ptr<ARDOUR::ExportFormatSpecification> FormatPtr;
84         typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ManagerPtr;
85
86         void export_rt ();
87         void export_fw ();
88         
89         void show_progress ();
90         Glib::ustring get_nth_format_name (uint32_t n);
91         gint progress_timeout ();
92         
93         /* Other stuff */
94         
95         PublicEditor &  editor;
96         HandlerPtr      handler;
97         ManagerPtr      profile_manager;
98         
99         /*** GUI components ***/
100         
101         Gtk::Table          main_table;
102         
103         /* Presets */
104         
105         typedef ARDOUR::ExportProfileManager::PresetPtr PresetPtr;
106         typedef ARDOUR::ExportProfileManager::PresetList PresetList;
107         
108         sigc::connection preset_select_connection;
109         
110         void select_preset ();
111         void save_current_preset ();
112         void remove_current_preset ();
113         
114         struct PresetCols : public Gtk::TreeModelColumnRecord
115         {
116           public:
117                 Gtk::TreeModelColumn<PresetPtr>      preset;
118                 Gtk::TreeModelColumn<Glib::ustring>  label;
119         
120                 PresetCols () { add (preset); add (label); }
121         };
122         PresetCols                   preset_cols;
123         Glib::RefPtr<Gtk::ListStore> preset_list;
124         PresetPtr                    current_preset;
125         PresetPtr                    previous_preset;
126         
127         Gtk::Alignment      preset_align;
128         Gtk::HBox           preset_hbox;
129         Gtk::Label          preset_label;
130         Gtk::ComboBoxEntry  preset_entry;
131         
132         Gtk::Button         preset_save_button;
133         Gtk::Button         preset_remove_button;
134         Gtk::Button         preset_new_button;
135         
136         /* File Notebook */
137         
138         class FilePage : public Gtk::VBox {
139           public:
140                 FilePage (ARDOUR::Session * s, ManagerPtr profile_manager, ExportMainDialog * parent, uint32_t number, 
141                           ARDOUR::ExportProfileManager::FormatStatePtr format_state,
142                           ARDOUR::ExportProfileManager::FilenameStatePtr filename_state);
143                 
144                 virtual ~FilePage ();
145                 
146                 Gtk::Widget & get_tab_widget () { return tab_widget; }
147                 void set_remove_sensitive (bool value);
148                 Glib::ustring get_format_name () const;
149                 
150                 ARDOUR::ExportProfileManager::FormatStatePtr   get_format_state () const { return format_state; }
151                 ARDOUR::ExportProfileManager::FilenameStatePtr get_filename_state () const { return filename_state; }
152                 
153                 sigc::signal<void> CriticalSelectionChanged;
154                 
155           private:
156                 void save_format_to_manager (FormatPtr format);
157                 void update_tab_label ();
158                 
159                 ARDOUR::ExportProfileManager::FormatStatePtr   format_state;
160                 ARDOUR::ExportProfileManager::FilenameStatePtr filename_state;
161                 ManagerPtr                                     profile_manager;
162         
163                 /* GUI components */
164         
165                 Gtk::Label              format_label;
166                 Gtk::Alignment          format_align;
167                 ExportFormatSelector    format_selector;
168         
169                 Gtk::Label              filename_label;
170                 Gtk::Alignment          filename_align;
171                 ExportFilenameSelector  filename_selector;
172         
173                 Gtk::HBox               tab_widget;
174                 Gtk::Label              tab_label;
175                 Gtk::Alignment          tab_close_alignment;
176                 Gtk::Button             tab_close_button;
177                 uint32_t                tab_number;
178         };
179         
180         void add_new_file_page ();
181         void add_file_page (ARDOUR::ExportProfileManager::FormatStatePtr format_state, ARDOUR::ExportProfileManager::FilenameStatePtr filename_state);
182         void remove_file_page (FilePage * page);
183         void update_remove_file_page_sensitivity ();
184         
185         sigc::connection page_change_connection;
186         void handle_page_change (GtkNotebookPage*, uint32_t page);
187         
188         uint32_t last_visible_page;
189         uint32_t page_counter;
190         
191         /* Warning area */
192         
193         Gtk::VBox           warn_container;
194         
195         Gtk::HBox           warn_hbox;
196         Gtk::Label          warn_label;
197         Glib::ustring       warn_string;
198         
199         Gtk::HBox           list_files_hbox;
200         Gtk::Label          list_files_label;
201         Gtk::Button         list_files_button;
202         Glib::ustring       list_files_string;
203         
204         void add_error (Glib::ustring const & text);
205         void add_warning (Glib::ustring const & text);
206         
207         /* Progress bar */
208         
209         Gtk::VBox               progress_container;
210         Gtk::Label              progress_label;
211         Gtk::ProgressBar        progress_bar;
212         sigc::connection        progress_connection;
213         
214         /* Everything else */
215
216         Gtk::Label              timespan_label;
217         Gtk::Alignment          timespan_align;
218         ExportTimespanSelector  timespan_selector;
219         
220         Gtk::Label              channels_label;
221         Gtk::Alignment          channels_align;
222         ExportChannelSelector   channel_selector;
223         
224         Gtk::Notebook           file_notebook;
225         
226         Gtk::HBox               new_file_hbox;
227         Gtk::Button             new_file_button;
228         Gtk::VBox               new_file_dummy;
229         
230         Gtk::Button *           cancel_button;
231         Gtk::Button *           rt_export_button;
232         Gtk::Button *           fast_export_button;
233
234 };
235
236 #endif /* __ardour_export_main_dialog_h__ */