diff options
| author | Carl Hetherington <cth@carlh.net> | 2018-08-15 00:23:17 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2018-08-15 10:57:06 +0100 |
| commit | 6a69f5ba3ce43094493785bb449c91001557b80d (patch) | |
| tree | 8fdf1272da16f302be6ea372e6c179d2f64343f7 /src | |
| parent | 7459697905a79ff36c8cd676a9b2f150f6491d6d (diff) | |
Shift some more stuff around.
Diffstat (limited to 'src')
| -rw-r--r-- | src/wx/dolby_doremi_certificate_panel.cc | 23 | ||||
| -rw-r--r-- | src/wx/dolby_doremi_certificate_panel.h | 10 | ||||
| -rw-r--r-- | src/wx/download_certificate_dialog.cc | 14 | ||||
| -rw-r--r-- | src/wx/download_certificate_panel.cc | 26 | ||||
| -rw-r--r-- | src/wx/download_certificate_panel.h | 12 |
5 files changed, 38 insertions, 47 deletions
diff --git a/src/wx/dolby_doremi_certificate_panel.cc b/src/wx/dolby_doremi_certificate_panel.cc index 5a0ce028e..f0f0a2601 100644 --- a/src/wx/dolby_doremi_certificate_panel.cc +++ b/src/wx/dolby_doremi_certificate_panel.cc @@ -38,16 +38,10 @@ using boost::function; using boost::optional; using dcp::raw_convert; -DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) - : DownloadCertificatePanel (parent, dialog) +DolbyDoremiCertificatePanel::DolbyDoremiCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog) + : DownloadCertificatePanel (parent, message, dialog) { - add_label_to_sizer (_table, this, _("Serial number"), true); - _serial = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1)); - _table->Add (_serial, 1, wxEXPAND); - _serial->Bind (wxEVT_TEXT, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog)); - - layout (); } static void @@ -145,14 +139,13 @@ try_cp850 (list<string>& urls, list<string>& files, string prefix, string serial } void -DolbyDoremiCertificatePanel::do_download (wxStaticText* message) +DolbyDoremiCertificatePanel::do_download (string serial) { /* Try dcp2000, imb and ims prefixes (see mantis #375) */ string const prefix = "ftp://anonymous@ftp.cinema.dolby.com/Certificates/"; list<string> urls; list<string> files; - string const serial = wx_to_std (_serial->GetValue()); bool starts_with_digit = false; optional<char> starting_char; @@ -191,10 +184,10 @@ DolbyDoremiCertificatePanel::do_download (wxStaticText* message) } if (ok) { - message->SetLabel (_("Certificate downloaded")); + _message->SetLabel (_("Certificate downloaded")); _dialog->setup_sensitivity (); } else { - message->SetLabel (wxT ("")); + _message->SetLabel (wxT ("")); string s; BOOST_FOREACH (string e, errors) { @@ -205,12 +198,6 @@ DolbyDoremiCertificatePanel::do_download (wxStaticText* message) } } -bool -DolbyDoremiCertificatePanel::ready_to_download () const -{ - return !_serial->IsEmpty (); -} - wxString DolbyDoremiCertificatePanel::name () const { diff --git a/src/wx/dolby_doremi_certificate_panel.h b/src/wx/dolby_doremi_certificate_panel.h index 2e1e0f54e..21f928621 100644 --- a/src/wx/dolby_doremi_certificate_panel.h +++ b/src/wx/dolby_doremi_certificate_panel.h @@ -23,14 +23,8 @@ class DolbyDoremiCertificatePanel : public DownloadCertificatePanel { public: - DolbyDoremiCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); + DolbyDoremiCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog); - bool ready_to_download () const; - void do_download (wxStaticText* message); + void do_download (std::string serial); wxString name () const; - -private: - void finish_download (std::string serial, wxStaticText* message); - - wxTextCtrl* _serial; }; diff --git a/src/wx/download_certificate_dialog.cc b/src/wx/download_certificate_dialog.cc index bccfbb5c2..a2219cd6f 100644 --- a/src/wx/download_certificate_dialog.cc +++ b/src/wx/download_certificate_dialog.cc @@ -32,12 +32,6 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) _notebook = new wxNotebook (this, wxID_ANY); sizer->Add (_notebook, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); - _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, this)); - - BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { - _notebook->AddPage (i, i->name(), true); - } - _download = new wxButton (this, wxID_ANY, _("Download")); sizer->Add (_download, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP); @@ -48,6 +42,12 @@ DownloadCertificateDialog::DownloadCertificateDialog (wxWindow* parent) font.SetPointSize (font.GetPointSize() - 1); _message->SetFont (font); + _pages.push_back (new DolbyDoremiCertificatePanel (_notebook, _message, this)); + + BOOST_FOREACH (DownloadCertificatePanel* i, _pages) { + _notebook->AddPage (i, i->name(), true); + } + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); if (buttons) { sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); @@ -71,7 +71,7 @@ DownloadCertificateDialog::~DownloadCertificateDialog () void DownloadCertificateDialog::download () { - _pages[_notebook->GetSelection()]->download (_message); + _pages[_notebook->GetSelection()]->download (); } dcp::Certificate diff --git a/src/wx/download_certificate_panel.cc b/src/wx/download_certificate_panel.cc index 0c78901eb..f9a88a7bb 100644 --- a/src/wx/download_certificate_panel.cc +++ b/src/wx/download_certificate_panel.cc @@ -20,6 +20,7 @@ #include "wx_util.h" #include "download_certificate_panel.h" +#include "download_certificate_dialog.h" #include "lib/signal_manager.h" #include <dcp/util.h> #include <dcp/exceptions.h> @@ -28,9 +29,10 @@ using boost::function; using boost::optional; -DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog) +DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog) : wxPanel (parent, wxID_ANY) , _dialog (dialog) + , _message (message) { _overall_sizer = new wxBoxSizer (wxVERTICAL); SetSizer (_overall_sizer); @@ -39,11 +41,13 @@ DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCe _table->AddGrowableCol (1, 1); _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); -} -void -DownloadCertificatePanel::layout () -{ + add_label_to_sizer (_table, this, _("Serial number"), true); + _serial = new wxTextCtrl (this, wxID_ANY, wxT (""), wxDefaultPosition, wxSize (300, -1)); + _table->Add (_serial, 1, wxEXPAND); + + _serial->Bind (wxEVT_TEXT, boost::bind (&DownloadCertificateDialog::setup_sensitivity, _dialog)); + _overall_sizer->Layout (); _overall_sizer->SetSizeHints (this); } @@ -65,12 +69,18 @@ DownloadCertificatePanel::certificate () const } void -DownloadCertificatePanel::download (wxStaticText* message) +DownloadCertificatePanel::download () { - message->SetLabel (_("Downloading certificate")); + _message->SetLabel (_("Downloading certificate")); /* Hack: without this the SetLabel() above has no visible effect */ wxMilliSleep (200); - signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this, message)); + signal_manager->when_idle (boost::bind (&DownloadCertificatePanel::do_download, this, wx_to_std(_serial->GetValue()))); +} + +bool +DownloadCertificatePanel::ready_to_download () const +{ + return !_serial->IsEmpty (); } diff --git a/src/wx/download_certificate_panel.h b/src/wx/download_certificate_panel.h index 98e48de39..252474c59 100644 --- a/src/wx/download_certificate_panel.h +++ b/src/wx/download_certificate_panel.h @@ -30,25 +30,25 @@ class DownloadCertificateDialog; class DownloadCertificatePanel : public wxPanel { public: - DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog); + DownloadCertificatePanel (wxWindow* parent, wxStaticText* message, DownloadCertificateDialog* dialog); - virtual bool ready_to_download () const = 0; - virtual void do_download (wxStaticText* message) = 0; + virtual void do_download (std::string serial) = 0; virtual wxString name () const = 0; - void download (wxStaticText* message); + bool ready_to_download () const; + void download (); void load (boost::filesystem::path); boost::optional<dcp::Certificate> certificate () const; protected: - void layout (); - DownloadCertificateDialog* _dialog; wxFlexGridSizer* _table; + wxStaticText* _message; private: wxSizer* _overall_sizer; boost::optional<dcp::Certificate> _certificate; + wxTextCtrl* _serial; }; #endif |
