Fix a tiny memory leak, add_instant_xml() copies the node
[ardour.git] / gtk2_ardour / export_format_dialog.cc
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 #include <gtkmm/stock.h>
22
23 #include "ardour/session.h"
24 #include "ardour/export_format_specification.h"
25
26 #include "widgets/tooltips.h"
27
28 #include "export_format_dialog.h"
29 #include "gui_thread.h"
30
31 #include "pbd/i18n.h"
32
33 using namespace ARDOUR;
34
35 ExportFormatDialog::ExportFormatDialog (FormatPtr format, bool new_dialog) :
36   ArdourDialog (new_dialog ? _("New Export Format Profile") : _("Edit Export Format Profile")),
37   format (format),
38   manager (format),
39   original_state (format->get_state()),
40
41   applying_changes_from_engine (0),
42
43   name_label (_("Label: "), Gtk::ALIGN_LEFT),
44   name_generated_part ("", Gtk::ALIGN_LEFT),
45
46   normalize_checkbox (_("Normalize:")),
47   normalize_peak_rb (_("Peak")),
48   normalize_loudness_rb (_("Loudness")),
49   normalize_dbfs_adjustment ( 0.00, -90.00, 0.00, 0.1, 0.2),
50   normalize_lufs_adjustment (-23.0, -90.00, 0.00, 0.1, 1.0),
51   normalize_dbtp_adjustment ( -1.0, -90.00, 0.00, 0.1, 0.2),
52
53   normalize_dbfs_label (_("dBFS"), Gtk::ALIGN_LEFT),
54   normalize_lufs_label (_("LUFS"), Gtk::ALIGN_LEFT),
55   normalize_dbtp_label (_("dBTP"), Gtk::ALIGN_LEFT),
56
57   silence_table (2, 4),
58   trim_start_checkbox (_("Trim silence at start")),
59   silence_start_checkbox (_("Add silence at start:")),
60   silence_start_clock ("silence_start", true, "", true, false, true),
61
62   trim_end_checkbox (_("Trim silence at end")),
63   silence_end_checkbox (_("Add silence at end:")),
64   silence_end_clock ("silence_end", true, "", true, false, true),
65
66   command_label(_("Command to run post-export\n(%f=file path, %d=directory, %b=basename, see tooltip for more):"), Gtk::ALIGN_LEFT),
67
68   format_table (3, 4),
69   compatibility_label (_("Compatibility"), Gtk::ALIGN_LEFT),
70   quality_label (_("Quality"), Gtk::ALIGN_LEFT),
71   format_label (_("File format"), Gtk::ALIGN_LEFT),
72   sample_rate_label (_("Sample rate"), Gtk::ALIGN_LEFT),
73   src_quality_label (_("Sample rate conversion quality:"), Gtk::ALIGN_RIGHT),
74
75   encoding_options_label ("", Gtk::ALIGN_LEFT),
76
77   /* Changing encoding options from here on */
78
79   sample_format_label (_("Sample Format"), Gtk::ALIGN_LEFT),
80   dither_label (_("Dithering"), Gtk::ALIGN_LEFT),
81
82   with_cue (_("Create CUE file for disk-at-once CD/DVD creation")),
83   with_toc (_("Create TOC file for disk-at-once CD/DVD creation")),
84   with_mp4chaps (_("Create chapter mark file for MP4 chapter marks")),
85
86   tag_checkbox (_("Tag file with session's metadata"))
87 {
88
89         /* Pack containers in dialog */
90
91         get_vbox()->pack_start (silence_table, false, false, 6);
92         get_vbox()->pack_start (format_table, false, false, 6);
93         get_vbox()->pack_start (encoding_options_vbox, false, false, 0);
94         get_vbox()->pack_start (cue_toc_vbox, false, false, 0);
95         get_vbox()->pack_start (name_hbox, false, false, 6);
96
97         /* Name, new and remove */
98
99         name_hbox.pack_start (name_label, false, false, 0);
100         name_hbox.pack_start (name_entry, false, false, 0);
101         name_hbox.pack_start (name_generated_part, true, true, 0);
102         name_entry.set_width_chars(20);
103         update_description();
104         manager.DescriptionChanged.connect(
105                 *this, invalidator (*this),
106                 boost::bind (&ExportFormatDialog::update_description, this), gui_context());
107
108         /* Normalize */
109
110         Gtk::RadioButtonGroup normalize_group = normalize_loudness_rb.get_group();
111         normalize_peak_rb.set_group (normalize_group);
112
113         normalize_hbox.pack_start (normalize_checkbox, false, false, 2);
114         normalize_hbox.pack_start (normalize_peak_rb, false, false, 0);
115         normalize_hbox.pack_start (normalize_dbfs_spinbutton, false, false, 2);
116         normalize_hbox.pack_start (normalize_dbfs_label, false, false, 0);
117
118         normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label ("")), false, false, 6); // separator
119
120         normalize_hbox.pack_start (normalize_loudness_rb, false, false, 0);
121         normalize_hbox.pack_start (normalize_lufs_spinbutton, false, false, 2);
122         normalize_hbox.pack_start (normalize_lufs_label, false, false, 0);
123         normalize_hbox.pack_start (*Gtk::manage (new Gtk::Label (_("\u2227"))), false, false, 4);
124         normalize_hbox.pack_start (normalize_dbtp_spinbutton, false, false, 2);
125         normalize_hbox.pack_start (normalize_dbtp_label, false, false, 0);
126
127         ArdourWidgets::set_tooltip (normalize_loudness_rb,
128                         _("Normalize to EBU-R128 LUFS target loudness without exceeding the given true-peak limit. EBU-R128 normalization is only available for mono and stereo targets, true-peak works for any channel layout."));
129
130         normalize_dbfs_spinbutton.configure (normalize_dbfs_adjustment, 0.1, 2);
131         normalize_lufs_spinbutton.configure (normalize_lufs_adjustment, 0.1, 2);
132         normalize_dbtp_spinbutton.configure (normalize_dbtp_adjustment, 0.1, 2);
133
134         /* Silence  */
135
136         silence_table.set_row_spacings (6);
137         silence_table.set_col_spacings (12);
138
139         silence_table.attach (normalize_hbox, 0, 3, 0, 1);
140
141         silence_table.attach (trim_start_checkbox, 0, 1, 1, 2);
142         silence_table.attach (silence_start_checkbox, 1, 2, 1, 2);
143         silence_table.attach (silence_start_clock, 2, 3, 1, 2);
144
145         silence_table.attach (trim_end_checkbox, 0, 1, 2, 3);
146         silence_table.attach (silence_end_checkbox, 1, 2, 2, 3);
147         silence_table.attach (silence_end_clock, 2, 3, 2, 3);
148
149         /* Post-export hook script */
150
151         get_vbox()->pack_start (command_label, false, false);
152         get_vbox()->pack_start (command_entry, false, false);
153
154         ArdourWidgets::set_tooltip (command_entry,
155                         _(
156                                 "%a Artist name\n"
157                                 "%b File's base-name\n"
158                                 "%c Copyright\n"
159                                 "%d File's directory\n"
160                                 "%f File's full absolute path\n"
161                                 "%l Lyricist\n"
162                                 "%n Session name\n"
163                                 "%o Conductor\n"
164                                 "%t Title\n"
165                                 "%z Organization\n"
166                                 "%A Album\n"
167                                 "%C Comment\n"
168                                 "%E Engineer\n"
169                                 "%G Genre\n"
170                                 "%L Total track count\n"
171                                 "%M Mixer\n"
172                                 "%N Timespan name\n"
173                                 "%O Composer\n"
174                                 "%P Producer\n"
175                                 "%S Disc subtitle\n"
176                                 "%T Track number\n"
177                                 "%Y Year\n"
178                                 "%Z Country"
179                          ));
180
181         /* Format table */
182
183         init_format_table();
184
185         /* Encoding options */
186
187         init_encoding_option_widgets();
188
189         encoding_options_table.set_spacings (1);
190
191         encoding_options_vbox.pack_start (encoding_options_label, false, false, 0);
192         encoding_options_vbox.pack_start (encoding_options_table, false, false, 12);
193
194         Pango::AttrList bold;
195         Pango::Attribute b = Pango::Attribute::create_attr_weight (Pango::WEIGHT_BOLD);
196         bold.insert (b);
197         encoding_options_label.set_attributes (bold);
198
199         /* Codec options */
200
201         codec_quality_list = Gtk::ListStore::create (codec_quality_cols);
202         codec_quality_combo.set_model (codec_quality_list);
203         codec_quality_combo.pack_start (codec_quality_cols.label);
204         //codec_quality_combo.set_active (0);
205
206         /* Buttons */
207
208         revert_button = add_button (Gtk::Stock::CANCEL, Gtk::RESPONSE_CANCEL);
209         revert_button->signal_clicked().connect (sigc::mem_fun(*this, &ExportFormatDialog::revert));
210         close_button = add_button (Gtk::Stock::SAVE, Gtk::RESPONSE_APPLY);
211         close_button->set_sensitive (false);
212         close_button->signal_clicked().connect (sigc::mem_fun (*this, &ExportFormatDialog::end_dialog));
213         manager.CompleteChanged.connect (*this, invalidator (*this), boost::bind (&Gtk::Button::set_sensitive, close_button, _1), gui_context());
214
215         with_cue.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_cue));
216         with_toc.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_toc));
217         with_mp4chaps.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_with_mp4chaps));
218         command_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_command));
219
220         cue_toc_vbox.pack_start (with_cue, false, false);
221         cue_toc_vbox.pack_start (with_toc, false, false);
222         cue_toc_vbox.pack_start (with_mp4chaps, false, false);
223
224         /* Load state before hooking up the rest of the signals */
225
226         load_state (format);
227
228         /* Name entry */
229
230         name_entry.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_name));
231
232         /* Normalize, silence and src_quality signals */
233
234         trim_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_start_selection));
235         trim_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_trim_end_selection));
236
237         normalize_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
238         normalize_peak_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
239         normalize_loudness_rb.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
240         normalize_dbfs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
241         normalize_lufs_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
242         normalize_dbtp_spinbutton.signal_value_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_normalize_selection));
243
244         silence_start_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
245         silence_start_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_start_selection));
246
247         silence_end_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
248         silence_end_clock.ValueChanged.connect (sigc::mem_fun (*this, &ExportFormatDialog::update_silence_end_selection));
249
250         src_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_src_quality_selection));
251         codec_quality_combo.signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_codec_quality_selection));
252
253         /* Format table signals */
254
255         Gtk::CellRendererToggle *toggle = dynamic_cast<Gtk::CellRendererToggle *>(compatibility_view.get_column_cell_renderer (0));
256         toggle->signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_compatibility_selection));
257         compatibility_select_connection = compatibility_view.get_selection()->signal_changed().connect (sigc::mem_fun (*this, &ExportFormatDialog::prohibit_compatibility_selection));
258
259         quality_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_quality_selection));
260         format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_format_selection));
261         sample_rate_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_rate_selection));
262
263         /* Encoding option signals */
264
265         sample_format_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_sample_format_selection));
266         dither_type_view.get_selection()->signal_changed().connect (sigc::mem_fun(*this, &ExportFormatDialog::update_dither_type_selection));
267
268         tag_checkbox.signal_toggled().connect (sigc::mem_fun (*this, &ExportFormatDialog::update_tagging_selection));
269
270         /* Finalize */
271
272         show_all_children();
273         update_normalize_sensitivity ();
274 }
275
276 ExportFormatDialog::~ExportFormatDialog ()
277 {
278
279 }
280
281 void
282 ExportFormatDialog::revert ()
283 {
284         ++applying_changes_from_engine;
285
286         format->set_state (original_state);
287         load_state (format);
288
289         --applying_changes_from_engine;
290 }
291
292 void
293 ExportFormatDialog::set_session (ARDOUR::Session* s)
294 {
295         SessionHandlePtr::set_session (s);
296         silence_start_clock.set_session (s);
297         silence_end_clock.set_session (s);
298
299         if (!_session) {
300                 return;
301         }
302
303         update_clock (silence_start_clock, silence_start);
304         update_clock (silence_end_clock, silence_end);
305
306         /* Select native samplerate if no selection is yet made */
307
308         if (sample_rate_view.get_selection()->count_selected_rows() == 0) {
309                 Gtk::ListStore::Children::iterator it;
310                 for (it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
311                         if ((samplecnt_t) (*it)->get_value (sample_rate_cols.ptr)->rate == _session->nominal_sample_rate()) {
312                                 sample_rate_view.get_selection()->select (it);
313                                 break;
314                         }
315                 }
316         }
317 }
318
319 void
320 ExportFormatDialog::load_state (FormatPtr spec)
321 {
322         name_entry.set_text (spec->name());
323
324         normalize_checkbox.set_active (spec->normalize());
325         normalize_peak_rb.set_active (!spec->normalize_loudness());
326         normalize_loudness_rb.set_active (spec->normalize_loudness());
327         normalize_dbfs_spinbutton.set_value (spec->normalize_dbfs());
328         normalize_lufs_spinbutton.set_value (spec->normalize_lufs());
329         normalize_dbtp_spinbutton.set_value (spec->normalize_dbtp());
330
331         trim_start_checkbox.set_active (spec->trim_beginning());
332         silence_start = spec->silence_beginning_time();
333         silence_start_checkbox.set_active (spec->silence_beginning_time().not_zero());
334
335         trim_end_checkbox.set_active (spec->trim_end());
336         silence_end = spec->silence_end_time();
337         silence_end_checkbox.set_active (spec->silence_end_time().not_zero());
338
339         with_cue.set_active (spec->with_cue());
340         with_toc.set_active (spec->with_toc());
341         with_mp4chaps.set_active (spec->with_mp4chaps());
342
343         for (Gtk::ListStore::Children::iterator it = src_quality_list->children().begin(); it != src_quality_list->children().end(); ++it) {
344                 if (it->get_value (src_quality_cols.id) == spec->src_quality()) {
345                         src_quality_combo.set_active (it);
346                         break;
347                 }
348         }
349
350         for (Gtk::ListStore::Children::iterator it = codec_quality_list->children().begin(); it != codec_quality_list->children().end(); ++it) {
351                 if (it->get_value (codec_quality_cols.quality) == spec->codec_quality()) {
352                         codec_quality_combo.set_active (it);
353                         break;
354                 }
355         }
356
357         for (Gtk::ListStore::Children::iterator it = format_list->children().begin(); it != format_list->children().end(); ++it) {
358                 boost::shared_ptr<ARDOUR::ExportFormat> format_in_list = it->get_value (format_cols.ptr);
359                 if (format_in_list->get_format_id() == spec->format_id() &&
360                     // BWF has the same format id with wav, so we need to check this.
361                     format_in_list->has_broadcast_info() == spec->has_broadcast_info()) {
362
363                         format_in_list->set_selected (true);
364                         break;
365                 }
366         }
367
368         for (Gtk::ListStore::Children::iterator it = sample_rate_list->children().begin(); it != sample_rate_list->children().end(); ++it) {
369                 if (it->get_value (sample_rate_cols.ptr)->rate == spec->sample_rate()) {
370                         it->get_value (sample_rate_cols.ptr)->set_selected (true);
371                         break;
372                 }
373         }
374
375         if (spec->sample_format()) {
376                 for (Gtk::ListStore::Children::iterator it = sample_format_list->children().begin(); it != sample_format_list->children().end(); ++it) {
377                         if (it->get_value (sample_format_cols.ptr)->format == spec->sample_format()) {
378                                 it->get_value (sample_format_cols.ptr)->set_selected (true);
379                                 break;
380                         }
381                 }
382
383                 for (Gtk::ListStore::Children::iterator it = dither_type_list->children().begin(); it != dither_type_list->children().end(); ++it) {
384                         if (it->get_value (dither_type_cols.ptr)->type == spec->dither_type()) {
385                                 it->get_value (dither_type_cols.ptr)->set_selected (true);
386                                 break;
387                         }
388                 }
389         }
390
391         update_normalize_sensitivity ();
392         tag_checkbox.set_active (spec->tag());
393         command_entry.set_text (spec->command());
394 }
395
396 void
397 ExportFormatDialog::init_format_table ()
398 {
399
400         format_table.set_spacings (1);
401
402         format_table.attach (compatibility_label, 0, 1, 0, 1);
403         format_table.attach (quality_label, 1, 2, 0, 1);
404         format_table.attach (format_label, 2, 3, 0, 1);
405         format_table.attach (sample_rate_label, 3, 4, 0, 1);
406
407         format_table.attach (compatibility_view, 0, 1, 1, 2);
408         format_table.attach (quality_view, 1, 2, 1, 2);
409         format_table.attach (format_view, 2, 3, 1, 2);
410         format_table.attach (sample_rate_view, 3, 4, 1, 2);
411
412         format_table.attach (src_quality_label, 0, 3, 2, 3);
413         format_table.attach (src_quality_combo, 3, 4, 2, 3);
414
415         compatibility_view.set_headers_visible (false);
416         quality_view.set_headers_visible (false);
417         format_view.set_headers_visible (false);
418         sample_rate_view.set_headers_visible (false);
419
420         /*** Table entries ***/
421
422         Gtk::TreeModel::iterator iter;
423         Gtk::TreeModel::Row row;
424
425         /* Compatibilities */
426
427         compatibility_list = Gtk::ListStore::create (compatibility_cols);
428         compatibility_view.set_model (compatibility_list);
429
430         ExportFormatManager::CompatList const & compat_list = manager.get_compatibilities();
431
432         for (ExportFormatManager::CompatList::const_iterator it = compat_list.begin(); it != compat_list.end(); ++it) {
433                 iter = compatibility_list->append();
434                 row = *iter;
435
436                 row[compatibility_cols.ptr] = *it;
437                 row[compatibility_cols.selected] = false;
438                 row[compatibility_cols.label] = (*it)->name();
439
440                 WeakCompatPtr ptr (*it);
441                 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_compatibility_selection, this, _1, ptr), gui_context());
442         }
443
444         compatibility_view.append_column_editable ("", compatibility_cols.selected);
445
446         Gtk::CellRendererText* text_renderer = Gtk::manage (new Gtk::CellRendererText);
447         text_renderer->property_editable() = false;
448
449         Gtk::TreeView::Column* column = compatibility_view.get_column (0);
450         column->pack_start (*text_renderer);
451         column->add_attribute (text_renderer->property_text(), compatibility_cols.label);
452
453         /* Qualities */
454
455         quality_list = Gtk::ListStore::create (quality_cols);
456         quality_view.set_model (quality_list);
457
458         ExportFormatManager::QualityList const & qualities = manager.get_qualities ();
459
460         for (ExportFormatManager::QualityList::const_iterator it = qualities.begin(); it != qualities.end(); ++it) {
461                 iter = quality_list->append();
462                 row = *iter;
463
464                 row[quality_cols.ptr] = *it;
465                 row[quality_cols.color] = "white";
466                 row[quality_cols.label] = (*it)->name();
467
468                 WeakQualityPtr ptr (*it);
469                 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_selection, this, _1, ptr), gui_context());
470                 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_quality_compatibility, this, _1, ptr), gui_context());
471         }
472
473         quality_view.append_column ("", quality_cols.label);
474
475         /* Formats */
476
477         format_list = Gtk::ListStore::create (format_cols);
478         format_view.set_model (format_list);
479
480         ExportFormatManager::FormatList const & formats = manager.get_formats ();
481
482         for (ExportFormatManager::FormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
483                 iter = format_list->append();
484                 row = *iter;
485
486                 row[format_cols.ptr] = *it;
487                 row[format_cols.color] = "white";
488                 row[format_cols.label] = (*it)->name();
489
490                 WeakFormatPtr ptr (*it);
491                 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_selection, this, _1, ptr), gui_context());
492                 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_format_compatibility, this, _1, ptr), gui_context());
493
494                 /* Encoding options */
495
496                 boost::shared_ptr<HasSampleFormat> hsf;
497
498                 if ((hsf = boost::dynamic_pointer_cast<HasSampleFormat> (*it))) {
499                         hsf->SampleFormatSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_selection, this, _1, _2), gui_context());
500                         hsf->SampleFormatCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_format_compatibility, this, _1, _2), gui_context());
501
502                         hsf->DitherTypeSelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_selection, this, _1, _2), gui_context());
503                         hsf->DitherTypeCompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_dither_type_compatibility, this, _1, _2), gui_context());
504                 }
505         }
506
507         format_view.append_column ("", format_cols.label);
508
509         /* Sample Rates */
510
511         sample_rate_list = Gtk::ListStore::create (sample_rate_cols);
512         sample_rate_view.set_model (sample_rate_list);
513
514         ExportFormatManager::SampleRateList const & rates = manager.get_sample_rates ();
515
516         for (ExportFormatManager::SampleRateList::const_iterator it = rates.begin(); it != rates.end(); ++it) {
517                 iter = sample_rate_list->append();
518                 row = *iter;
519
520                 row[sample_rate_cols.ptr] = *it;
521                 row[sample_rate_cols.color] = "white";
522                 row[sample_rate_cols.label] = (*it)->name();
523
524                 WeakSampleRatePtr ptr (*it);
525                 (*it)->SelectChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_selection, this, _1, ptr), gui_context());
526                 (*it)->CompatibleChanged.connect (*this, invalidator (*this), boost::bind (&ExportFormatDialog::change_sample_rate_compatibility, this, _1, ptr), gui_context());
527         }
528
529         sample_rate_view.append_column ("", sample_rate_cols.label);
530
531         /* Color rendering */
532
533         Gtk::TreeViewColumn * label_col;
534         Gtk::CellRendererText * renderer;
535
536         label_col = quality_view.get_column(0);
537         renderer = dynamic_cast<Gtk::CellRendererText*> (quality_view.get_column_cell_renderer (0));
538         label_col->add_attribute(renderer->property_foreground(), quality_cols.color);
539
540         label_col = format_view.get_column(0);
541         renderer = dynamic_cast<Gtk::CellRendererText*> (format_view.get_column_cell_renderer (0));
542         label_col->add_attribute(renderer->property_foreground(), format_cols.color);
543
544         label_col = sample_rate_view.get_column(0);
545         renderer = dynamic_cast<Gtk::CellRendererText*> (sample_rate_view.get_column_cell_renderer (0));
546         label_col->add_attribute(renderer->property_foreground(), sample_rate_cols.color);
547
548         /* SRC Qualities */
549
550         src_quality_list = Gtk::ListStore::create (src_quality_cols);
551         src_quality_combo.set_model (src_quality_list);
552
553         iter = src_quality_list->append();
554         row = *iter;
555         row[src_quality_cols.id] = ExportFormatBase::SRC_SincBest;
556         row[src_quality_cols.label] = _("Best (sinc)");
557
558         iter = src_quality_list->append();
559         row = *iter;
560         row[src_quality_cols.id] = ExportFormatBase::SRC_SincMedium;
561         row[src_quality_cols.label] = _("Medium (sinc)");
562
563         iter = src_quality_list->append();
564         row = *iter;
565         row[src_quality_cols.id] = ExportFormatBase::SRC_SincFast;
566         row[src_quality_cols.label] = _("Fast (sinc)");
567
568         iter = src_quality_list->append();
569         row = *iter;
570         row[src_quality_cols.id] = ExportFormatBase::SRC_Linear;
571         row[src_quality_cols.label] = _("Linear");
572
573         iter = src_quality_list->append();
574         row = *iter;
575         row[src_quality_cols.id] = ExportFormatBase::SRC_ZeroOrderHold;
576         row[src_quality_cols.label] = _("Zero order hold");
577
578         src_quality_combo.pack_start (src_quality_cols.label);
579         src_quality_combo.set_active (0);
580 }
581
582 void
583 ExportFormatDialog::init_encoding_option_widgets ()
584 {
585         Gtk::TreeViewColumn * label_col;
586         Gtk::CellRendererText * renderer;
587
588         sample_format_list = Gtk::ListStore::create (sample_format_cols);
589         sample_format_view.set_model (sample_format_list);
590         sample_format_view.set_headers_visible (false);
591         sample_format_view.append_column ("", sample_format_cols.label);
592         label_col = sample_format_view.get_column(0);
593         renderer = dynamic_cast<Gtk::CellRendererText*> (sample_format_view.get_column_cell_renderer (0));
594         label_col->add_attribute(renderer->property_foreground(), sample_format_cols.color);
595
596         dither_type_list = Gtk::ListStore::create (dither_type_cols);
597         dither_type_view.set_model (dither_type_list);
598         dither_type_view.set_headers_visible (false);
599         dither_type_view.append_column ("", dither_type_cols.label);
600         label_col = dither_type_view.get_column(0);
601         renderer = dynamic_cast<Gtk::CellRendererText*> (dither_type_view.get_column_cell_renderer (0));
602         label_col->add_attribute(renderer->property_foreground(), dither_type_cols.color);
603
604 }
605
606 void
607 ExportFormatDialog::update_compatibility_selection (std::string const & path)
608 {
609
610         Gtk::TreeModel::iterator iter = compatibility_view.get_model ()->get_iter (path);
611         ExportFormatCompatibilityPtr ptr = iter->get_value (compatibility_cols.ptr);
612         bool state = iter->get_value (compatibility_cols.selected);
613
614         iter->set_value (compatibility_cols.selected, state);
615         ptr->set_selected (state);
616
617 }
618
619 void
620 ExportFormatDialog::update_quality_selection ()
621 {
622         update_selection<QualityCols> (quality_list, quality_view, quality_cols);
623 }
624
625 void
626 ExportFormatDialog::update_format_selection ()
627 {
628         update_selection<FormatCols> (format_list, format_view, format_cols);
629 }
630
631 void
632 ExportFormatDialog::update_sample_rate_selection ()
633 {
634         update_selection<SampleRateCols> (sample_rate_list, sample_rate_view, sample_rate_cols);
635 }
636
637 void
638 ExportFormatDialog::update_sample_format_selection ()
639 {
640         update_selection<SampleFormatCols> (sample_format_list, sample_format_view, sample_format_cols);
641 }
642
643 void
644 ExportFormatDialog::update_dither_type_selection ()
645 {
646         update_selection<DitherTypeCols> (dither_type_list, dither_type_view, dither_type_cols);
647 }
648
649 template<typename ColsT>
650 void
651 ExportFormatDialog::update_selection (Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
652 {
653         if (applying_changes_from_engine) {
654                 return;
655         }
656
657         Gtk::ListStore::Children::iterator it;
658         Glib::RefPtr<Gtk::TreeSelection> selection = view.get_selection();
659
660         for (it = list->children().begin(); it != list->children().end(); ++it) {
661                 bool selected = selection->is_selected (it);
662                 it->get_value (cols.ptr)->set_selected (selected);
663         }
664
665         set_codec_quality_selection ();
666 }
667
668 void
669 ExportFormatDialog::change_compatibility_selection (bool select, WeakCompatPtr compat)
670 {
671         ++applying_changes_from_engine;
672
673         ExportFormatCompatibilityPtr ptr = compat.lock();
674
675         for (Gtk::ListStore::Children::iterator it = compatibility_list->children().begin(); it != compatibility_list->children().end(); ++it) {
676                 if (it->get_value (compatibility_cols.ptr) == ptr) {
677                         it->set_value (compatibility_cols.selected, select);
678                         break;
679                 }
680         }
681
682         --applying_changes_from_engine;
683 }
684
685 void
686 ExportFormatDialog::change_quality_selection (bool select, WeakQualityPtr quality)
687 {
688         change_selection<ExportFormatManager::QualityState, QualityCols> (select, quality, quality_list, quality_view, quality_cols);
689 }
690
691 void
692 ExportFormatDialog::change_format_selection (bool select, WeakFormatPtr format)
693 {
694         change_selection<ExportFormat, FormatCols> (select, format, format_list, format_view, format_cols);
695
696         ExportFormatPtr ptr = format.lock();
697
698         if (select && ptr) {
699                 change_encoding_options (ptr);
700         }
701 }
702
703 void
704 ExportFormatDialog::change_sample_rate_selection (bool select, WeakSampleRatePtr rate)
705 {
706         change_selection<ExportFormatManager::SampleRateState, SampleRateCols> (select, rate, sample_rate_list, sample_rate_view, sample_rate_cols);
707
708         if (select) {
709                 ExportFormatManager::SampleRatePtr ptr = rate.lock();
710                 if (ptr && _session) {
711                         src_quality_combo.set_sensitive ((uint32_t) ptr->rate != _session->sample_rate());
712                 }
713         }
714 }
715
716 void
717 ExportFormatDialog::change_sample_format_selection (bool select, WeakSampleFormatPtr format)
718 {
719         change_selection<HasSampleFormat::SampleFormatState, SampleFormatCols> (select, format, sample_format_list, sample_format_view, sample_format_cols);
720 }
721
722 void
723 ExportFormatDialog::change_dither_type_selection (bool select, WeakDitherTypePtr type)
724 {
725         change_selection<HasSampleFormat::DitherTypeState, DitherTypeCols> (select, type, dither_type_list, dither_type_view, dither_type_cols);
726 }
727
728 template<typename T, typename ColsT>
729 void
730 ExportFormatDialog::change_selection (bool select, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, Gtk::TreeView & view, ColsT & cols)
731 {
732         ++applying_changes_from_engine;
733
734         boost::shared_ptr<T> ptr = w_ptr.lock();
735
736         Gtk::ListStore::Children::iterator it;
737         Glib::RefPtr<Gtk::TreeSelection> selection;
738
739         selection = view.get_selection();
740
741         if (!ptr) {
742                 selection->unselect_all();
743         } else {
744                 for (it = list->children().begin(); it != list->children().end(); ++it) {
745                         if (it->get_value (cols.ptr) == ptr) {
746                                 if (select) {
747                                         selection->select (it);
748                                 } else {
749                                         selection->unselect (it);
750                                 }
751                                 break;
752                         }
753                 }
754         }
755
756         --applying_changes_from_engine;
757 }
758
759 void
760 ExportFormatDialog::change_quality_compatibility (bool compatibility, WeakQualityPtr quality)
761 {
762         change_compatibility<ExportFormatManager::QualityState, QualityCols> (compatibility, quality, quality_list, quality_cols);
763 }
764
765 void
766 ExportFormatDialog::change_format_compatibility (bool compatibility, WeakFormatPtr format)
767 {
768         change_compatibility<ExportFormat, FormatCols> (compatibility, format, format_list, format_cols);
769 }
770
771 void
772 ExportFormatDialog::change_sample_rate_compatibility (bool compatibility, WeakSampleRatePtr rate)
773 {
774         change_compatibility<ExportFormatManager::SampleRateState, SampleRateCols> (compatibility, rate, sample_rate_list, sample_rate_cols);
775 }
776
777 void
778 ExportFormatDialog::change_sample_format_compatibility (bool compatibility, WeakSampleFormatPtr format)
779 {
780         change_compatibility<HasSampleFormat::SampleFormatState, SampleFormatCols> (compatibility, format, sample_format_list, sample_format_cols);
781 }
782
783 void
784 ExportFormatDialog::change_dither_type_compatibility (bool compatibility, WeakDitherTypePtr type)
785 {
786         change_compatibility<HasSampleFormat::DitherTypeState, DitherTypeCols> (compatibility, type, dither_type_list, dither_type_cols, "red");
787 }
788
789 template<typename T, typename ColsT>
790 void
791 ExportFormatDialog::change_compatibility (bool compatibility, boost::weak_ptr<T> w_ptr, Glib::RefPtr<Gtk::ListStore> & list, ColsT & cols,
792                                           std::string const & c_incompatible, std::string const & c_compatible)
793 {
794         boost::shared_ptr<T> ptr = w_ptr.lock();
795
796         Gtk::ListStore::Children::iterator it;
797         for (it = list->children().begin(); it != list->children().end(); ++it) {
798                 if (it->get_value (cols.ptr) == ptr) {
799                         it->set_value (cols.color, compatibility ? c_compatible : c_incompatible);
800                         break;
801                 }
802         }
803 }
804
805 void
806 ExportFormatDialog::update_with_cue ()
807 {
808         manager.select_with_cue (with_cue.get_active());
809 }
810
811 void
812 ExportFormatDialog::update_with_toc ()
813 {
814         manager.select_with_toc (with_toc.get_active());
815 }
816
817 void
818 ExportFormatDialog::update_with_mp4chaps ()
819 {
820         manager.select_with_mp4chaps (with_mp4chaps.get_active());
821 }
822
823 void
824 ExportFormatDialog::update_command ()
825 {
826         manager.set_command (command_entry.get_text());
827 }
828
829 void
830 ExportFormatDialog::update_description()
831 {
832         std::string text = ": " + format->description(false);
833         name_generated_part.set_text(text);
834 }
835
836 void
837 ExportFormatDialog::update_name ()
838 {
839         manager.set_name (name_entry.get_text());
840 }
841
842 void
843 ExportFormatDialog::update_trim_start_selection ()
844 {
845         manager.select_trim_beginning (trim_start_checkbox.get_active());
846 }
847
848 void
849 ExportFormatDialog::update_trim_end_selection ()
850 {
851         manager.select_trim_end (trim_end_checkbox.get_active());
852 }
853
854 void
855 ExportFormatDialog::update_normalize_sensitivity ()
856 {
857         bool en = normalize_checkbox.get_active();
858         bool loudness = normalize_loudness_rb.get_active();
859         normalize_dbfs_spinbutton.set_sensitive (!loudness && en);
860         normalize_lufs_spinbutton.set_sensitive (loudness && en);
861         normalize_dbtp_spinbutton.set_sensitive (loudness && en);
862 }
863
864 void
865 ExportFormatDialog::update_normalize_selection ()
866 {
867         manager.select_normalize (normalize_checkbox.get_active());
868         manager.select_normalize_loudness (normalize_loudness_rb.get_active());
869         manager.select_normalize_dbfs (normalize_dbfs_spinbutton.get_value ());
870         manager.select_normalize_lufs (normalize_lufs_spinbutton.get_value ());
871         manager.select_normalize_dbtp (normalize_dbtp_spinbutton.get_value ());
872         update_normalize_sensitivity ();
873 }
874
875 void
876 ExportFormatDialog::update_silence_start_selection ()
877 {
878         update_time (silence_start, silence_start_clock);
879         AnyTime zero;
880         zero.type = AnyTime::Timecode;
881         manager.select_silence_beginning (silence_start_checkbox.get_active() ? silence_start : zero);
882 }
883
884 void
885 ExportFormatDialog::update_silence_end_selection ()
886 {
887         update_time (silence_end, silence_end_clock);
888         AnyTime zero;
889         zero.type = AnyTime::Timecode;
890         manager.select_silence_end (silence_end_checkbox.get_active() ? silence_end : zero);
891 }
892
893 void
894 ExportFormatDialog::update_clock (AudioClock & clock, ARDOUR::AnyTime const & time)
895 {
896         // TODO position
897         clock.set (_session->convert_to_samples (time), true);
898
899         AudioClock::Mode mode(AudioClock::Timecode);
900
901         switch (time.type) {
902           case AnyTime::Timecode:
903                 mode = AudioClock::Timecode;
904                 break;
905           case AnyTime::BBT:
906                 mode = AudioClock::BBT;
907                 break;
908           case AnyTime::Samples:
909                 mode = AudioClock::Samples;
910                 break;
911           case AnyTime::Seconds:
912                 mode = AudioClock::MinSec;
913                 break;
914         }
915
916         clock.set_mode (mode);
917 }
918
919 void
920 ExportFormatDialog::update_time (AnyTime & time, AudioClock const & clock)
921 {
922         if (!_session) {
923                 return;
924         }
925
926         samplecnt_t samples = clock.current_duration();
927
928         switch (clock.mode()) {
929           case AudioClock::Timecode:
930                 time.type = AnyTime::Timecode;
931                 _session->timecode_time (samples, time.timecode);
932                 break;
933           case AudioClock::BBT:
934                 time.type = AnyTime::BBT;
935                 _session->bbt_time (samples, time.bbt);
936                 break;
937           case AudioClock::Seconds:
938           case AudioClock::MinSec:
939                 time.type = AnyTime::Seconds;
940                 time.seconds = (double) samples / _session->sample_rate();
941                 break;
942           case AudioClock::Samples:
943                 time.type = AnyTime::Samples;
944                 time.samples = samples;
945                 break;
946         }
947 }
948
949 void
950 ExportFormatDialog::update_src_quality_selection ()
951 {
952         Gtk::TreeModel::const_iterator iter = src_quality_combo.get_active();
953         ExportFormatBase::SRCQuality quality = iter->get_value (src_quality_cols.id);
954         manager.select_src_quality (quality);
955 }
956
957 void
958 ExportFormatDialog::update_codec_quality_selection ()
959 {
960         Gtk::TreeModel::const_iterator iter = codec_quality_combo.get_active();
961         if (!iter) {
962                 return;
963         }
964         int quality = iter->get_value (codec_quality_cols.quality);
965         manager.select_codec_quality (quality);
966 }
967
968 void
969 ExportFormatDialog::update_tagging_selection ()
970 {
971         manager.select_tagging (tag_checkbox.get_active());
972 }
973
974 void
975 ExportFormatDialog::change_encoding_options (ExportFormatPtr ptr)
976 {
977         empty_encoding_option_table ();
978
979         boost::shared_ptr<ARDOUR::ExportFormatLinear> linear_ptr;
980         boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ogg_ptr;
981         boost::shared_ptr<ARDOUR::ExportFormatFLAC> flac_ptr;
982         boost::shared_ptr<ARDOUR::ExportFormatBWF> bwf_ptr;
983         boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ffmpeg_ptr;
984
985         if ((linear_ptr = boost::dynamic_pointer_cast<ExportFormatLinear> (ptr))) {
986                 show_linear_enconding_options (linear_ptr);
987         } else if ((ogg_ptr = boost::dynamic_pointer_cast<ExportFormatOggVorbis> (ptr))) {
988                 show_ogg_enconding_options (ogg_ptr);
989         } else if ((flac_ptr = boost::dynamic_pointer_cast<ExportFormatFLAC> (ptr))) {
990                 show_flac_enconding_options (flac_ptr);
991         } else if ((bwf_ptr = boost::dynamic_pointer_cast<ExportFormatBWF> (ptr))) {
992                 show_bwf_enconding_options (bwf_ptr);
993         } else if ((ffmpeg_ptr = boost::dynamic_pointer_cast<ExportFormatFFMPEG> (ptr))) {
994                 show_ffmpeg_enconding_options (ffmpeg_ptr);
995         } else {
996                 std::cout << "Unrecognized format!" << std::endl;
997         }
998 }
999
1000 void
1001 ExportFormatDialog::empty_encoding_option_table ()
1002 {
1003         encoding_options_table.foreach (sigc::bind (sigc::mem_fun (*this, &ExportFormatDialog::remove_widget), &encoding_options_table));
1004 }
1005
1006 void
1007 ExportFormatDialog::remove_widget (Gtk::Widget & to_remove, Gtk::Container * remove_from)
1008 {
1009         remove_from->remove (to_remove);
1010 }
1011
1012 void
1013 ExportFormatDialog::show_linear_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatLinear> ptr)
1014 {
1015         /* Set label and pack table */
1016
1017         encoding_options_label.set_label (_("Linear encoding options"));
1018
1019         encoding_options_table.resize (2, 2);
1020         encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1021         encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1022         encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1023         encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1024
1025         fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1026
1027         show_all_children ();
1028 }
1029
1030 void
1031 ExportFormatDialog::show_ogg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatOggVorbis> ptr)
1032 {
1033         encoding_options_label.set_label (_("Ogg Vorbis options"));
1034
1035         encoding_options_table.resize (2, 1);
1036         encoding_options_table.attach (codec_quality_combo, 0, 1, 0, 1);
1037         encoding_options_table.attach (tag_checkbox, 0, 1, 1, 2);
1038         fill_codec_quality_lists (ptr);
1039         show_all_children ();
1040 }
1041
1042 void
1043 ExportFormatDialog::show_flac_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFLAC> ptr)
1044 {
1045         encoding_options_label.set_label (_("FLAC options"));
1046
1047         encoding_options_table.resize (3, 2);
1048         encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1049         encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1050         encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1051         encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1052         encoding_options_table.attach (tag_checkbox, 0, 2, 2, 3);
1053
1054         fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1055
1056         show_all_children ();
1057 }
1058
1059 void
1060 ExportFormatDialog::show_bwf_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatBWF> ptr)
1061 {
1062         encoding_options_label.set_label (_("Broadcast Wave options"));
1063
1064         encoding_options_table.resize (2, 2);
1065         encoding_options_table.attach (sample_format_label, 0, 1, 0, 1);
1066         encoding_options_table.attach (dither_label, 1, 2, 0, 1);
1067         encoding_options_table.attach (sample_format_view, 0, 1, 1, 2);
1068         encoding_options_table.attach (dither_type_view, 1, 2, 1, 2);
1069
1070         fill_sample_format_lists (boost::dynamic_pointer_cast<HasSampleFormat> (ptr));
1071
1072         show_all_children ();
1073 }
1074
1075 void
1076 ExportFormatDialog::show_ffmpeg_enconding_options (boost::shared_ptr<ARDOUR::ExportFormatFFMPEG> ptr)
1077 {
1078         encoding_options_label.set_label (_("FFMPEG/MP3 options"));
1079         encoding_options_table.resize (1, 1);
1080         encoding_options_table.attach (codec_quality_combo, 0, 1, 0, 1);
1081         fill_codec_quality_lists (ptr);
1082         show_all_children ();
1083 }
1084
1085 void
1086 ExportFormatDialog::fill_sample_format_lists (boost::shared_ptr<ARDOUR::HasSampleFormat> ptr)
1087 {
1088         /* Fill lists */
1089
1090         Gtk::TreeModel::iterator iter;
1091         Gtk::TreeModel::Row row;
1092
1093         sample_format_list->clear ();
1094
1095         HasSampleFormat::SampleFormatList const & formats = ptr->get_sample_formats ();
1096
1097         for (HasSampleFormat::SampleFormatList::const_iterator it = formats.begin(); it != formats.end(); ++it) {
1098                 iter = sample_format_list->append();
1099                 row = *iter;
1100
1101                 row[sample_format_cols.ptr] = *it;
1102                 row[sample_format_cols.color] = (*it)->compatible() ? "white" : "red";
1103                 row[sample_format_cols.label] = (*it)->name();
1104
1105                 if ((*it)->selected()) {
1106                         sample_format_view.get_selection()->select (iter);
1107                 }
1108         }
1109
1110         dither_type_list->clear ();
1111
1112         HasSampleFormat::DitherTypeList const & types = ptr->get_dither_types ();
1113
1114         for (HasSampleFormat::DitherTypeList::const_iterator it = types.begin(); it != types.end(); ++it) {
1115                 iter = dither_type_list->append();
1116                 row = *iter;
1117
1118                 row[dither_type_cols.ptr] = *it;
1119                 row[dither_type_cols.color] = "white";
1120                 row[dither_type_cols.label] = (*it)->name();
1121
1122                 if ((*it)->selected()) {
1123                         dither_type_view.get_selection()->select (iter);
1124                 }
1125         }
1126 }
1127
1128 void
1129 ExportFormatDialog::fill_codec_quality_lists (boost::shared_ptr<ARDOUR::HasCodecQuality> ptr)
1130 {
1131         HasCodecQuality::CodecQualityList const & codecs = ptr->get_codec_qualities();
1132
1133         codec_quality_list->clear();
1134         for (HasCodecQuality::CodecQualityList::const_iterator it = codecs.begin(); it != codecs.end(); ++it) {
1135
1136         Gtk::TreeModel::iterator iter = codec_quality_list->append();
1137         Gtk::TreeModel::Row row = *iter;
1138                 row[codec_quality_cols.quality] = (*it)->quality;
1139                 row[codec_quality_cols.label] = (*it)->name;
1140         }
1141         set_codec_quality_selection ();
1142 }
1143
1144 void
1145 ExportFormatDialog::set_codec_quality_selection ()
1146 {
1147         for (Gtk::ListStore::Children::iterator it = codec_quality_list->children().begin(); it != codec_quality_list->children().end(); ++it) {
1148                 if (it->get_value (codec_quality_cols.quality) == format->codec_quality()) {
1149                         codec_quality_combo.set_active (it);
1150                         break;
1151                 }
1152         }
1153 }
1154
1155 void
1156 ExportFormatDialog::end_dialog ()
1157 {
1158         hide_all ();
1159 }
1160
1161 void
1162 ExportFormatDialog::prohibit_compatibility_selection ()
1163 {
1164         compatibility_select_connection.block (true);
1165         compatibility_view.get_selection()->unselect_all ();
1166         compatibility_select_connection.block (false);
1167 }