Change bitmap_path to take a full name with extension.
[dcpomatic.git] / src / wx / config_dialog.h
index ec345750ab0c4ffd537131c37a3bbdf74fa8521f..c767929f75f76fc9558bade2ca846b890e3e3620 100644 (file)
 /*
-    Copyright (C) 2012 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
-    This program is free software; you can redistribute it and/or modify
+    This file is part of DCP-o-matic.
+
+    DCP-o-matic is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
     the Free Software Foundation; either version 2 of the License, or
     (at your option) any later version.
 
-    This program is distributed in the hope that it will be useful,
+    DCP-o-matic is distributed in the hope that it will be useful,
     but WITHOUT ANY WARRANTY; without even the implied warranty of
     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     GNU General Public License for more details.
 
     You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+    along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
 
 */
 
-/** @file src/config_dialog.h
- *  @brief A dialogue to edit DVD-o-matic configuration.
- */
 
-#include <gtkmm.h>
+#ifndef DCPOMATIC_CONFIG_DIALOG_H
+#define DCPOMATIC_CONFIG_DIALOG_H
+
+
+#include "editable_list.h"
+#include "make_chain_dialog.h"
+#include "wx_util.h"
+#include "lib/config.h"
+#include "lib/cross.h"
+#include "lib/dcp_content_type.h"
+#include "lib/exceptions.h"
+#include "lib/filter.h"
+#include "lib/log.h"
+#include "lib/ratio.h"
+#include "lib/util.h"
+#include <dcp/certificate_chain.h>
+#include <dcp/exceptions.h>
+#include <dcp/locale_convert.h>
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
+#include <wx/filepicker.h>
+#include <wx/preferences.h>
+#include <wx/spinctrl.h>
+#include <wx/stdpaths.h>
+#include <RtAudio.h>
+LIBDCP_ENABLE_WARNINGS
+#include <boost/filesystem.hpp>
+
+
+class AudioMappingView;
+
+
+class Page : public wxPreferencesPage
+{
+public:
+       Page (wxSize panel_size, int border);
+       virtual ~Page () {}
+
+       wxWindow* CreateWindow (wxWindow* parent) override;
+
+protected:
+       wxWindow* create_window (wxWindow* parent);
+
+       int _border;
+       wxPanel* _panel;
+
+private:
+       virtual void config_changed () = 0;
+       virtual void setup () = 0;
+
+       void config_changed_wrapper ();
+       void window_destroyed ();
+
+       wxSize _panel_size;
+       boost::signals2::scoped_connection _config_connection;
+       bool _window_exists;
+};
+
+
+class GeneralPage : public Page
+{
+public:
+       GeneralPage (wxSize panel_size, int border);
+
+       wxString GetName () const override;
+
+#ifdef DCPOMATIC_OSX
+       wxBitmap GetLargeIcon () const override
+       {
+               return wxBitmap(bitmap_path("general.png"), wxBITMAP_TYPE_PNG);
+       }
+#endif
+
+protected:
+       void add_language_controls (wxGridBagSizer* table, int& r);
+       void add_update_controls (wxGridBagSizer* table, int& r);
+       void config_changed () override;
+
+private:
+       void setup_sensitivity ();
+       void set_language_changed ();
+       void language_changed ();
+       void check_for_updates_changed ();
+       void check_for_test_updates_changed ();
+
+       wxCheckBox* _set_language;
+       wxChoice* _language;
+       wxCheckBox* _check_for_updates;
+       wxCheckBox* _check_for_test_updates;
+};
 
-class Screen;
-class Server;
 
