Rearrange cerficate download UI a bit.
[dcpomatic.git] / src / wx / download_certificate_panel.cc
1 /*
2     Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 #include "wx_util.h"
21 #include "download_certificate_panel.h"
22 #include <dcp/util.h>
23 #include <dcp/exceptions.h>
24 #include <boost/bind.hpp>
25
26 using boost::function;
27
28 DownloadCertificatePanel::DownloadCertificatePanel (wxWindow* parent, DownloadCertificateDialog* dialog)
29         : wxPanel (parent, wxID_ANY)
30         , _dialog (dialog)
31 {
32         _overall_sizer = new wxBoxSizer (wxVERTICAL);
33         SetSizer (_overall_sizer);
34
35         _table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
36         _table->AddGrowableCol (1, 1);
37
38         _overall_sizer->Add (_table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
39 }
40
41 void
42 DownloadCertificatePanel::layout ()
43 {
44         _overall_sizer->Layout ();
45         _overall_sizer->SetSizeHints (this);
46 }
47
48 void
49 DownloadCertificatePanel::load (boost::filesystem::path file)
50 {
51         try {
52                 _certificate = dcp::Certificate (dcp::file_to_string (file));
53         } catch (dcp::MiscError& e) {
54                 error_dialog (this, wxString::Format (_("Could not read certificate file (%s)"), std_to_wx(e.what()).data()));
55         }
56 }
57
58 dcp::Certificate
59 DownloadCertificatePanel::certificate () const
60 {
61         DCPOMATIC_ASSERT (_certificate);
62         return _certificate.get ();
63 }