X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fdownload_certificate_dialog.cc;h=e18723a4a08213a4e59e42c0431b592a8393e5ba;hb=ad5c8849fc3ef5aad88201f28db5474a60db4436;hp=bd3841f193205491c995382d6bbff35fdad7bb54;hpb=41b7a04cf3dedaa93aaf3c050db7a693281417f7;p=dcpomatic.git diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index bd3841f19..e18723a4a 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -1,49 +1,105 @@ /* - Copyright (C) 2014 Carl Hetherington + Copyright (C) 2014-2015 Carl Hetherington - This program is free software; you can redistribute it and/or modify + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. - This program is distributed in the hope that it will be useful, + DCP-o-matic is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + along with DCP-o-matic. If not, see . */ -#include +#include "dolby_doremi_certificate_panel.h" #include "download_certificate_dialog.h" #include "wx_util.h" -using boost::function; +using boost::optional; -DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent, function load) - : TableDialog (parent, _("Download certificate"), 2, true) - , _load (load) +DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) + : wxDialog (parent, wxID_ANY, _("Download certificate")) { + wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL); + + _notebook = new wxNotebook (this, wxID_ANY); + sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); + + _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, this)); + _setup.push_back (false); + _notebook->AddPage (_pages.back(), _("Dolby / Doremi"), true); + + _download = new wxButton (this, wxID_ANY, _("Download")); + sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); + + _message = new wxStaticText (this, wxID_ANY, wxT ("")); + sizer->Add (_message, 0, wxALL, DCPOMATIC_SIZER_GAP); + wxFont font = _message->GetFont(); + font.SetStyle (wxFONTSTYLE_ITALIC); + font.SetPointSize (font.GetPointSize() - 1); + _message->SetFont (font); + + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); + if (buttons) { + sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } + SetSizerAndFit (sizer); + + _notebook->Bind (wxEVT_NOTEBOOK_PAGE_CHANGED, &DownloadCertificateDialog::page_changed, this); + _download->Bind (wxEVT_BUTTON, boost::bind (&DownloadCertificateDialog::download, this)); + _download->Enable (false); + + wxNotebookEvent ev; + page_changed (ev); +} + +DownloadCertificateDialog::~DownloadCertificateDialog () +{ + _notebook->Unbind (wxEVT_NOTEBOOK_PAGE_CHANGED, &DownloadCertificateDialog::page_changed, this); } void -DownloadCertificateDialog::add_common_widgets () +DownloadCertificateDialog::download () { - add_spacer (); - _download = add (new wxButton (this, wxID_ANY, _("Download"))); + _pages[_notebook->GetSelection()]->download (_message); +} - add_spacer (); - _gauge = add (new wxGauge (this, wxID_ANY, 100)); +dcp::Certificate +DownloadCertificateDialog::certificate () const +{ + optional c = _pages[_notebook->GetSelection()]->certificate (); + DCPOMATIC_ASSERT (c); + return c.get (); +} - add_spacer (); - _message = add (new wxStaticText (this, wxID_ANY, wxT (""))); - - _download->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DownloadCertificateDialog::download, this)); - _download->Enable (false); +void +DownloadCertificateDialog::setup_sensitivity () +{ + DownloadCertificatePanel* p = _pages[_notebook->GetSelection()]; + _download->Enable (p->ready_to_download ()); + wxButton* ok = dynamic_cast (FindWindowById (wxID_OK, this)); + if (ok) { + ok->Enable (static_cast(p->certificate ())); + } + +} + +void +DownloadCertificateDialog::page_changed (wxNotebookEvent &) +{ + int const n = _notebook->GetSelection(); + if (!_setup[n]) { + _pages[n]->setup (); + _setup[n] = true; + } - layout (); + setup_sensitivity (); }