Extract constants.h
[dcpomatic.git] / src / wx / config_dialog.cc
index 08e2721da35e49f448b3d2ccabd9de93dbea9f22..6403d7e12a25b551cc92220515883e18873859f1 100644 (file)
 
 */
 
-#include "config_dialog.h"
-#include "static_text.h"
+
+#include "audio_mapping_view.h"
 #include "check_box.h"
-#include "nag_dialog.h"
+#include "config_dialog.h"
 #include "dcpomatic_button.h"
-#include "audio_mapping_view.h"
+#include "nag_dialog.h"
+#include "static_text.h"
+#include "lib/constants.h"
+#include <dcp/file.h>
 #include <dcp/raw_convert.h>
 
 
@@ -132,9 +135,11 @@ GeneralPage::add_language_controls (wxGridBagSizer* table, int& r)
        languages.push_back (make_pair("Português europeu", "pt_PT"));
        languages.push_back (make_pair("Português do Brasil", "pt_BR"));
        languages.push_back (make_pair("Svenska", "sv_SE"));
+       languages.push_back (make_pair("Slovenščina", "sl_SI"));
        languages.push_back (make_pair("Slovenský jazyk", "sk_SK"));
        // languages.push_back (make_pair("Türkçe", "tr_TR"));
        languages.push_back (make_pair("українська мова", "uk_UA"));
+       languages.push_back (make_pair("Magyar nyelv", "hu_HU"));
        checked_set (_language, languages);
        table->Add (_language, wxGBPosition (r, 1));
        ++r;
@@ -148,7 +153,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));
 }
 
@@ -163,8 +168,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
@@ -462,14 +467,13 @@ CertificateChainEditor::export_certificate ()
                if (path.extension() != ".pem") {
                        path += ".pem";
                }
-               auto f = fopen_boost (path, "w");
+               dcp::File f(path, "w");
                if (!f) {
                        throw OpenFileError (path, errno, OpenFileError::WRITE);
                }
 
                string const s = j->certificate (true);
-               checked_fwrite (s.c_str(), s.length(), f, path);
-               fclose (f);
+               f.checked_write(s.c_str(), s.length());
        }
        d->Destroy ();
 }
@@ -487,14 +491,13 @@ CertificateChainEditor::export_chain ()
                if (path.extension() != ".pem") {
                        path += ".pem";
                }
-               auto f = fopen_boost (path, "w");
+               dcp::File f(path, "w");
                if (!f) {
                        throw OpenFileError (path, errno, OpenFileError::WRITE);
                }
 
                auto const s = _get()->chain();
-               checked_fwrite (s.c_str(), s.length(), f, path);
-               fclose (f);
+               f.checked_write (s.c_str(), s.length());
        }
 
        d->Destroy ();
@@ -616,14 +619,13 @@ CertificateChainEditor::export_private_key ()
                if (path.extension() != ".pem") {
                        path += ".pem";
                }
-               auto f = fopen_boost (path, "w");
+               dcp::File f(path, "w");
                if (!f) {
                        throw OpenFileError (path, errno, OpenFileError::WRITE);
                }
 
                auto const s = _get()->key().get ();
-               checked_fwrite (s.c_str(), s.length(), f, path);
-               fclose (f);
+               f.checked_write(s.c_str(), s.length());
        }
        d->Destroy ();
 }
@@ -733,17 +735,16 @@ KeysPage::export_decryption_chain_and_key ()
 
        if (d->ShowModal () == wxID_OK) {
                boost::filesystem::path path (wx_to_std(d->GetPath()));
-               auto f = fopen_boost (path, "w");
+               dcp::File f(path, "w");
                if (!f) {
                        throw OpenFileError (path, errno, OpenFileError::WRITE);
                }
 
                auto const chain = Config::instance()->decryption_chain()->chain();
-               checked_fwrite (chain.c_str(), chain.length(), f, path);
-               optional<string> const key = Config::instance()->decryption_chain()->key();
+               f.checked_write (chain.c_str(), chain.length());
+               auto const key = Config::instance()->decryption_chain()->key();
                DCPOMATIC_ASSERT (key);
-               checked_fwrite (key->c_str(), key->length(), f, path);
-               fclose (f);
+               f.checked_write(key->c_str(), key->length());
        }
        d->Destroy ();
 
@@ -768,15 +769,15 @@ KeysPage::import_decryption_chain_and_key ()
        if (d->ShowModal () == wxID_OK) {
                auto new_chain = make_shared<dcp::CertificateChain>();
 
-               FILE* f = fopen_boost (wx_to_std (d->GetPath ()), "r");
+               dcp::File f(wx_to_std(d->GetPath()), "r");
                if (!f) {
-                       throw OpenFileError (wx_to_std (d->GetPath ()), errno, OpenFileError::WRITE);
+                       throw OpenFileError (f.path(), errno, OpenFileError::WRITE);
                }
 
                string current;
-               while (!feof (f)) {
+               while (!f.eof()) {
                        char buffer[128];
-                       if (fgets (buffer, 128, f) == 0) {
+                       if (f.gets(buffer, 128) == 0) {
                                break;
                        }
                        current += buffer;
@@ -788,7 +789,6 @@ KeysPage::import_decryption_chain_and_key ()
                                current = "";
                        }
                }
-               fclose (f);
 
                if (new_chain->chain_valid() && new_chain->private_key_valid()) {
                        Config::instance()->set_decryption_chain (new_chain);
@@ -833,14 +833,13 @@ KeysPage::export_decryption_certificate ()
                if (path.extension() != ".pem") {
                        path += ".pem";
                }
-               auto f = fopen_boost (path, "w");
+               dcp::File f(path, "w");
                if (!f) {
                        throw OpenFileError (path, errno, OpenFileError::WRITE);
                }
 
                auto const s = Config::instance()->decryption_chain()->leaf().certificate (true);
-               checked_fwrite (s.c_str(), s.length(), f, path);
-               fclose (f);
+               f.checked_write(s.c_str(), s.length());
        }
 
        d->Destroy ();
@@ -897,7 +896,7 @@ SoundPage::setup ()
                }
        }
 
-       _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));
@@ -1056,7 +1055,7 @@ LocationsPage::GetName () const
 wxBitmap
 LocationsPage::GetLargeIcon () const
 {
-       return wxBitmap(bitmap_path("locations"), wxBITMAP_TYPE_PNG);
+       return wxBitmap(icon_path("locations"), wxBITMAP_TYPE_PNG);
 }
 #endif