Fix bars at side/top/bottom of image in full-screen player (#1397).
[dcpomatic.git] / src / wx / config_dialog.cc
index 2f396ded0e969cb3675ac50ace51066675a936b8..34bdee8b33693d699de5915414cd5a3b2b193ac9 100644 (file)
@@ -515,7 +515,8 @@ CertificateChainEditor::export_certificate ()
        }
 
        wxFileDialog* d = new wxFileDialog (
-               this, _("Select Certificate File"), wxEmptyString, wxEmptyString, wxT ("PEM files (*.pem)|*.pem"), wxFD_SAVE
+               this, _("Select Certificate File"), wxEmptyString, wxEmptyString, wxT ("PEM files (*.pem)|*.pem"),
+               wxFD_SAVE | wxFD_OVERWRITE_PROMPT
                );
 
        dcp::CertificateChain::List all = _get()->root_to_leaf ();
@@ -525,17 +526,15 @@ CertificateChainEditor::export_certificate ()
        }
 
        if (d->ShowModal () == wxID_OK) {
-               optional<boost::filesystem::path> path = path_from_file_dialog (d, "pem");
-               if (path) {
-                       FILE* f = fopen_boost (*path, "w");
-                       if (!f) {
-                               throw OpenFileError (*path, errno, false);
-                       }
-
-                       string const s = j->certificate (true);
-                       fwrite (s.c_str(), 1, s.length(), f);
-                       fclose (f);
+               boost::filesystem::path path (wx_to_std(d->GetPath()));
+               FILE* f = fopen_boost (path, "w");
+               if (!f) {
+                       throw OpenFileError (path, errno, false);
                }
+
+               string const s = j->certificate (true);
+               fwrite (s.c_str(), 1, s.length(), f);
+               fclose (f);
        }
        d->Destroy ();
 }
@@ -695,21 +694,20 @@ CertificateChainEditor::export_private_key ()
        }
 
        wxFileDialog* d = new wxFileDialog (
-               this, _("Select Key File"), wxEmptyString, wxEmptyString, wxT ("PEM files (*.pem)|*.pem"), wxFD_SAVE
+               this, _("Select Key File"), wxEmptyString, wxEmptyString, wxT ("PEM files (*.pem)|*.pem"),
+               wxFD_SAVE | wxFD_OVERWRITE_PROMPT
                );
 
        if (d->ShowModal () == wxID_OK) {
-               optional<boost::filesystem::path> path = path_from_file_dialog (d, "pem");
-               if (path) {
-                       FILE* f = fopen_boost (*path, "w");
-                       if (!f) {
-                               throw OpenFileError (*path, errno, false);
-                       }
-
-                       string const s = _get()->key().get ();
-                       fwrite (s.c_str(), 1, s.length(), f);
-                       fclose (f);
+               boost::filesystem::path path (wx_to_std(d->GetPath()));
+               FILE* f = fopen_boost (path, "w");
+               if (!f) {
+                       throw OpenFileError (path, errno, false);
                }
+
+               string const s = _get()->key().get ();
+               fwrite (s.c_str(), 1, s.length(), f);
+               fclose (f);
        }
        d->Destroy ();
 }
