Shift some more stuff around.
authorCarl Hetherington <cth@carlh.net>
Tue, 14 Aug 2018 23:23:17 +0000 (00:23 +0100)
committerCarl Hetherington <cth@carlh.net>
Wed, 15 Aug 2018 09:57:06 +0000 (10:57 +0100)
src/wx/dolby_doremi_certificate_panel.cc
src/wx/dolby_doremi_certificate_panel.h
src/wx/download_certificate_dialog.cc
src/wx/download_certificate_panel.cc
src/wx/download_certificate_panel.h

index 5a0ce028e646298e50768ae97a34357da82b21e5..f0f0a2601e219d6d97a74df045d644dad3a51662 100644 (file)
@@ -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
 {
index 2e1e0f54e36a06cb6d5527719a6a0b465df36d32..21f9286218bebb1b58518002d62bca53fc1c497d 100644 (file)
 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;
 };
index bccfbb5c24067b9434f74da3926a30b54a676b8c..a2219cd6fec7a865d182d3a003a349a70130fae6 100644 (file)
@@ -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
index 0c78901eba551e21e9a76fc3b94f1467e09413d2..f9a88a7bbddbcaa823eb3af619a2462f6a554721 100644 (file)
@@ -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>
 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 ();
 }
index 98e48de39a105f9fe854372d5ddfab1d5edefe00..252474c59802e357151b36a076f047eb6610ec5e 100644 (file)
@@ -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