More bits and pieces.
[dcpomatic.git] / src / wx / config_dialog.cc
1 /*
2     Copyright (C) 2012-2014 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 /** @file src/config_dialog.cc
21  *  @brief A dialogue to edit DCP-o-matic configuration.
22  */
23
24 #include <iostream>
25 #include <boost/lexical_cast.hpp>
26 #include <boost/filesystem.hpp>
27 #include <wx/stdpaths.h>
28 #include <wx/preferences.h>
29 #include <wx/filepicker.h>
30 #include <wx/spinctrl.h>
31 #include <libdcp/colour_matrix.h>
32 #include "lib/config.h"
33 #include "lib/ratio.h"
34 #include "lib/scaler.h"
35 #include "lib/filter.h"
36 #include "lib/dcp_content_type.h"
37 #include "lib/colour_conversion.h"
38 #include "config_dialog.h"
39 #include "wx_util.h"
40 #include "editable_list.h"
41 #include "filter_dialog.h"
42 #include "dir_picker_ctrl.h"
43 #include "dci_metadata_dialog.h"
44 #include "preset_colour_conversion_dialog.h"
45 #include "server_dialog.h"
46
47 using std::vector;
48 using std::string;
49 using std::list;
50 using std::cout;
51 using boost::bind;
52 using boost::shared_ptr;
53 using boost::lexical_cast;
54
55 class GeneralPage : public wxStockPreferencesPage
56 {
57 public:
58         GeneralPage ()
59                 : wxStockPreferencesPage (Kind_General)
60         {}
61
62         wxWindow* CreateWindow (wxWindow* parent)
63         {
64                 wxPanel* panel = new wxPanel (parent);
65                 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
66                 panel->SetSizer (s);
67
68                 wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
69                 table->AddGrowableCol (1, 1);
70                 s->Add (table, 1, wxALL | wxEXPAND, 8);
71                 
72                 _set_language = new wxCheckBox (panel, wxID_ANY, _("Set language"));
73                 table->Add (_set_language, 1);
74                 _language = new wxChoice (panel, wxID_ANY);
75                 _language->Append (wxT ("English"));
76                 _language->Append (wxT ("Français"));
77                 _language->Append (wxT ("Italiano"));
78                 _language->Append (wxT ("Español"));
79                 _language->Append (wxT ("Svenska"));
80                 _language->Append (wxT ("Deutsch"));
81                 table->Add (_language);
82                 
83                 wxStaticText* restart = add_label_to_sizer (table, panel, _("(restart DCP-o-matic to see language changes)"), false);
84                 wxFont font = restart->GetFont();
85                 font.SetStyle (wxFONTSTYLE_ITALIC);
86                 font.SetPointSize (font.GetPointSize() - 1);
87                 restart->SetFont (font);
88                 table->AddSpacer (0);
89                 
90                 add_label_to_sizer (table, panel, _("Threads to use for encoding on this host"), true);
91                 _num_local_encoding_threads = new wxSpinCtrl (panel);
92                 table->Add (_num_local_encoding_threads, 1);
93                 
94                 add_label_to_sizer (table, panel, _("Outgoing mail server"), true);
95                 _mail_server = new wxTextCtrl (panel, wxID_ANY);
96                 table->Add (_mail_server, 1, wxEXPAND | wxALL);
97                 
98                 add_label_to_sizer (table, panel, _("Mail user name"), true);
99                 _mail_user = new wxTextCtrl (panel, wxID_ANY);
100                 table->Add (_mail_user, 1, wxEXPAND | wxALL);
101                 
102                 add_label_to_sizer (table, panel, _("Mail password"), true);
103                 _mail_password = new wxTextCtrl (panel, wxID_ANY);
104                 table->Add (_mail_password, 1, wxEXPAND | wxALL);
105                 
106                 wxStaticText* plain = add_label_to_sizer (table, panel, _("(password will be stored on disk in plaintext)"), false);
107                 plain->SetFont (font);
108                 table->AddSpacer (0);
109                 
110                 add_label_to_sizer (table, panel, _("From address for KDM emails"), true);
111                 _kdm_from = new wxTextCtrl (panel, wxID_ANY);
112                 table->Add (_kdm_from, 1, wxEXPAND | wxALL);
113                 
114                 _check_for_updates = new wxCheckBox (panel, wxID_ANY, _("Check for updates on startup"));
115                 table->Add (_check_for_updates, 1, wxEXPAND | wxALL);
116                 table->AddSpacer (0);
117                 
118                 _check_for_test_updates = new wxCheckBox (panel, wxID_ANY, _("Check for testing updates as well as stable ones"));
119                 table->Add (_check_for_test_updates, 1, wxEXPAND | wxALL);
120                 table->AddSpacer (0);
121                 
122                 Config* config = Config::instance ();
123                 
124                 _set_language->SetValue (config->language ());
125                 
126                 if (config->language().get_value_or ("") == "fr") {
127                         _language->SetSelection (1);
128                 } else if (config->language().get_value_or ("") == "it") {
129                 _language->SetSelection (2);
130                 } else if (config->language().get_value_or ("") == "es") {
131                         _language->SetSelection (3);
132                 } else if (config->language().get_value_or ("") == "sv") {
133                         _language->SetSelection (4);
134                 } else if (config->language().get_value_or ("") == "de") {
135                         _language->SetSelection (5);
136                 } else {
137                         _language->SetSelection (0);
138                 }
139                 
140                 setup_language_sensitivity ();
141                 
142                 _set_language->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::set_language_changed, this));
143                 _language->Bind     (wxEVT_COMMAND_CHOICE_SELECTED,  boost::bind (&GeneralPage::language_changed,     this));
144                 
145                 _num_local_encoding_threads->SetRange (1, 128);
146                 _num_local_encoding_threads->SetValue (config->num_local_encoding_threads ());
147                 _num_local_encoding_threads->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&GeneralPage::num_local_encoding_threads_changed, this));
148                 
149                 _mail_server->SetValue (std_to_wx (config->mail_server ()));
150                 _mail_server->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&GeneralPage::mail_server_changed, this));
151                 _mail_user->SetValue (std_to_wx (config->mail_user ()));
152                 _mail_user->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&GeneralPage::mail_user_changed, this));
153                 _mail_password->SetValue (std_to_wx (config->mail_password ()));
154                 _mail_password->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&GeneralPage::mail_password_changed, this));
155                 _kdm_from->SetValue (std_to_wx (config->kdm_from ()));
156                 _kdm_from->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&GeneralPage::kdm_from_changed, this));
157                 _check_for_updates->SetValue (config->check_for_updates ());
158                 _check_for_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_updates_changed, this));
159                 _check_for_test_updates->SetValue (config->check_for_test_updates ());
160                 _check_for_test_updates->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&GeneralPage::check_for_test_updates_changed, this));
161                 
162                 return panel;
163         }
164
165 private:        
166         void setup_language_sensitivity ()
167         {
168                 _language->Enable (_set_language->GetValue ());
169         }
170
171         void set_language_changed ()
172         {
173                 setup_language_sensitivity ();
174                 if (_set_language->GetValue ()) {
175                         language_changed ();
176                 } else {
177                         Config::instance()->unset_language ();
178                 }
179         }
180
181         void language_changed ()
182         {
183                 switch (_language->GetSelection ()) {
184                 case 0:
185                         Config::instance()->set_language ("en");
186                         break;
187                 case 1:
188                         Config::instance()->set_language ("fr");
189                         break;
190                 case 2:
191                         Config::instance()->set_language ("it");
192                         break;
193                 case 3:
194                         Config::instance()->set_language ("es");
195                         break;
196                 case 4:
197                         Config::instance()->set_language ("sv");
198                         break;
199                 case 5:
200                         Config::instance()->set_language ("de");
201                         break;
202                 }
203         }
204         
205         void mail_server_changed ()
206         {
207                 Config::instance()->set_mail_server (wx_to_std (_mail_server->GetValue ()));
208         }
209         
210         void mail_user_changed ()
211         {
212                 Config::instance()->set_mail_user (wx_to_std (_mail_user->GetValue ()));
213         }
214         
215         void mail_password_changed ()
216         {
217                 Config::instance()->set_mail_password (wx_to_std (_mail_password->GetValue ()));
218         }
219         
220         void kdm_from_changed ()
221         {
222                 Config::instance()->set_kdm_from (wx_to_std (_kdm_from->GetValue ()));
223         }
224
225         void check_for_updates_changed ()
226         {
227                 Config::instance()->set_check_for_updates (_check_for_updates->GetValue ());
228         }
229         
230         void check_for_test_updates_changed ()
231         {
232                 Config::instance()->set_check_for_test_updates (_check_for_test_updates->GetValue ());
233         }
234
235         void num_local_encoding_threads_changed ()
236         {
237                 Config::instance()->set_num_local_encoding_threads (_num_local_encoding_threads->GetValue ());
238         }
239         
240         wxCheckBox* _set_language;
241         wxChoice* _language;
242         wxSpinCtrl* _num_local_encoding_threads;
243         wxTextCtrl* _mail_server;
244         wxTextCtrl* _mail_user;
245         wxTextCtrl* _mail_password;
246         wxTextCtrl* _kdm_from;
247         wxCheckBox* _check_for_updates;
248         wxCheckBox* _check_for_test_updates;
249 };
250
251 class DefaultsPage : public wxPreferencesPage
252 {
253 public:
254         wxString GetName () const
255         {
256                 return _("Defaults");
257         }
258
259 #ifdef DCPOMATIC_OSX    
260         wxBitmap GetLargeIcon () const
261         {
262                 return wxBitmap ("defaults", wxBITMAP_TYPE_PNG_RESOURCE);
263         }
264 #endif  
265
266         wxWindow* CreateWindow (wxWindow* parent)
267         {
268                 wxPanel* panel = new wxPanel (parent);
269                 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
270                 panel->SetSizer (s);
271
272                 wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
273                 table->AddGrowableCol (1, 1);
274                 s->Add (table, 1, wxALL | wxEXPAND, 8);
275                 
276                 {
277                         add_label_to_sizer (table, panel, _("Default duration of still images"), true);
278                         wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
279                         _still_length = new wxSpinCtrl (panel);
280                         s->Add (_still_length);
281                         add_label_to_sizer (s, panel, _("s"), false);
282                         table->Add (s, 1);
283                 }
284                 
285                 add_label_to_sizer (table, panel, _("Default directory for new films"), true);
286 #ifdef DCPOMATIC_USE_OWN_DIR_PICKER
287                 _directory = new DirPickerCtrl (panel);
288 #else   
289                 _directory = new wxDirPickerCtrl (panel, wxDD_DIR_MUST_EXIST);
290 #endif
291                 table->Add (_directory, 1, wxEXPAND);
292                 
293                 add_label_to_sizer (table, panel, _("Default DCI name details"), true);
294                 _dci_metadata_button = new wxButton (panel, wxID_ANY, _("Edit..."));
295                 table->Add (_dci_metadata_button);
296                 
297                 add_label_to_sizer (table, panel, _("Default container"), true);
298                 _container = new wxChoice (panel, wxID_ANY);
299                 table->Add (_container);
300                 
301                 add_label_to_sizer (table, panel, _("Default content type"), true);
302                 _dcp_content_type = new wxChoice (panel, wxID_ANY);
303                 table->Add (_dcp_content_type);
304                 
305                 {
306                         add_label_to_sizer (table, panel, _("Default JPEG2000 bandwidth"), true);
307                         wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
308                         _j2k_bandwidth = new wxSpinCtrl (panel);
309                         s->Add (_j2k_bandwidth);
310                         add_label_to_sizer (s, panel, _("Mbit/s"), false);
311                         table->Add (s, 1);
312                 }
313                 
314                 {
315                         add_label_to_sizer (table, panel, _("Default audio delay"), true);
316                         wxBoxSizer* s = new wxBoxSizer (wxHORIZONTAL);
317                         _audio_delay = new wxSpinCtrl (panel);
318                         s->Add (_audio_delay);
319                         add_label_to_sizer (s, panel, _("ms"), false);
320                         table->Add (s, 1);
321                 }
322
323                 add_label_to_sizer (table, panel, _("Default issuer"), true);
324                 _issuer = new wxTextCtrl (panel, wxID_ANY);
325                 table->Add (_issuer, 1, wxEXPAND);
326
327                 add_label_to_sizer (table, panel, _("Default creator"), true);
328                 _creator = new wxTextCtrl (panel, wxID_ANY);
329                 table->Add (_creator, 1, wxEXPAND);
330                 
331                 Config* config = Config::instance ();
332                 
333                 _still_length->SetRange (1, 3600);
334                 _still_length->SetValue (config->default_still_length ());
335                 _still_length->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DefaultsPage::still_length_changed, this));
336                 
337                 _directory->SetPath (std_to_wx (config->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()));
338                 _directory->Bind (wxEVT_COMMAND_DIRPICKER_CHANGED, boost::bind (&DefaultsPage::directory_changed, this));
339                 
340                 _dci_metadata_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DefaultsPage::edit_dci_metadata_clicked, this, parent));
341                 
342                 vector<Ratio const *> ratio = Ratio::all ();
343                 int n = 0;
344                 for (vector<Ratio const *>::iterator i = ratio.begin(); i != ratio.end(); ++i) {
345                         _container->Append (std_to_wx ((*i)->nickname ()));
346                         if (*i == config->default_container ()) {
347                                 _container->SetSelection (n);
348                         }
349                         ++n;
350                 }
351                 
352                 _container->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DefaultsPage::container_changed, this));
353                 
354                 vector<DCPContentType const *> const ct = DCPContentType::all ();
355                 n = 0;
356                 for (vector<DCPContentType const *>::const_iterator i = ct.begin(); i != ct.end(); ++i) {
357                         _dcp_content_type->Append (std_to_wx ((*i)->pretty_name ()));
358                         if (*i == config->default_dcp_content_type ()) {
359                                 _dcp_content_type->SetSelection (n);
360                         }
361                         ++n;
362                 }
363                 
364                 _dcp_content_type->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&DefaultsPage::dcp_content_type_changed, this));
365                 
366                 _j2k_bandwidth->SetRange (50, 250);
367                 _j2k_bandwidth->SetValue (config->default_j2k_bandwidth() / 1000000);
368                 _j2k_bandwidth->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DefaultsPage::j2k_bandwidth_changed, this));
369                 
370                 _audio_delay->SetRange (-1000, 1000);
371                 _audio_delay->SetValue (config->default_audio_delay ());
372                 _audio_delay->Bind (wxEVT_COMMAND_SPINCTRL_UPDATED, boost::bind (&DefaultsPage::audio_delay_changed, this));
373
374                 _issuer->SetValue (std_to_wx (config->dcp_metadata().issuer));
375                 _issuer->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DefaultsPage::issuer_changed, this));
376                 _creator->SetValue (std_to_wx (config->dcp_metadata().creator));
377                 _creator->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&DefaultsPage::creator_changed, this));
378
379                 return panel;
380         }
381
382 private:
383         void j2k_bandwidth_changed ()
384         {
385                 Config::instance()->set_default_j2k_bandwidth (_j2k_bandwidth->GetValue() * 1000000);
386         }
387         
388         void audio_delay_changed ()
389         {
390                 Config::instance()->set_default_audio_delay (_audio_delay->GetValue());
391         }
392
393         void directory_changed ()
394         {
395                 Config::instance()->set_default_directory (wx_to_std (_directory->GetPath ()));
396         }
397
398         void edit_dci_metadata_clicked (wxWindow* parent)
399         {
400                 DCIMetadataDialog* d = new DCIMetadataDialog (parent, Config::instance()->default_dci_metadata ());
401                 d->ShowModal ();
402                 Config::instance()->set_default_dci_metadata (d->dci_metadata ());
403                 d->Destroy ();
404         }
405
406         void still_length_changed ()
407         {
408                 Config::instance()->set_default_still_length (_still_length->GetValue ());
409         }
410         
411         void container_changed ()
412         {
413                 vector<Ratio const *> ratio = Ratio::all ();
414                 Config::instance()->set_default_container (ratio[_container->GetSelection()]);
415         }
416         
417         void dcp_content_type_changed ()
418         {
419                 vector<DCPContentType const *> ct = DCPContentType::all ();
420                 Config::instance()->set_default_dcp_content_type (ct[_dcp_content_type->GetSelection()]);
421         }
422
423         void issuer_changed ()
424         {
425                 libdcp::XMLMetadata m = Config::instance()->dcp_metadata ();
426                 m.issuer = wx_to_std (_issuer->GetValue ());
427                 Config::instance()->set_dcp_metadata (m);
428         }
429         
430         void creator_changed ()
431         {
432                 libdcp::XMLMetadata m = Config::instance()->dcp_metadata ();
433                 m.creator = wx_to_std (_creator->GetValue ());
434                 Config::instance()->set_dcp_metadata (m);
435         }
436         
437         wxSpinCtrl* _j2k_bandwidth;
438         wxSpinCtrl* _audio_delay;
439         wxButton* _dci_metadata_button;
440         wxSpinCtrl* _still_length;
441 #ifdef DCPOMATIC_USE_OWN_DIR_PICKER
442         DirPickerCtrl* _directory;
443 #else
444         wxDirPickerCtrl* _directory;
445 #endif
446         wxChoice* _container;
447         wxChoice* _dcp_content_type;
448         wxTextCtrl* _issuer;
449         wxTextCtrl* _creator;
450 };
451
452 class EncodingServersPage : public wxPreferencesPage
453 {
454 public:
455         wxString GetName () const
456         {
457                 return _("Servers");
458         }
459
460 #ifdef DCPOMATIC_OSX    
461         wxBitmap GetLargeIcon () const
462         {
463                 return wxBitmap ("servers", wxBITMAP_TYPE_PNG_RESOURCE);
464         }
465 #endif  
466
467         wxWindow* CreateWindow (wxWindow* parent)
468         {
469                 wxPanel* panel = new wxPanel (parent);
470                 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
471                 panel->SetSizer (s);
472                 
473                 _use_any_servers = new wxCheckBox (panel, wxID_ANY, _("Use all servers"));
474                 s->Add (_use_any_servers, 0, wxALL, DCPOMATIC_SIZER_X_GAP);
475                 
476                 vector<string> columns;
477                 columns.push_back (wx_to_std (_("IP address / host name")));
478                 _servers_list = new EditableList<string, ServerDialog> (
479                         panel,
480                         columns,
481                         boost::bind (&Config::servers, Config::instance()),
482                         boost::bind (&Config::set_servers, Config::instance(), _1),
483                         boost::bind (&EncodingServersPage::server_column, this, _1)
484                         );
485                 
486                 s->Add (_servers_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP);
487                 
488                 _use_any_servers->SetValue (Config::instance()->use_any_servers ());
489                 _use_any_servers->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&EncodingServersPage::use_any_servers_changed, this));
490
491                 return panel;
492         }
493
494 private:        
495
496         void use_any_servers_changed ()
497         {
498                 Config::instance()->set_use_any_servers (_use_any_servers->GetValue ());
499         }
500
501         string server_column (string s)
502         {
503                 return s;
504         }
505
506         wxCheckBox* _use_any_servers;
507         EditableList<string, ServerDialog>* _servers_list;
508 };
509
510 class ColourConversionsPage : public wxPreferencesPage
511 {
512         wxString GetName () const
513         {
514                 return _("Colour Conversions");
515         }
516
517 #ifdef DCPOMATIC_OSX    
518         wxBitmap GetLargeIcon () const
519         {
520                 return wxBitmap ("colour_conversions", wxBITMAP_TYPE_PNG_RESOURCE);
521         }
522 #endif  
523         wxWindow* CreateWindow (wxWindow* parent)
524         {
525                 vector<string> columns;
526                 columns.push_back (wx_to_std (_("Name")));
527                 return new EditableList<PresetColourConversion, PresetColourConversionDialog> (
528                         parent,
529                         columns,
530                         boost::bind (&Config::colour_conversions, Config::instance()),
531                         boost::bind (&Config::set_colour_conversions, Config::instance(), _1),
532                         boost::bind (&ColourConversionsPage::colour_conversion_column, this, _1),
533                         300
534                         );
535         }
536
537 private:
538         string colour_conversion_column (PresetColourConversion c)
539         {
540                 return c.name;
541         }
542 };
543
544 class TMSPage : public wxPreferencesPage
545 {
546         wxString GetName () const
547         {
548                 return _("TMS");
549         }
550
551 #ifdef DCPOMATIC_OSX    
552         wxBitmap GetLargeIcon () const
553         {
554                 return wxBitmap ("tms", wxBITMAP_TYPE_PNG_RESOURCE);
555         }
556 #endif  
557
558         wxWindow* CreateWindow (wxWindow* parent)
559         {
560                 wxPanel* panel = new wxPanel (parent);
561                 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
562                 panel->SetSizer (s);
563
564                 wxFlexGridSizer* table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP);
565                 table->AddGrowableCol (1, 1);
566                 s->Add (table, 1, wxALL | wxEXPAND, 8);
567                 
568                 add_label_to_sizer (table, panel, _("IP address"), true);
569                 _tms_ip = new wxTextCtrl (panel, wxID_ANY);
570                 table->Add (_tms_ip, 1, wxEXPAND);
571                 
572                 add_label_to_sizer (table, panel, _("Target path"), true);
573                 _tms_path = new wxTextCtrl (panel, wxID_ANY);
574                 table->Add (_tms_path, 1, wxEXPAND);
575                 
576                 add_label_to_sizer (table, panel, _("User name"), true);
577                 _tms_user = new wxTextCtrl (panel, wxID_ANY);
578                 table->Add (_tms_user, 1, wxEXPAND);
579                 
580                 add_label_to_sizer (table, panel, _("Password"), true);
581                 _tms_password = new wxTextCtrl (panel, wxID_ANY);
582                 table->Add (_tms_password, 1, wxEXPAND);
583                 
584                 Config* config = Config::instance ();
585                 
586                 _tms_ip->SetValue (std_to_wx (config->tms_ip ()));
587                 _tms_ip->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TMSPage::tms_ip_changed, this));
588                 _tms_path->SetValue (std_to_wx (config->tms_path ()));
589                 _tms_path->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TMSPage::tms_path_changed, this));
590                 _tms_user->SetValue (std_to_wx (config->tms_user ()));
591                 _tms_user->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TMSPage::tms_user_changed, this));
592                 _tms_password->SetValue (std_to_wx (config->tms_password ()));
593                 _tms_password->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TMSPage::tms_password_changed, this));
594
595                 return panel;
596         }
597
598 private:
599         void tms_ip_changed ()
600         {
601                 Config::instance()->set_tms_ip (wx_to_std (_tms_ip->GetValue ()));
602         }
603         
604         void tms_path_changed ()
605         {
606                 Config::instance()->set_tms_path (wx_to_std (_tms_path->GetValue ()));
607         }
608         
609         void tms_user_changed ()
610         {
611                 Config::instance()->set_tms_user (wx_to_std (_tms_user->GetValue ()));
612         }
613         
614         void tms_password_changed ()
615         {
616                 Config::instance()->set_tms_password (wx_to_std (_tms_password->GetValue ()));
617         }
618
619         wxTextCtrl* _tms_ip;
620         wxTextCtrl* _tms_path;
621         wxTextCtrl* _tms_user;
622         wxTextCtrl* _tms_password;
623 };
624
625 class KDMEmailPage : public wxPreferencesPage
626 {
627 public:
628         wxString GetName () const
629         {
630                 return _("KDM Email");
631         }
632
633 #ifdef DCPOMATIC_OSX    
634         wxBitmap GetLargeIcon () const
635         {
636                 return wxBitmap ("blank", wxBITMAP_TYPE_PNG_RESOURCE);
637         }
638 #endif  
639
640         wxWindow* CreateWindow (wxWindow* parent)
641         {
642                 wxPanel* panel = new wxPanel (parent);
643                 wxBoxSizer* s = new wxBoxSizer (wxVERTICAL);
644                 panel->SetSizer (s);
645                 
646                 _kdm_email = new wxTextCtrl (panel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE);
647                 s->Add (_kdm_email, 1, wxEXPAND | wxALL, 12);
648                 
649                 _kdm_email->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&KDMEmailPage::kdm_email_changed, this));
650                 _kdm_email->SetValue (wx_to_std (Config::instance()->kdm_email ()));
651
652                 return panel;
653         }
654
655 private:        
656         void kdm_email_changed ()
657         {
658                 Config::instance()->set_kdm_email (wx_to_std (_kdm_email->GetValue ()));
659         }
660
661         wxTextCtrl* _kdm_email;
662 };
663
664 wxPreferencesEditor*
665 create_config_dialog ()
666 {
667         wxPreferencesEditor* e = new wxPreferencesEditor ();
668         e->AddPage (new GeneralPage);
669         e->AddPage (new DefaultsPage);
670         e->AddPage (new EncodingServersPage);
671         e->AddPage (new ColourConversionsPage);
672         e->AddPage (new TMSPage);
673         e->AddPage (new KDMEmailPage);
674         return e;
675 }