@@ -792,24 +790,23 @@ void
 KeysPage::export_decryption_chain_and_key ()
 {
        wxFileDialog* d = new wxFileDialog (
-               _panel, _("Select Export File"), wxEmptyString, wxEmptyString, wxT ("DOM files (*.dom)|*.dom"), wxFD_SAVE
+               _panel, _("Select Export File"), wxEmptyString, wxEmptyString, wxT ("DOM files (*.dom)|*.dom"),
+               wxFD_SAVE | wxFD_OVERWRITE_PROMPT
                );
 
        if (d->ShowModal () == wxID_OK) {
-               optional<boost::filesystem::path> path = path_from_file_dialog (d, "dom");
-               if (path) {
-                       FILE* f = fopen_boost (*path, "w");
-                       if (!f) {
-                               throw OpenFileError (wx_to_std (d->GetPath ()), errno, false);
-                       }
-
-                       string const chain = Config::instance()->decryption_chain()->chain();
-                       fwrite (chain.c_str(), 1, chain.length(), f);
-                       optional<string> const key = Config::instance()->decryption_chain()->key();
-                       DCPOMATIC_ASSERT (key);
-                       fwrite (key->c_str(), 1, key->length(), f);
-                       fclose (f);
+               boost::filesystem::path path (wx_to_std(d->GetPath()));
+               FILE* f = fopen_boost (path, "w");
+               if (!f) {
+                       throw OpenFileError (path, errno, false);
                }
+
+               string const chain = Config::instance()->decryption_chain()->chain();
+               fwrite (chain.c_str(), 1, chain.length(), f);
+               optional<string> const key = Config::instance()->decryption_chain()->key();
+               DCPOMATIC_ASSERT (key);
+               fwrite (key->c_str(), 1, key->length(), f);
+               fclose (f);
        }
        d->Destroy ();
 
@@ -871,21 +868,20 @@ void
 KeysPage::export_decryption_chain ()
 {
        wxFileDialog* d = new wxFileDialog (
-               _panel, _("Select Chain File"), wxEmptyString, _("dcpomatic_kdm_decryption_chain.pem"), wxT ("PEM files (*.pem)|*.pem"), wxFD_SAVE
+               _panel, _("Select Chain File"), wxEmptyString, _("dcpomatic_kdm_decryption_chain.pem"), wxT ("PEM files (*.pem)|*.pem"),
+               wxFD_SAVE | wxFD_OVERWRITE_PROMPT
                );
 
        if (d->ShowModal () == wxID_OK) {
-               optional<boost::filesystem::path> path = path_from_file_dialog (d, "pem");
-               if (path) {
-                       FILE* f = fopen_boost (*path, "w");
-                       if (!f) {
-                               throw OpenFileError (*path, errno, false);
-                       }
-
-                       string const s = Config::instance()->decryption_chain()->chain();
-                       fwrite (s.c_str(), 1, s.length(), f);
-                       fclose (f);
+               boost::filesystem::path path (wx_to_std(d->GetPath()));
+               FILE* f = fopen_boost (path, "w");
+               if (!f) {
+                       throw OpenFileError (path, errno, false);
                }
+
+               string const s = Config::instance()->decryption_chain()->chain();
+               fwrite (s.c_str(), 1, s.length(), f);
+               fclose (f);
        }
        d->Destroy ();
 }
@@ -894,21 +890,20 @@ void
 KeysPage::export_decryption_certificate ()
 {
        wxFileDialog* d = new wxFileDialog (
-               _panel, _("Select Certificate File"), wxEmptyString, _("dcpomatic_kdm_decryption_cert.pem"), wxT ("PEM files (*.pem)|*.pem"), wxFD_SAVE
+               _panel, _("Select Certificate File"), wxEmptyString, _("dcpomatic_kdm_decryption_cert.pem"), wxT ("PEM files (*.pem)|*.pem"),
+               wxFD_SAVE | wxFD_OVERWRITE_PROMPT
                );
 
        if (d->ShowModal () == wxID_OK) {
-               optional<boost::filesystem::path> path = path_from_file_dialog (d, "pem");
-               if (path) {
-                       FILE* f = fopen_boost (*path, "w");
-                       if (!f) {
-                               throw OpenFileError (*path, errno, false);
-                       }
-
-                       string const s = Config::instance()->decryption_chain()->leaf().certificate (true);
-                       fwrite (s.c_str(), 1, s.length(), f);
-                       fclose (f);
+               boost::filesystem::path path (wx_to_std(d->GetPath()));
+               FILE* f = fopen_boost (path, "w");
+               if (!f) {
+                       throw OpenFileError (path, errno, false);
                }
+
+               string const s = Config::instance()->decryption_chain()->leaf().certificate (true);
+               fwrite (s.c_str(), 1, s.length(), f);
+               fclose (f);
        }
 
        d->Destroy ();