Fix for wx 2.8.
[dcpomatic.git] / src / wx / config_dialog.cc
index b0bd6f2ee5514c31b332ffc650846a03b704a721..b28c350ea25a802518f92e2fba38d231d436f8fa 100644 (file)
 
 #include <iostream>
 #include <boost/lexical_cast.hpp>
+#include <boost/filesystem.hpp>
+#include <wx/stdpaths.h>
 #include "lib/config.h"
 #include "lib/server.h"
-#include "lib/screen.h"
 #include "lib/format.h"
 #include "lib/scaler.h"
 #include "lib/filter.h"
 #include "wx_util.h"
 #include "filter_dialog.h"
 #include "server_dialog.h"
+#include "dir_picker_ctrl.h"
+#include "dci_metadata_dialog.h"
 
 using namespace std;
-using namespace boost;
+using boost::bind;
 
 ConfigDialog::ConfigDialog (wxWindow* parent)
-       : wxDialog (parent, wxID_ANY, _("DVD-o-matic Configuration"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
+       : wxDialog (parent, wxID_ANY, _("DVD-o-matic Preferences"), wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
 {
        wxFlexGridSizer* table = new wxFlexGridSizer (3, 6, 6);
        table->AddGrowableCol (1, 1);
 
-       add_label_to_sizer (table, this, "TMS IP address");
+       add_label_to_sizer (table, this, _("TMS IP address"));
        _tms_ip = new wxTextCtrl (this, wxID_ANY);
        table->Add (_tms_ip, 1, wxEXPAND);
        table->AddSpacer (0);
 
-       add_label_to_sizer (table, this, "TMS target path");
+       add_label_to_sizer (table, this, _("TMS target path"));
        _tms_path = new wxTextCtrl (this, wxID_ANY);
        table->Add (_tms_path, 1, wxEXPAND);
        table->AddSpacer (0);
 
-       add_label_to_sizer (table, this, "TMS user name");
+       add_label_to_sizer (table, this, _("TMS user name"));
        _tms_user = new wxTextCtrl (this, wxID_ANY);
        table->Add (_tms_user, 1, wxEXPAND);
        table->AddSpacer (0);
 
-       add_label_to_sizer (table, this, "TMS password");
+       add_label_to_sizer (table, this, _("TMS password"));
        _tms_password = new wxTextCtrl (this, wxID_ANY);
        table->Add (_tms_password, 1, wxEXPAND);
        table->AddSpacer (0);
 
-       add_label_to_sizer (table, this, "Threads to use for encoding on this host");
+       add_label_to_sizer (table, this, _("Threads to use for encoding on this host"));
        _num_local_encoding_threads = new wxSpinCtrl (this);
        table->Add (_num_local_encoding_threads, 1, wxEXPAND);
        table->AddSpacer (0);
 
-       add_label_to_sizer (table, this, "Colour look-up table");
-       _colour_lut = new wxComboBox (this, wxID_ANY);
-       for (int i = 0; i < 2; ++i) {
-               _colour_lut->Append (std_to_wx (colour_lut_index_to_name (i)));
-       }
-       _colour_lut->SetSelection (0);
-       table->Add (_colour_lut, 1, wxEXPAND);
+       add_label_to_sizer (table, this, _("Default directory for new films"));
+#ifdef __WXMSW__
+       _default_directory = new DirPickerCtrl (this);
+#else  
+       _default_directory = new wxDirPickerCtrl (this, wxDD_DIR_MUST_EXIST);
+#endif
+       table->Add (_default_directory, 1, wxEXPAND);
        table->AddSpacer (0);
 
-       add_label_to_sizer (table, this, "JPEG2000 bandwidth");
-       _j2k_bandwidth = new wxSpinCtrl (this, wxID_ANY);
-       table->Add (_j2k_bandwidth, 1, wxEXPAND);
-       add_label_to_sizer (table, this, "MBps");
+       add_label_to_sizer (table, this, _("Default DCI name details"));
+       _default_dci_metadata_button = new wxButton (this, wxID_ANY, _("Edit..."));
+       table->Add (_default_dci_metadata_button);
+       table->AddSpacer (1);
 
-       add_label_to_sizer (table, this, "Reference scaler for A/B");
-       _reference_scaler = new wxComboBox (this, wxID_ANY);
+       add_label_to_sizer (table, this, _("Reference scaler for A/B"));
+       _reference_scaler = new wxChoice (this, wxID_ANY);
        vector<Scaler const *> const sc = Scaler::all ();
        for (vector<Scaler const *>::const_iterator i = sc.begin(); i != sc.end(); ++i) {
                _reference_scaler->Append (std_to_wx ((*i)->name ()));
@@ -93,7 +96,7 @@ ConfigDialog::ConfigDialog (wxWindow* parent)
        table->AddSpacer (0);
 
        {
-               add_label_to_sizer (table, this, "Reference filters for A/B");
+               add_label_to_sizer (table, this, _("Reference filters for A/B"));
                wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
                _reference_filters = new wxStaticText (this, wxID_ANY, wxT (""));
                s->Add (_reference_filters, 1, wxEXPAND);
@@ -103,7 +106,7 @@ ConfigDialog::ConfigDialog (wxWindow* parent)
                table->AddSpacer (0);
        }
 
-       add_label_to_sizer (table, this, "Encoding Servers");
+       add_label_to_sizer (table, this, _("Encoding Servers"));
        _servers = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (220, 100), wxLC_REPORT | wxLC_SINGLE_SEL);
        wxListItem ip;
        ip.SetId (0);
@@ -142,17 +145,16 @@ ConfigDialog::ConfigDialog (wxWindow* parent)
        _num_local_encoding_threads->SetValue (config->num_local_encoding_threads ());
        _num_local_encoding_threads->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (ConfigDialog::num_local_encoding_threads_changed), 0, this);
 
-       _colour_lut->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (ConfigDialog::colour_lut_changed), 0, this);
-       
-       _j2k_bandwidth->SetRange (50, 250);
-       _j2k_bandwidth->SetValue (rint ((double) config->j2k_bandwidth() / 1e6));
-       _j2k_bandwidth->Connect (wxID_ANY, wxEVT_COMMAND_SPINCTRL_UPDATED, wxCommandEventHandler (ConfigDialog::j2k_bandwidth_changed), 0, this);
+       _default_directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir()))));
+       _default_directory->Connect (wxID_ANY, wxEVT_COMMAND_DIRPICKER_CHANGED, wxCommandEventHandler (ConfigDialog::default_directory_changed), 0, this);
+
+       _default_dci_metadata_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::edit_default_dci_metadata_clicked), 0, this);
 
        _reference_scaler->SetSelection (Scaler::as_index (config->reference_scaler ()));
