Working Soundcloud export
[ardour.git] / gtk2_ardour / export_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_dialog_h__
22 #define __export_dialog_h__
23
24 #include <boost/scoped_ptr.hpp>
25 #include <string>
26
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_file_notebook.h"
33 #include "export_preset_selector.h"
34 #include "ardour_dialog.h"
35 #include "soundcloud_export_selector.h"
36
37 #include <gtkmm.h>
38
39 namespace ARDOUR {
40         class ExportStatus;
41         class ExportHandler;
42 }
43
44 class ExportTimespanSelector;
45 class ExportChannelSelector;
46
47 class ExportDialog : public ArdourDialog, public PBD::ScopedConnectionList 
48 {
49
50   public:
51
52         ExportDialog (PublicEditor & editor, std::string title, ARDOUR::ExportProfileManager::ExportType type);
53         ~ExportDialog ();
54
55         void set_session (ARDOUR::Session* s);
56
57         /* Responses */
58
59         enum Responses {
60                 RESPONSE_RT,
61                 RESPONSE_FAST,
62                 RESPONSE_CANCEL
63         };
64
65   protected:
66
67         typedef boost::shared_ptr<ARDOUR::ExportHandler> HandlerPtr;
68         typedef boost::shared_ptr<ARDOUR::ExportProfileManager> ManagerPtr;
69
70         ARDOUR::ExportProfileManager::ExportType type;
71         HandlerPtr      handler;
72         ManagerPtr      profile_manager;
73
74         // initializes GUI layout
75         virtual void init_gui ();
76
77         // Must initialize all the shared_ptrs below
78         virtual void init_components ();
79
80         boost::scoped_ptr<ExportPresetSelector>   preset_selector;
81         boost::scoped_ptr<ExportTimespanSelector> timespan_selector;
82         boost::scoped_ptr<ExportChannelSelector>  channel_selector;
83         boost::scoped_ptr<ExportFileNotebook>     file_notebook;
84         boost::scoped_ptr<SoundcloudExportSelector> soundcloud_selector;
85
86         Gtk::VBox                                 warning_widget;
87         Gtk::VBox                                 progress_widget;
88
89         /*** GUI components ***/
90         Gtk::Notebook export_notebook;
91
92   private:
93
94         void init ();
95
96         void notify_errors ();
97         void close_dialog ();
98
99         void sync_with_manager ();
100         void update_warnings_and_example_filename ();
101         void show_conflicting_files ();
102
103         void do_export ();
104
105         void show_progress ();
106         gint progress_timeout ();
107
108         typedef boost::shared_ptr<ARDOUR::ExportStatus> StatusPtr;
109
110         PublicEditor &  editor;
111         StatusPtr       status;
112
113
114
115         /* Warning area */
116
117         Gtk::HBox           warn_hbox;
118         Gtk::Label          warn_label;
119         std::string       warn_string;
120
121         Gtk::HBox           list_files_hbox;
122         Gtk::Label          list_files_label;
123         Gtk::Button         list_files_button;
124         std::string       list_files_string;
125
126         void add_error (std::string const & text);
127         void add_warning (std::string const & text);
128
129         /* Progress bar */
130
131         Gtk::ProgressBar        progress_bar;
132         sigc::connection        progress_connection;
133
134         float previous_progress; // Needed for gtk bug workaround
135
136         void soundcloud_upload_progress(double total, double now, std::string title);
137
138         /* Buttons */
139
140         Gtk::Button *           cancel_button;
141         Gtk::Button *           export_button;
142
143 };
144
145 class ExportRangeDialog : public ExportDialog
146 {
147   public:
148         ExportRangeDialog (PublicEditor & editor, std::string range_id);
149
150   private:
151         void init_components ();
152
153         std::string range_id;
154 };
155
156 class ExportSelectionDialog : public ExportDialog
157 {
158   public:
159         ExportSelectionDialog (PublicEditor & editor);
160
161   private:
162         void init_components ();
163 };
164
165 class ExportRegionDialog : public ExportDialog
166 {
167   public:
168         ExportRegionDialog (PublicEditor & editor, ARDOUR::AudioRegion const & region, ARDOUR::AudioTrack & track);
169
170   private:
171         void init_gui ();
172         void init_components ();
173
174         ARDOUR::AudioRegion const & region;
175         ARDOUR::AudioTrack & track;
176 };
177
178 class StemExportDialog : public ExportDialog
179 {
180   public:
181         StemExportDialog (PublicEditor & editor);
182
183   private:
184         void init_components ();
185 };
186
187 #endif /* __ardour_export_dialog_h__ */