X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fconfig_dialog.cc;h=b4adc855e4af103398fd11a8c5a27cbc33c6a8c6;hb=HEAD;hp=07ab2d8aab9321aa073d04ecff49c528a1b57f75;hpb=fecfda4c913da3f60ab4329d1f4f412bc27d19a7;p=dcpomatic.git diff --git a/src/wx/config_dialog.cc b/src/wx/config_dialog.cc index 07ab2d8aa..b4adc855e 100644 --- a/src/wx/config_dialog.cc +++ b/src/wx/config_dialog.cc @@ -25,7 +25,9 @@ #include "dcpomatic_button.h" #include "nag_dialog.h" #include "static_text.h" +#include "lib/constants.h" #include +#include #include @@ -126,8 +128,10 @@ GeneralPage::add_language_controls (wxGridBagSizer* table, int& r) languages.push_back (make_pair("Deutsch", "de_DE")); languages.push_back (make_pair("English", "en_GB")); languages.push_back (make_pair("Español", "es_ES")); + languages.push_back (make_pair("فارسی", "fa_IR")); languages.push_back (make_pair("Français", "fr_FR")); languages.push_back (make_pair("Italiano", "it_IT")); + languages.push_back (make_pair("ქართული", "ka_KA")); languages.push_back (make_pair("Nederlands", "nl_NL")); languages.push_back (make_pair("Русский", "ru_RU")); languages.push_back (make_pair("Polski", "pl_PL")); @@ -152,7 +156,7 @@ GeneralPage::add_language_controls (wxGridBagSizer* table, int& r) restart->SetFont (font); ++r; - _set_language->Bind (wxEVT_CHECKBOX, bind (&GeneralPage::set_language_changed, this)); + _set_language->bind(&GeneralPage::set_language_changed, this); _language->Bind (wxEVT_CHOICE, bind (&GeneralPage::language_changed, this)); } @@ -167,8 +171,8 @@ GeneralPage::add_update_controls (wxGridBagSizer* table, int& r) table->Add (_check_for_test_updates, wxGBPosition (r, 0), wxGBSpan (1, 2)); ++r; - _check_for_updates->Bind (wxEVT_CHECKBOX, bind (&GeneralPage::check_for_updates_changed, this)); - _check_for_test_updates->Bind (wxEVT_CHECKBOX, bind (&GeneralPage::check_for_test_updates_changed, this)); + _check_for_updates->bind(&GeneralPage::check_for_updates_changed, this); + _check_for_test_updates->bind(&GeneralPage::check_for_test_updates_changed, this); } void @@ -366,7 +370,7 @@ CertificateChainEditor::add_button (wxWindow* button) void CertificateChainEditor::add_certificate () { - auto d = new wxFileDialog (this, _("Select Certificate File")); + auto d = make_wx(this, _("Select Certificate File")); if (d->ShowModal() == wxID_OK) { try { @@ -376,7 +380,6 @@ CertificateChainEditor::add_certificate () extra = c.read_string (dcp::file_to_string (wx_to_std (d->GetPath ()))); } catch (boost::filesystem::filesystem_error& e) { error_dialog (this, _("Could not import certificate (%s)"), d->GetPath()); - d->Destroy (); return; } @@ -405,8 +408,6 @@ CertificateChainEditor::add_certificate () } } - d->Destroy (); - update_sensitivity (); } @@ -451,7 +452,7 @@ CertificateChainEditor::export_certificate () default_name = "intermediate.pem"; } - auto d = new wxFileDialog( + auto d = make_wx( this, _("Select Certificate File"), wxEmptyString, default_name, wxT ("PEM files (*.pem)|*.pem"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); @@ -461,45 +462,46 @@ CertificateChainEditor::export_certificate () ++j; } - if (d->ShowModal () == wxID_OK) { - boost::filesystem::path path (wx_to_std(d->GetPath())); - if (path.extension() != ".pem") { - path += ".pem"; - } - dcp::File f(path, "w"); - if (!f) { - throw OpenFileError (path, errno, OpenFileError::WRITE); - } + if (d->ShowModal() != wxID_OK) { + return; + } - string const s = j->certificate (true); - f.checked_write(s.c_str(), s.length()); + boost::filesystem::path path(wx_to_std(d->GetPath())); + if (path.extension() != ".pem") { + path += ".pem"; } - d->Destroy (); + dcp::File f(path, "w"); + if (!f) { + throw OpenFileError(path, errno, OpenFileError::WRITE); + } + + string const s = j->certificate(true); + f.checked_write(s.c_str(), s.length()); } void CertificateChainEditor::export_chain () { - auto d = new wxFileDialog ( + auto d = make_wx( this, _("Select Chain File"), wxEmptyString, wxT("certificate_chain.pem"), wxT("PEM files (*.pem)|*.pem"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - if (d->ShowModal () == wxID_OK) { - boost::filesystem::path path (wx_to_std(d->GetPath())); - if (path.extension() != ".pem") { - path += ".pem"; - } - dcp::File f(path, "w"); - if (!f) { - throw OpenFileError (path, errno, OpenFileError::WRITE); - } + if (d->ShowModal() != wxID_OK) { + return; + } - auto const s = _get()->chain(); - f.checked_write (s.c_str(), s.length()); + boost::filesystem::path path(wx_to_std(d->GetPath())); + if (path.extension() != ".pem") { + path += ".pem"; + } + dcp::File f(path, "w"); + if (!f) { + throw OpenFileError(path, errno, OpenFileError::WRITE); } - d->Destroy (); + auto const s = _get()->chain(); + f.checked_write(s.c_str(), s.length()); } void @@ -544,15 +546,13 @@ CertificateChainEditor::remake_certificates () return; } - auto d = new MakeChainDialog (this, _get()); + auto d = make_wx(this, _get()); if (d->ShowModal () == wxID_OK) { _set (d->get()); update_certificate_list (); update_private_key (); } - - d->Destroy (); } void @@ -573,12 +573,12 @@ CertificateChainEditor::update_private_key () void CertificateChainEditor::import_private_key () { - auto d = new wxFileDialog (this, _("Select Key File")); + auto d = make_wx(this, _("Select Key File")); if (d->ShowModal() == wxID_OK) { try { boost::filesystem::path p (wx_to_std (d->GetPath ())); - if (boost::filesystem::file_size (p) > 8192) { + if (dcp::filesystem::file_size(p) > 8192) { error_dialog ( this, wxString::Format (_("Could not read key file; file is too long (%s)"), std_to_wx (p.string ())) @@ -595,8 +595,6 @@ CertificateChainEditor::import_private_key () } } - d->Destroy (); - update_sensitivity (); } @@ -608,7 +606,7 @@ CertificateChainEditor::export_private_key () return; } - auto d = new wxFileDialog ( + auto d = make_wx( this, _("Select Key File"), wxEmptyString, wxT("private_key.pem"), wxT("PEM files (*.pem)|*.pem"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); @@ -626,7 +624,6 @@ CertificateChainEditor::export_private_key () auto const s = _get()->key().get (); f.checked_write(s.c_str(), s.length()); } - d->Destroy (); } wxString @@ -727,26 +724,26 @@ KeysPage::signing_advanced () void KeysPage::export_decryption_chain_and_key () { - auto d = new wxFileDialog ( + auto d = make_wx( _panel, _("Select Export File"), wxEmptyString, wxEmptyString, wxT ("DOM files (*.dom)|*.dom"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - if (d->ShowModal () == wxID_OK) { - boost::filesystem::path path (wx_to_std(d->GetPath())); - dcp::File f(path, "w"); - if (!f) { - throw OpenFileError (path, errno, OpenFileError::WRITE); - } + if (d->ShowModal() != wxID_OK) { + return; + } - auto const chain = Config::instance()->decryption_chain()->chain(); - f.checked_write (chain.c_str(), chain.length()); - auto const key = Config::instance()->decryption_chain()->key(); - DCPOMATIC_ASSERT (key); - f.checked_write(key->c_str(), key->length()); + boost::filesystem::path path(wx_to_std(d->GetPath())); + dcp::File f(path, "w"); + if (!f) { + throw OpenFileError(path, errno, OpenFileError::WRITE); } - d->Destroy (); + auto const chain = Config::instance()->decryption_chain()->chain(); + f.checked_write(chain.c_str(), chain.length()); + auto const key = Config::instance()->decryption_chain()->key(); + DCPOMATIC_ASSERT(key); + f.checked_write(key->c_str(), key->length()); } void @@ -761,41 +758,42 @@ KeysPage::import_decryption_chain_and_key () return; } - auto d = new wxFileDialog ( + auto d = make_wx( _panel, _("Select File To Import"), wxEmptyString, wxEmptyString, wxT ("DOM files (*.dom)|*.dom") ); - if (d->ShowModal () == wxID_OK) { - auto new_chain = make_shared(); + if (d->ShowModal() != wxID_OK) { + return; + } - dcp::File f(wx_to_std(d->GetPath()), "r"); - if (!f) { - throw OpenFileError (f.path(), errno, OpenFileError::WRITE); - } + auto new_chain = make_shared(); - string current; - while (!f.eof()) { - char buffer[128]; - if (f.gets(buffer, 128) == 0) { - break; - } - current += buffer; - if (strncmp (buffer, "-----END CERTIFICATE-----", 25) == 0) { - new_chain->add (dcp::Certificate (current)); - current = ""; - } else if (strncmp (buffer, "-----END RSA PRIVATE KEY-----", 29) == 0) { - new_chain->set_key (current); - current = ""; - } - } + dcp::File f(wx_to_std(d->GetPath()), "r"); + if (!f) { + throw OpenFileError(f.path(), errno, OpenFileError::WRITE); + } - if (new_chain->chain_valid() && new_chain->private_key_valid()) { - Config::instance()->set_decryption_chain (new_chain); - } else { - error_dialog (_panel, _("Invalid DCP-o-matic export file")); + string current; + while (!f.eof()) { + char buffer[128]; + if (f.gets(buffer, 128) == 0) { + break; + } + current += buffer; + if (strncmp (buffer, "-----END CERTIFICATE-----", 25) == 0) { + new_chain->add(dcp::Certificate(current)); + current = ""; + } else if (strncmp (buffer, "-----END RSA PRIVATE KEY-----", 29) == 0) { + new_chain->set_key(current); + current = ""; } } - d->Destroy (); + + if (new_chain->chain_valid() && new_chain->private_key_valid()) { + Config::instance()->set_decryption_chain(new_chain); + } else { + error_dialog(_panel, _("Invalid DCP-o-matic export file")); + } } bool @@ -822,26 +820,26 @@ KeysPage::export_decryption_certificate () } default_name += wxT("_kdm_decryption_cert.pem"); - auto d = new wxFileDialog ( + auto d = make_wx( _panel, _("Select Certificate File"), wxEmptyString, default_name, wxT("PEM files (*.pem)|*.pem"), wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); - if (d->ShowModal () == wxID_OK) { - boost::filesystem::path path (wx_to_std(d->GetPath())); - if (path.extension() != ".pem") { - path += ".pem"; - } - dcp::File f(path, "w"); - if (!f) { - throw OpenFileError (path, errno, OpenFileError::WRITE); - } + if (d->ShowModal() != wxID_OK) { + return; + } - auto const s = Config::instance()->decryption_chain()->leaf().certificate (true); - f.checked_write(s.c_str(), s.length()); + boost::filesystem::path path(wx_to_std(d->GetPath())); + if (path.extension() != ".pem") { + path += ".pem"; + } + dcp::File f(path, "w"); + if (!f) { + throw OpenFileError(path, errno, OpenFileError::WRITE); } - d->Destroy (); + auto const s = Config::instance()->decryption_chain()->leaf().certificate (true); + f.checked_write(s.c_str(), s.length()); } wxString @@ -870,7 +868,6 @@ SoundPage::setup () add_label_to_sizer (table, _panel, _("Mapping"), true, wxGBPosition(r, 0)); _map = new AudioMappingView (_panel, _("DCP"), _("DCP"), _("Output"), _("output")); - _map->SetSize (-1, 400); table->Add (_map, wxGBPosition(r, 1), wxDefaultSpan, wxEXPAND); ++r; @@ -884,6 +881,14 @@ SoundPage::setup () _sound_output_details->SetFont (font); RtAudio audio (DCPOMATIC_RTAUDIO_API); +#if (RTAUDIO_VERSION_MAJOR >= 6) + for (auto device_id: audio.getDeviceIds()) { + auto dev = audio.getDeviceInfo(device_id); + if (dev.outputChannels > 0) { + _sound_output->Append(std_to_wx(dev.name)); + } + } +#else for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) { try { auto dev = audio.getDeviceInfo (i); @@ -894,8 +899,9 @@ SoundPage::setup () /* Something went wrong so let's just ignore that device */ } } +#endif - _sound->Bind (wxEVT_CHECKBOX, bind(&SoundPage::sound_changed, this)); + _sound->bind(&SoundPage::sound_changed, this); _sound_output->Bind (wxEVT_CHOICE, bind(&SoundPage::sound_output_changed, this)); _map->Changed.connect (bind(&SoundPage::map_changed, this, _1)); _reset_to_default->Bind (wxEVT_BUTTON, bind(&SoundPage::reset_to_default, this)); @@ -925,11 +931,15 @@ SoundPage::sound_output_changed () RtAudio audio (DCPOMATIC_RTAUDIO_API); auto const so = get_sound_output(); string default_device; +#if (RTAUDIO_VERSION_MAJOR >= 6) + default_device = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; +#else try { default_device = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; } catch (RtAudioError&) { /* Never mind */ } +#endif if (!so || *so == default_device) { Config::instance()->unset_sound_output (); } else { @@ -952,11 +962,15 @@ SoundPage::config_changed () } else { /* No configured output means we should use the default */ RtAudio audio (DCPOMATIC_RTAUDIO_API); +#if (RTAUDIO_VERSION_MAJOR >= 6) + configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; +#else try { configured_so = audio.getDeviceInfo(audio.getDefaultOutputDevice()).name; } catch (RtAudioError&) { /* Probably no audio devices at all */ } +#endif } if (configured_so && current_so != configured_so) { @@ -986,6 +1000,14 @@ SoundPage::config_changed () int channels = 0; if (configured_so) { +#if (RTAUDIO_VERSION_MAJOR >= 6) + for (auto device_id: audio.getDeviceIds()) { + auto info = audio.getDeviceInfo(device_id); + if (info.name == *configured_so && info.outputChannels > 0) { + channels = info.outputChannels; + } + } +#else for (unsigned int i = 0; i < audio.getDeviceCount(); ++i) { try { auto info = audio.getDeviceInfo(i); @@ -996,6 +1018,7 @@ SoundPage::config_changed () /* Never mind */ } } +#endif } _sound_output_details->SetLabel (