-/** @class ConfigDialog
- *  @brief A dialogue to edit DVD-o-matic configuration.
- */
-class ConfigDialog : public Gtk::Dialog
+class CertificateChainEditor : public wxDialog
 {
 public:
-       ConfigDialog ();
+       CertificateChainEditor (
+               wxWindow* parent,
+               wxString title,
+               int border,
+               std::function<void (std::shared_ptr<dcp::CertificateChain>)> set,
+               std::function<std::shared_ptr<const dcp::CertificateChain> (void)> get,
+               std::function<bool (void)> nag_alter
+               );
+
+       void add_button (wxWindow* button);
 
 private:
-       void on_response (int);
-
-       void tms_ip_changed ();
-       void tms_path_changed ();
-       void tms_user_changed ();
-       void tms_password_changed ();
-       void num_local_encoding_threads_changed ();
-       void colour_lut_changed ();
-       void j2k_bandwidth_changed ();
-       void add_server_clicked ();
-       void remove_server_clicked ();
-       void server_selection_changed ();
-       void add_screen_clicked ();
-       void remove_screen_clicked ();
-       void screen_selection_changed ();
-       void reference_scaler_changed ();
-       void edit_reference_filters_clicked ();
-       void reference_filters_changed (std::vector<Filter const *>);
-
-       void add_screen_to_store (boost::shared_ptr<Screen>);
-       void add_server_to_store (Server *);
-
-       struct ServersModelColumns : public Gtk::TreeModelColumnRecord
+       void add_certificate ();
+       void remove_certificate ();
+       void export_certificate ();
+       void update_certificate_list ();
+       void remake_certificates ();
+       void update_sensitivity ();
+       void update_private_key ();
+       void import_private_key ();
+       void export_private_key ();
+       void export_chain ();
+
+       wxListCtrl* _certificates;
+       wxButton* _add_certificate;
+       wxButton* _export_certificate;
+       wxButton* _remove_certificate;
+       wxButton* _remake_certificates;
+       wxStaticText* _private_key;
+       wxButton* _import_private_key;
+       wxButton* _export_private_key;
+       wxButton* _export_chain;
+       wxStaticText* _private_key_bad;
+       wxSizer* _sizer;
+       wxBoxSizer* _button_sizer;
+       std::function<void (std::shared_ptr<dcp::CertificateChain>)> _set;
+       std::function<std::shared_ptr<const dcp::CertificateChain> (void)> _get;
+       std::function<bool (void)> _nag_alter;
+};
+
+class KeysPage : public Page
+{
+public:
+       KeysPage (wxSize panel_size, int border)
+               : Page (panel_size, border)
+       {}
+
+       wxString GetName () const override;
+
+#ifdef DCPOMATIC_OSX
+       wxBitmap GetLargeIcon () const override
        {
-               ServersModelColumns () {
-                       add (_host_name);
-                       add (_threads);
-               }
+               return wxBitmap(bitmap_path("keys.png"), wxBITMAP_TYPE_PNG);
+       }
+#endif
+
+private:
+
+       void setup () override;
+
+       void export_decryption_certificate ();
+       void config_changed () override {}
+       bool nag_alter_decryption_chain ();
+       void decryption_advanced ();
+       void signing_advanced ();
+       void export_decryption_chain_and_key ();
+       void import_decryption_chain_and_key ();
+       void remake_signing ();
+};
+
+
+class SoundPage : public Page
+{
+public:
+       SoundPage (wxSize panel_size, int border)
+               : Page (panel_size, border)
+       {}
 
-               Gtk::TreeModelColumn<std::string> _host_name;
-               Gtk::TreeModelColumn<int> _threads;
-       };
+       wxString GetName() const override;
 
-       struct ScreensModelColumns : public Gtk::TreeModelColumnRecord
+#ifdef DCPOMATIC_OSX
+       wxBitmap GetLargeIcon () const override
        {
-               ScreensModelColumns () {
-                       add (_name);
-                       add (_format_name);
-                       add (_format_nickname);
-                       add (_x);
-                       add (_y);
-                       add (_width);
-                       add (_height);
-               }
-
-               Gtk::TreeModelColumn<std::string> _name;
-               Gtk::TreeModelColumn<std::string> _format_name;
-               Gtk::TreeModelColumn<std::string> _format_nickname;
-               Gtk::TreeModelColumn<std::string> _x;
-               Gtk::TreeModelColumn<std::string> _y;
-               Gtk::TreeModelColumn<std::string> _width;
-               Gtk::TreeModelColumn<std::string> _height;
-       };
-
-       Gtk::Entry _tms_ip;
-       Gtk::Entry _tms_path;
-       Gtk::Entry _tms_user;
-       Gtk::Entry _tms_password;
-       Gtk::SpinButton _num_local_encoding_threads;
-       Gtk::ComboBoxText _colour_lut;
-       Gtk::SpinButton _j2k_bandwidth;
-       Gtk::ComboBoxText _reference_scaler;
-       Gtk::Label _reference_filters;
-       Gtk::Button _reference_filters_button;
-       ServersModelColumns _servers_columns;
-       Glib::RefPtr<Gtk::ListStore> _servers_store;
-       Gtk::TreeView _servers_view;
-       Gtk::Button _add_server;
-       Gtk::Button _remove_server;
-       ScreensModelColumns _screens_columns;
-       Glib::RefPtr<Gtk::TreeStore> _screens_store;
-       Gtk::TreeView _screens_view;
-       Gtk::Button _add_screen;
-       Gtk::Button _remove_screen;
+               return wxBitmap(bitmap_path("sound.png"), wxBITMAP_TYPE_PNG);
+       }
+#endif
+
+private:
+
+       void setup () override;
+       void config_changed () override;
+        boost::optional<std::string> get_sound_output ();
+       void sound_changed ();
+       void sound_output_changed ();
+       void setup_sensitivity ();
+       void map_changed (AudioMapping m);
+       void reset_to_default ();
+
+       wxCheckBox* _sound;
+       wxChoice* _sound_output;
+       wxStaticText* _sound_output_details;
+       AudioMappingView* _map;
+       Button* _reset_to_default;
+};
+
+
+class LocationsPage : public Page
+{
+public:
+       LocationsPage (wxSize panel_size, int border);
+
+       wxString GetName () const override;
+
+#ifdef DCPOMATIC_OSX
+       wxBitmap GetLargeIcon () const override;
+#endif
+
+private:
+       void setup () override;
+       void config_changed () override;
+       void content_directory_changed ();
+       void playlist_directory_changed ();
+       void kdm_directory_changed ();
+
+       wxDirPickerCtrl* _content_directory;
+       wxDirPickerCtrl* _playlist_directory;
+       wxDirPickerCtrl* _kdm_directory;
 };
 
+#endif