-       _reference_scaler->Connect (wxID_ANY, wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler (ConfigDialog::reference_scaler_changed), 0, this);
+       _reference_scaler->Connect (wxID_ANY, wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler (ConfigDialog::reference_scaler_changed), 0, this);
 
        pair<string, string> p = Filter::ffmpeg_strings (config->reference_filters ());
-       _reference_filters->SetLabel (std_to_wx (p.first + " " + p.second));
+       _reference_filters->SetLabel (std_to_wx (p.first) + N_(" ") + std_to_wx (p.second));
        _reference_filters_button->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (ConfigDialog::edit_reference_filters_clicked), 0, this);
 
        vector<ServerDescription*> servers = config->servers ();
@@ -213,15 +215,9 @@ ConfigDialog::num_local_encoding_threads_changed (wxCommandEvent &)
 }
 
 void
-ConfigDialog::colour_lut_changed (wxCommandEvent &)
-{
-       Config::instance()->set_colour_lut_index (_colour_lut->GetSelection ());
-}
-
-void
-ConfigDialog::j2k_bandwidth_changed (wxCommandEvent &)
+ConfigDialog::default_directory_changed (wxCommandEvent &)
 {
-       Config::instance()->set_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1e6);
+       Config::instance()->set_default_directory (wx_to_std (_default_directory->GetPath ()));
 }
 
 void
@@ -287,7 +283,7 @@ ConfigDialog::remove_server_clicked (wxCommandEvent &)
 }
 
 void
-ConfigDialog::server_selection_changed (wxListEvent& ev)
+ConfigDialog::server_selection_changed (wxListEvent &)
 {
        int const i = _servers->GetNextItem (-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
        _edit_server->Enable (i >= 0);
@@ -307,7 +303,7 @@ void
 ConfigDialog::edit_reference_filters_clicked (wxCommandEvent &)
 {
        FilterDialog* d = new FilterDialog (this, Config::instance()->reference_filters ());
-       d->ActiveChanged.connect (sigc::mem_fun (*this, &ConfigDialog::reference_filters_changed));
+       d->ActiveChanged.connect (boost::bind (&ConfigDialog::reference_filters_changed, this, _1));
        d->ShowModal ();
        d->Destroy ();
 }
@@ -317,5 +313,14 @@ ConfigDialog::reference_filters_changed (vector<Filter const *> f)
 {
        Config::instance()->set_reference_filters (f);
        pair<string, string> p = Filter::ffmpeg_strings (Config::instance()->reference_filters ());
-       _reference_filters->SetLabel (std_to_wx (p.first + " " + p.second));
+       _reference_filters->SetLabel (std_to_wx (p.first) + N_(" ") + std_to_wx (p.second));
+}
+
+void
+ConfigDialog::edit_default_dci_metadata_clicked (wxCommandEvent &)
+{
+       DCIMetadataDialog* d = new DCIMetadataDialog (this, Config::instance()->default_dci_metadata ());
+       d->ShowModal ();
+       Config::instance()->set_default_dci_metadata (d->dci_metadata ());
+       d->Destroy ();
 }