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)
38 : TableDialog (parent, _("Export subtitles"), 2, 1, true)
39 , _initial_name (name)
41 _split_reels = new CheckBox (this, _("Write reels into separate files"));
42 add (_split_reels, false);
45 add (_("Output file"), true);
46 /* Don't warn overwrite here, because on Linux (at least) if we specify a filename like foo
47 the wxFileDialog will check that foo exists, but we will add an extension so we actually
48 need to check if foo.mov (or similar) exists. I can't find a way to make wxWidgets do this,
49 so disable its check and the caller will have to do it themselves.
51 _file = new FilePickerCtrl (this, _("Select output file"), _("Subtitle files (.xml)|*.xml"), false, false);
52 _file->SetPath (_initial_name);
55 _file->Bind (wxEVT_FILEPICKER_CHANGED, bind(&ExportSubtitlesDialog::file_changed, this));
59 wxButton* ok = dynamic_cast<wxButton *>(FindWindowById(wxID_OK, this));
64 boost::filesystem::path
65 ExportSubtitlesDialog::path () const
67 wxFileName fn (_file->GetPath());
69 return wx_to_std (fn.GetFullPath());
74 ExportSubtitlesDialog::split_reels () const
76 return _split_reels->GetValue ();
81 ExportSubtitlesDialog::file_changed ()
83 wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
84 DCPOMATIC_ASSERT (ok);
85 ok->Enable (path().is_absolute());