2 Copyright (C) 2017-2020 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
22 #include "check_box.h"
23 #include "export_subtitles_dialog.h"
24 #include "file_picker_ctrl.h"
26 #include "lib/warnings.h"
27 DCPOMATIC_DISABLE_WARNINGS
28 #include <wx/filepicker.h>
29 DCPOMATIC_ENABLE_WARNINGS
30 #include <boost/bind.hpp>
37 ExportSubtitlesDialog::ExportSubtitlesDialog (wxWindow* parent, string name, bool interop)
38 : TableDialog (parent, _("Export subtitles"), 2, 1, true)
39 , _initial_name (name)
42 _split_reels = new CheckBox (this, _("Write reels into separate files"));
43 add (_split_reels, false);
46 _include_font = new CheckBox (this, _("Define font in output and export font file"));
47 add (_include_font, false);
51 add (_("Output file"), true);
52 /* Don't warn overwrite here, because on Linux (at least) if we specify a filename like foo
53 the wxFileDialog will check that foo exists, but we will add an extension so we actually
54 need to check if foo.mov (or similar) exists. I can't find a way to make wxWidgets do this,
55 so disable its check and the caller will have to do it themselves.
57 _file = new FilePickerCtrl (this, _("Select output file"), _("Subtitle files (.xml)|*.xml"), false, false);
58 _file->SetPath (_initial_name);
61 _file->Bind (wxEVT_FILEPICKER_CHANGED, bind(&ExportSubtitlesDialog::file_changed, this));
65 wxButton* ok = dynamic_cast<wxButton *>(FindWindowById(wxID_OK, this));
70 boost::filesystem::path
71 ExportSubtitlesDialog::path () const
73 wxFileName fn (_file->GetPath());
75 return wx_to_std (fn.GetFullPath());
80 ExportSubtitlesDialog::split_reels () const
82 return _split_reels->GetValue ();
87 ExportSubtitlesDialog::include_font () const
89 return _include_font ? _include_font->GetValue () : true;
94 ExportSubtitlesDialog::file_changed ()
96 wxButton* ok = dynamic_cast<wxButton *> (FindWindowById(wxID_OK, this));
97 DCPOMATIC_ASSERT (ok);
98 ok->Enable (path().is_absolute());