2 Copyright (C) 2018 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 #include "../wx/wx_util.h"
22 #include "../wx/wx_signal_manager.h"
23 #include "../lib/util.h"
24 #include "../lib/config.h"
26 #include <wx/listctrl.h>
27 #include <wx/imaglist.h>
31 class DOMFrame : public wxFrame
34 explicit DOMFrame (wxString const & title)
35 : wxFrame (0, -1, title)
37 /* Use a panel as the only child of the Frame so that we avoid
38 the dark-grey background on Windows.
40 wxPanel* overall_panel = new wxPanel (this, wxID_ANY);
41 wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
43 _list = new wxListCtrl (
44 overall_panel, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT | wxLC_SINGLE_SEL
47 _list->AppendColumn (_("Name"), wxLIST_FORMAT_LEFT, 400);
48 _list->AppendColumn (_("CPL"), wxLIST_FORMAT_LEFT, 400);
49 _list->AppendColumn (_("Type"), wxLIST_FORMAT_LEFT, 75);
50 _list->AppendColumn (_("Format"), wxLIST_FORMAT_LEFT, 75);
51 _list->AppendColumn (_("Encrypted"), wxLIST_FORMAT_LEFT, 90);
52 _list->AppendColumn (_("Skippable"), wxLIST_FORMAT_LEFT, 90);
53 _list->AppendColumn (_("Disable timeline"), wxLIST_FORMAT_LEFT, 125);
54 _list->AppendColumn (_("Stop after play"), wxLIST_FORMAT_LEFT, 125);
57 wxImageList* images = new wxImageList (16, 16);
59 icon.LoadFile ("test.png", wxBITMAP_TYPE_PNG);
61 _list->SetImageList (images, wxIMAGE_LIST_SMALL);
67 _list->InsertItem (item);
69 main_sizer->Add (_list, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_GAP);
71 wxBoxSizer* button_sizer = new wxBoxSizer (wxVERTICAL);
72 _up = new wxButton (overall_panel, wxID_ANY, _("Up"));
73 button_sizer->Add (_up, 0, wxALL, DCPOMATIC_SIZER_GAP);
75 main_sizer->Add (button_sizer, 0, wxALL, DCPOMATIC_SIZER_GAP);
76 overall_panel->SetSizer (main_sizer);
81 void setup_sensitivity ()
91 * @brief The magic App class for wxWidgets.
93 class App : public wxApp
106 SetAppName (_("DCP-o-matic KDM Creator"));
108 if (!wxApp::OnInit()) {
112 #ifdef DCPOMATIC_LINUX
113 unsetenv ("UBUNTU_MENUPROXY");
117 ProcessSerialNumber serial;
118 GetCurrentProcess (&serial);
119 TransformProcessType (&serial, kProcessTransformToForegroundApplication);
122 dcpomatic_setup_path_encoding ();
124 /* Enable i18n; this will create a Config object
125 to look for a force-configured language. This Config
126 object will be wrong, however, because dcpomatic_setup
127 hasn't yet been called and there aren't any filters etc.
130 dcpomatic_setup_i18n ();
132 /* Set things up, including filters etc.
133 which will now be internationalised correctly.
137 /* Force the configuration to be re-loaded correctly next
142 _frame = new DOMFrame (_("DCP-o-matic KDM Creator"));
143 SetTopWindow (_frame);
147 signal_manager = new wxSignalManager (this);
148 Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
154 error_dialog (0, _("DCP-o-matic could not start"), std_to_wx(e.what()));
158 /* An unhandled exception has occurred inside the main event loop */
159 bool OnExceptionInMainLoop ()
163 } catch (FileError& e) {
167 _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM,
168 std_to_wx (e.what()),
169 std_to_wx (e.file().string().c_str ())
172 } catch (exception& e) {
176 _("An exception occurred: %s.\n\n") + " " + REPORT_PROBLEM,
177 std_to_wx (e.what ())
181 error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
184 /* This will terminate the program */
188 void OnUnhandledException ()
190 error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
195 signal_manager->ui_idle ();