more miscellaneous fixes to make things even nicer
[ardour.git] / gtk2_ardour / export_dialog.h
1 /*
2     Copyright (C) 1999-2002 Paul Davis 
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #ifndef __ardour_export_dialog_h__
21 #define __ardour_export_dialog_h__
22
23 #include <gtkmm/box.h>
24 #include <gtkmm/table.h>
25 #include <gtkmm/frame.h>
26 #include <gtkmm/frame.h>
27 #include <gtkmm/button.h>
28 #include <gtkmm/progressbar.h>
29 #include <gtkmm/scrolledwindow.h>
30 #include <gtkmm/fileselection.h>
31 #include <gtkmm/comboboxtext.h>
32 #include <gtkmm/treeview.h>
33 #include <gtkmm/liststore.h>
34
35 #include <ardour/export.h>
36 #include <ardour/location.h>
37
38 #include "ardour_dialog.h"
39
40 class PublicEditor;
41
42 namespace ARDOUR {
43         class Session;
44         class AudioRegion;
45         class Port;
46 }
47
48 class ExportDialog : public ArdourDialog
49 {
50   public:
51         ExportDialog (PublicEditor&, ARDOUR::AudioRegion* r = 0);
52         ~ExportDialog ();
53
54         void connect_to_session (ARDOUR::Session*);
55         void set_range (jack_nframes_t start, jack_nframes_t end);
56         void start_export ();
57
58   protected:
59         struct ExportModelColumns : public Gtk::TreeModel::ColumnRecord
60         {
61         public:
62           Gtk::TreeModelColumn<std::string>     output;
63           Gtk::TreeModelColumn<bool>            left;
64           Gtk::TreeModelColumn<bool>            right;
65           Gtk::TreeModelColumn<ARDOUR::Port*>   port;
66
67           ExportModelColumns() { add(output); add(left); add(right); add(port);}
68         };
69
70         ExportModelColumns exp_cols;
71
72   private:
73         PublicEditor&    editor;
74         ARDOUR::Session* session;
75         ARDOUR::AudioRegion* audio_region;
76         Gtk::VBox   track_vpacker;
77         Gtk::HBox   hpacker;
78         Gtk::HBox   button_box;
79
80         Gtk::Table  format_table;
81         Gtk::Frame  format_frame;
82
83         Gtk::Label  sample_rate_label;
84         Gtk::ComboBoxText sample_rate_combo;
85         Gtk::Label  src_quality_label;
86         Gtk::ComboBoxText src_quality_combo;
87         Gtk::Label  dither_type_label;
88         Gtk::ComboBoxText dither_type_combo;
89         Gtk::Label  cue_file_label;
90         Gtk::ComboBoxText cue_file_combo;
91         Gtk::Label  channel_count_label;
92         Gtk::ComboBoxText channel_count_combo;
93         Gtk::Label  header_format_label;
94         Gtk::ComboBoxText header_format_combo;
95         Gtk::Label  bitdepth_format_label;
96         Gtk::ComboBoxText bitdepth_format_combo;
97         Gtk::Label  endian_format_label;
98         Gtk::ComboBoxText endian_format_combo;
99         Gtk::CheckButton cuefile_only_checkbox;
100
101         Gtk::Frame  file_frame;
102         Gtk::Entry  file_entry;
103         Gtk::HBox   file_hbox;
104         Gtk::Button file_browse_button;
105
106         Gtk::Button ok_button;
107         Gtk::Button cancel_button;
108         Gtk::Label  cancel_label;
109         Gtk::ProgressBar progress_bar;
110         Gtk::ScrolledWindow track_scroll;
111         Gtk::ScrolledWindow master_scroll;
112         Gtk::Button         track_selector_button;
113         Gtk::TreeView  track_selector;
114         Glib::RefPtr<Gtk::ListStore> track_list;
115         Gtk::TreeView  master_selector;
116         Glib::RefPtr<Gtk::ListStore> master_list;
117         Gtk::FileSelection *file_selector;
118         ARDOUR::AudioExportSpecification spec;
119
120         static void *_thread (void *arg);
121         gint progress_timeout ();
122         sigc::connection progress_connection;
123         void build_window ();
124         void end_dialog();
125         void header_chosen ();
126         void channels_chosen ();
127         void bitdepth_chosen ();
128         void sample_rate_chosen ();
129         void cue_file_type_chosen();
130
131         void fill_lists();
132
133         void do_export_cd_markers (const string& path, const string& cuefile_type);
134         void export_cue_file (ARDOUR::Locations::LocationList& locations, const string& path);
135         void export_toc_file (ARDOUR::Locations::LocationList& locations, const string& path);
136         void do_export ();
137         gint window_closed (GdkEventAny *ignored);
138
139         void track_selector_button_click ();
140
141         void initiate_browse ();
142         void finish_browse (int status);
143
144         void set_state();
145         void save_state();
146
147         static void* _export_region_thread (void *);
148         void export_region ();
149 };
150
151 #endif // __ardour_export_dialog_h__
152