2 Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 #include "dolby_doremi_certificate_panel.h"
21 #include "download_certificate_dialog.h"
24 using boost::optional;
26 DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent)
27 : wxDialog (parent, wxID_ANY, _("Download certificate"))
29 wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
31 _notebook = new wxNotebook (this, wxID_ANY);
32 sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
34 _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, this));
35 _setup.push_back (false);
36 _notebook->AddPage (_pages.back(), _("Dolby / Doremi"), true);
38 _download = new wxButton (this, wxID_ANY, _("Download"));
39 sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
41 _message = new wxStaticText (this, wxID_ANY, wxT (""));
42 sizer->Add (_message, 0, wxALL, DCPOMATIC_SIZER_GAP);
43 wxFont font = _message->GetFont();
44 font.SetStyle (wxFONTSTYLE_ITALIC);
45 font.SetPointSize (font.GetPointSize() - 1);
46 _message->SetFont (font);
48 wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL);
50 sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
53 SetSizerAndFit (sizer);
55 _notebook->Bind (wxEVT_NOTEBOOK_PAGE_CHANGED, &DownloadCertificateDialog::page_changed, this);
56 _download->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DownloadCertificateDialog::download, this));
57 _download->Enable (false);
63 DownloadCertificateDialog::~DownloadCertificateDialog ()
65 _notebook->Unbind (wxEVT_NOTEBOOK_PAGE_CHANGED, &DownloadCertificateDialog::page_changed, this);
69 DownloadCertificateDialog::download ()
71 _pages[_notebook->GetSelection()]->download (_message);
75 DownloadCertificateDialog::certificate () const
77 optional<dcp::Certificate> c = _pages[_notebook->GetSelection()]->certificate ();
83 DownloadCertificateDialog::setup_sensitivity ()
85 DownloadCertificatePanel* p = _pages[_notebook->GetSelection()];
86 _download->Enable (p->ready_to_download ());
87 wxButton* ok = dynamic_cast<wxButton *> (FindWindowById (wxID_OK, this));
89 ok->Enable (static_cast<bool>(p->certificate ()));
95 DownloadCertificateDialog::page_changed (wxNotebookEvent &)
97 int const n = _notebook->GetSelection();
103 setup_sensitivity ();