2 Copyright (C) 2017-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_signal_manager.h"
22 #include "wx/wx_util.h"
23 #include "wx/about_dialog.h"
24 #include "wx/report_problem_dialog.h"
25 #include "wx/film_viewer.h"
26 #include "wx/player_information.h"
27 #include "wx/update_dialog.h"
28 #include "wx/player_config_dialog.h"
29 #include "wx/verify_dcp_dialog.h"
30 #include "wx/controls.h"
31 #include "wx/cinema_player_dialog.h"
32 #include "lib/cross.h"
33 #include "lib/config.h"
35 #include "lib/update_checker.h"
36 #include "lib/compose.hpp"
37 #include "lib/dcp_content.h"
38 #include "lib/job_manager.h"
41 #include "lib/video_content.h"
42 #include "lib/text_content.h"
43 #include "lib/ratio.h"
44 #include "lib/verify_dcp_job.h"
45 #include "lib/dcp_examiner.h"
46 #include "lib/examine_content_job.h"
47 #include "lib/server.h"
48 #include "lib/dcpomatic_socket.h"
50 #include <wx/stdpaths.h>
51 #include <wx/splash.h>
52 #include <wx/cmdline.h>
53 #include <wx/preferences.h>
54 #include <wx/progdlg.h>
55 #include <wx/display.h>
57 #include <ApplicationServices/ApplicationServices.h>
59 #include <boost/bind.hpp>
73 using boost::shared_ptr;
74 using boost::scoped_array;
75 using boost::optional;
76 using boost::dynamic_pointer_cast;
85 /* Allow spare IDs after _history for the recent files list */
88 /* Allow spare IDs for CPLs */
89 ID_view_full_screen = 200,
91 ID_view_closed_captions,
92 ID_view_scale_appropriate,
95 ID_view_scale_quarter,
96 ID_help_report_a_problem,
98 ID_tools_check_for_updates,
99 /* IDs for shortcuts (with no associated menu item) */
105 class DOMFrame : public wxFrame
109 : wxFrame (0, -1, _("DCP-o-matic Player"))
110 , _update_news_requested (false)
112 , _mode (Config::instance()->player_mode())
117 , _history_position (0)
118 , _history_separator (0)
121 #if defined(DCPOMATIC_WINDOWS)
122 maybe_open_console ();
123 cout << "DCP-o-matic Player is starting." << "\n";
126 wxMenuBar* bar = new wxMenuBar;
128 set_menu_sensitivity ();
131 #ifdef DCPOMATIC_WINDOWS
132 SetIcon (wxIcon (std_to_wx ("id")));
135 _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this));
138 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this), ID_file_open);
139 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_ov, this), ID_file_add_ov);
140 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_kdm, this), ID_file_add_kdm);
141 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE);
142 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_close, this), ID_file_close);
143 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
144 Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
145 Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_full_screen, this), ID_view_full_screen);
146 Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_dual_screen, this), ID_view_dual_screen);
147 Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_closed_captions, this), ID_view_closed_captions);
148 Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_cpl, this, _1), ID_view_cpl, ID_view_cpl + MAX_CPLS);
149 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(0)), ID_view_scale_full);
150 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(1)), ID_view_scale_half);
151 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(2)), ID_view_scale_quarter);
152 Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT);
153 Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_report_a_problem, this), ID_help_report_a_problem);
154 Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_verify, this), ID_tools_verify);
155 Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_check_for_updates, this), ID_tools_check_for_updates);
157 /* Use a panel as the only child of the Frame so that we avoid
158 the dark-grey background on Windows.
160 _overall_panel = new wxPanel (this, wxID_ANY);
162 _viewer.reset (new FilmViewer (_overall_panel));
163 _controls = new Controls (_overall_panel, _viewer);
164 _viewer->set_dcp_decode_reduction (Config::instance()->decode_reduction ());
165 _info = new PlayerInformation (_overall_panel, _viewer);
166 wxSizer* main_sizer = new wxBoxSizer (wxVERTICAL);
167 main_sizer->Add (_viewer->panel(), 1, wxEXPAND);
168 main_sizer->Add (_controls, 0, wxEXPAND | wxALL, 6);
169 main_sizer->Add (_info, 0, wxEXPAND | wxALL, 6);
170 _overall_panel->SetSizer (main_sizer);
173 int accelerators = 4;
175 int accelerators = 3;
178 wxAcceleratorEntry* accel = new wxAcceleratorEntry[accelerators];
179 accel[0].Set(wxACCEL_NORMAL, WXK_SPACE, ID_start_stop);
180 accel[1].Set(wxACCEL_NORMAL, WXK_LEFT, ID_back_frame);
181 accel[2].Set(wxACCEL_NORMAL, WXK_RIGHT, ID_forward_frame);
183 accel[3].Set(wxACCEL_CTRL, static_cast<int>('W'), ID_file_close);
185 wxAcceleratorTable accel_table (accelerators, accel);
186 SetAcceleratorTable (accel_table);
189 Bind (wxEVT_MENU, boost::bind (&DOMFrame::start_stop_pressed, this), ID_start_stop);
190 Bind (wxEVT_MENU, boost::bind (&DOMFrame::back_frame, this), ID_back_frame);
191 Bind (wxEVT_MENU, boost::bind (&DOMFrame::forward_frame, this), ID_forward_frame);
193 _cinema_dialog = new CinemaPlayerDialog (this, _viewer);
195 UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
200 void set_decode_reduction (optional<int> reduction)
202 _viewer->set_dcp_decode_reduction (reduction);
203 _info->triggered_update ();
204 Config::instance()->set_decode_reduction (reduction);
207 void load_dcp (boost::filesystem::path dir)
209 _film.reset (new Film (optional<boost::filesystem::path>()));
210 shared_ptr<DCPContent> dcp;
212 dcp.reset (new DCPContent (_film, dir));
213 } catch (boost::filesystem::filesystem_error& e) {
214 error_dialog (this, _("Could not load DCP"), std_to_wx (e.what()));
218 _film->examine_and_add_content (dcp, true);
219 bool const ok = progress (_("Loading DCP"));
220 if (!ok || !report_errors_from_last_job()) {
224 setup_from_dcp (dcp);
226 if (dcp->three_d()) {
227 _film->set_three_d (true);
230 _viewer->set_film (_film);
231 _viewer->seek (DCPTime(), true);
232 _info->triggered_update ();
234 Config::instance()->add_to_player_history (dir);
236 set_menu_sensitivity ();
238 wxMenuItemList old = _cpl_menu->GetMenuItems();
239 for (wxMenuItemList::iterator i = old.begin(); i != old.end(); ++i) {
240 _cpl_menu->Remove (*i);
243 DCPExaminer ex (dcp);
244 int id = ID_view_cpl;
245 BOOST_FOREACH (shared_ptr<dcp::CPL> i, ex.cpls()) {
246 wxMenuItem* j = _cpl_menu->AppendRadioItem(
248 wxString::Format("%s (%s)", std_to_wx(i->annotation_text()).data(), std_to_wx(i->id()).data())
250 j->Check(!dcp->cpl() || i->id() == *dcp->cpl());
257 void setup_menu (wxMenuBar* m)
259 _file_menu = new wxMenu;
260 _file_menu->Append (ID_file_open, _("&Open...\tCtrl-O"));
261 _file_add_ov = _file_menu->Append (ID_file_add_ov, _("&Add OV..."));
262 _file_add_kdm = _file_menu->Append (ID_file_add_kdm, _("&Add KDM..."));
264 _history_position = _file_menu->GetMenuItems().GetCount();
266 _file_menu->AppendSeparator ();
267 _file_menu->Append (ID_file_close, _("&Close"));
268 _file_menu->AppendSeparator ();
271 _file_menu->Append (wxID_EXIT, _("&Exit"));
273 _file_menu->Append (wxID_EXIT, _("&Quit"));
277 _file_menu->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
279 wxMenu* edit = new wxMenu;
280 edit->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
283 _cpl_menu = new wxMenu;
285 wxMenu* view = new wxMenu;
286 optional<int> c = Config::instance()->decode_reduction();
287 _view_cpl = view->Append(ID_view_cpl, _("CPL"), _cpl_menu);
288 view->AppendCheckItem(ID_view_full_screen, _("Full screen\tF11"))->Check(_mode == Config::PLAYER_MODE_FULL);
289 view->AppendCheckItem(ID_view_dual_screen, _("Dual screen\tShift+F11"))->Check(_mode == Config::PLAYER_MODE_DUAL);
290 view->Append(ID_view_closed_captions, _("Closed captions..."));
291 view->AppendSeparator();
292 view->AppendRadioItem(ID_view_scale_appropriate, _("Set decode resolution to match display"))->Check(!static_cast<bool>(c));
293 view->AppendRadioItem(ID_view_scale_full, _("Decode at full resolution"))->Check(c && c.get() == 0);
294 view->AppendRadioItem(ID_view_scale_half, _("Decode at half resolution"))->Check(c && c.get() == 1);
295 view->AppendRadioItem(ID_view_scale_quarter, _("Decode at quarter resolution"))->Check(c && c.get() == 2);
297 wxMenu* tools = new wxMenu;
298 _tools_verify = tools->Append (ID_tools_verify, _("Verify DCP"));
299 tools->AppendSeparator ();
300 tools->Append (ID_tools_check_for_updates, _("Check for updates"));
302 wxMenu* help = new wxMenu;
304 help->Append (wxID_ABOUT, _("About DCP-o-matic"));
306 help->Append (wxID_ABOUT, _("About"));
308 help->Append (ID_help_report_a_problem, _("Report a problem..."));
310 m->Append (_file_menu, _("&File"));
312 m->Append (edit, _("&Edit"));
314 m->Append (view, _("&View"));
315 m->Append (tools, _("&Tools"));
316 m->Append (help, _("&Help"));
321 wxString d = wxStandardPaths::Get().GetDocumentsDir();
322 if (Config::instance()->last_player_load_directory()) {
323 d = std_to_wx (Config::instance()->last_player_load_directory()->string());
326 wxDirDialog* c = new wxDirDialog (this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
331 if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
332 error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
339 boost::filesystem::path const dcp (wx_to_std (c->GetPath ()));
341 Config::instance()->set_last_player_load_directory (dcp.parent_path());
349 wxDirDialog* c = new wxDirDialog (
351 _("Select DCP to open as OV"),
352 wxStandardPaths::Get().GetDocumentsDir(),
353 wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
359 if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
360 error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
367 DCPOMATIC_ASSERT (_film);
368 shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
369 DCPOMATIC_ASSERT (dcp);
370 dcp->add_ov (wx_to_std(c->GetPath()));
371 JobManager::instance()->add(shared_ptr<Job>(new ExamineContentJob (_film, dcp)));
372 bool const ok = progress (_("Loading DCP"));
373 if (!ok || !report_errors_from_last_job()) {
376 setup_from_dcp (dcp);
380 _info->triggered_update ();
385 wxFileDialog* d = new wxFileDialog (this, _("Select KDM"));
387 if (d->ShowModal() == wxID_OK) {
388 DCPOMATIC_ASSERT (_film);
389 shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
390 DCPOMATIC_ASSERT (dcp);
392 dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE)));
393 dcp->examine (shared_ptr<Job>());
394 } catch (exception& e) {
395 error_dialog (this, wxString::Format (_("Could not load KDM.")), std_to_wx(e.what()));
402 _info->triggered_update ();
405 void file_history (wxCommandEvent& event)
407 vector<boost::filesystem::path> history = Config::instance()->player_history ();
408 int n = event.GetId() - ID_file_history;
409 if (n >= 0 && n < static_cast<int> (history.size ())) {
410 load_dcp (history[n]);
416 _viewer->set_film (shared_ptr<Film>());
418 _info->triggered_update ();
419 set_menu_sensitivity ();
427 void edit_preferences ()
429 if (!_config_dialog) {
430 _config_dialog = create_player_config_dialog ();
432 _config_dialog->Show (this);
435 void view_cpl (wxCommandEvent& ev)
437 shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
438 DCPOMATIC_ASSERT (dcp);
439 DCPExaminer ex (dcp);
440 int id = ev.GetId() - ID_view_cpl;
441 DCPOMATIC_ASSERT (id >= 0);
442 DCPOMATIC_ASSERT (id < int(ex.cpls().size()));
443 list<shared_ptr<dcp::CPL> > cpls = ex.cpls();
444 list<shared_ptr<dcp::CPL> >::iterator i = cpls.begin();
450 dcp->set_cpl ((*i)->id());
451 dcp->examine (shared_ptr<Job>());
454 void view_full_screen ()
456 if (_mode == Config::PLAYER_MODE_FULL) {
457 _mode = Config::PLAYER_MODE_WINDOW;
459 _mode = Config::PLAYER_MODE_FULL;
464 void view_dual_screen ()
466 if (_mode == Config::PLAYER_MODE_DUAL) {
467 _mode = Config::PLAYER_MODE_WINDOW;
469 _mode = Config::PLAYER_MODE_DUAL;
476 _controls->Show (_mode == Config::PLAYER_MODE_WINDOW);
477 _info->Show (_mode == Config::PLAYER_MODE_WINDOW);
478 _overall_panel->SetBackgroundColour (_mode == Config::PLAYER_MODE_WINDOW ? wxNullColour : wxColour(0, 0, 0));
479 ShowFullScreen (_mode != Config::PLAYER_MODE_WINDOW);
480 if (_mode == Config::PLAYER_MODE_DUAL) {
481 _cinema_dialog->Show ();
482 if (wxDisplay::GetCount() > 1) {
484 _cinema_dialog->Move (wxDisplay(0).GetClientArea().GetWidth(), 0);
489 void view_closed_captions ()
491 _viewer->show_closed_captions ();
496 shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
497 DCPOMATIC_ASSERT (dcp);
499 JobManager* jm = JobManager::instance ();
500 jm->add (shared_ptr<Job> (new VerifyDCPJob (dcp->directories())));
501 bool const ok = progress (_("Verifying DCP"));
506 DCPOMATIC_ASSERT (!jm->get().empty());
507 shared_ptr<VerifyDCPJob> last = dynamic_pointer_cast<VerifyDCPJob> (jm->get().back());
508 DCPOMATIC_ASSERT (last);
510 VerifyDCPDialog* d = new VerifyDCPDialog (this, last);
515 void tools_check_for_updates ()
517 UpdateChecker::instance()->run ();
518 _update_news_requested = true;
523 AboutDialog* d = new AboutDialog (this);
528 void help_report_a_problem ()
530 ReportProblemDialog* d = new ReportProblemDialog (this);
531 if (d->ShowModal () == wxID_OK) {
537 void update_checker_state_changed ()
539 UpdateChecker* uc = UpdateChecker::instance ();
541 bool const announce =
542 _update_news_requested ||
543 (uc->stable() && Config::instance()->check_for_updates()) ||
544 (uc->test() && Config::instance()->check_for_updates() && Config::instance()->check_for_test_updates());
546 _update_news_requested = false;
552 if (uc->state() == UpdateChecker::YES) {
553 UpdateDialog* dialog = new UpdateDialog (this, uc->stable (), uc->test ());
554 dialog->ShowModal ();
556 } else if (uc->state() == UpdateChecker::FAILED) {
557 error_dialog (this, _("The DCP-o-matic download server could not be contacted."));
559 error_dialog (this, _("There are no new versions of DCP-o-matic available."));
562 _update_news_requested = false;
565 void config_changed ()
567 /* Instantly save any config changes when using the player GUI */
569 Config::instance()->write_config();
570 } catch (exception& e) {
574 _("Could not write to config file at %s. Your changes have not been saved."),
575 std_to_wx (Config::instance()->cinemas_file().string()).data()
580 for (int i = 0; i < _history_items; ++i) {
581 delete _file_menu->Remove (ID_file_history + i);
584 if (_history_separator) {
585 _file_menu->Remove (_history_separator);
587 delete _history_separator;
588 _history_separator = 0;
590 int pos = _history_position;
592 vector<boost::filesystem::path> history = Config::instance()->player_history ();
594 if (!history.empty ()) {
595 _history_separator = _file_menu->InsertSeparator (pos++);
598 for (size_t i = 0; i < history.size(); ++i) {
601 s = String::compose ("&%1 %2", i + 1, history[i].string());
603 s = history[i].string();
605 _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s));
608 _history_items = history.size ();
611 void set_menu_sensitivity ()
613 _tools_verify->Enable (static_cast<bool>(_film));
614 _file_add_ov->Enable (static_cast<bool>(_film));
615 _file_add_kdm->Enable (static_cast<bool>(_film));
616 _view_cpl->Enable (static_cast<bool>(_film));
619 void start_stop_pressed ()
621 if (_viewer->playing()) {
630 _viewer->seek_by (-_viewer->one_video_frame(), true);
633 void forward_frame ()
635 _viewer->seek_by (_viewer->one_video_frame(), true);
640 /** @return false if the task was cancelled */
641 bool progress (wxString task)
643 JobManager* jm = JobManager::instance ();
645 wxProgressDialog* progress = new wxProgressDialog (_("DCP-o-matic Player"), task, 100, 0, wxPD_CAN_ABORT);
649 while (jm->work_to_do() || signal_manager->ui_idle()) {
651 if (!progress->Pulse()) {
652 /* user pressed cancel */
653 BOOST_FOREACH (shared_ptr<Job> i, jm->get()) {
661 progress->Destroy ();
665 bool report_errors_from_last_job ()
667 JobManager* jm = JobManager::instance ();
669 DCPOMATIC_ASSERT (!jm->get().empty());
671 shared_ptr<Job> last = jm->get().back();
672 if (last->finished_in_error()) {
673 error_dialog(this, std_to_wx(last->error_summary()) + ".\n", std_to_wx(last->error_details()));
680 void setup_from_dcp (shared_ptr<DCPContent> dcp)
682 BOOST_FOREACH (shared_ptr<TextContent> i, dcp->text) {
687 Ratio const * r = Ratio::nearest_from_ratio(dcp->video->size().ratio());
689 _film->set_container(r);
694 bool _update_news_requested;
695 PlayerInformation* _info;
696 Config::PlayerMode _mode;
697 wxPreferencesEditor* _config_dialog;
698 CinemaPlayerDialog* _cinema_dialog;
699 wxPanel* _overall_panel;
701 wxMenuItem* _view_cpl;
704 int _history_position;
705 wxMenuItem* _history_separator;
706 shared_ptr<FilmViewer> _viewer;
708 boost::shared_ptr<Film> _film;
709 boost::signals2::scoped_connection _config_changed_connection;
710 wxMenuItem* _file_add_ov;
711 wxMenuItem* _file_add_kdm;
712 wxMenuItem* _tools_verify;
715 static const wxCmdLineEntryDesc command_line_description[] = {
716 { wxCMD_LINE_PARAM, 0, 0, "DCP to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
717 { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
720 class PlayServer : public Server
723 explicit PlayServer (DOMFrame* frame)
724 : Server (PLAYER_PLAY_PORT)
728 void handle (shared_ptr<Socket> socket)
731 int const length = socket->read_uint32 ();
732 scoped_array<char> buffer (new char[length]);
733 socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
734 string s (buffer.get());
735 signal_manager->when_idle (bind (&DOMFrame::load_dcp, _frame, s));
736 socket->write (reinterpret_cast<uint8_t const *> ("OK"), 3);
747 * @brief The magic App class for wxWidgets.
749 class App : public wxApp
762 wxInitAllImageHandlers ();
764 Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
765 Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
767 wxSplashScreen* splash = maybe_show_splash ();
769 SetAppName (_("DCP-o-matic Player"));
771 if (!wxApp::OnInit()) {
775 #ifdef DCPOMATIC_LINUX
776 unsetenv ("UBUNTU_MENUPROXY");
780 ProcessSerialNumber serial;
781 GetCurrentProcess (&serial);
782 TransformProcessType (&serial, kProcessTransformToForegroundApplication);
785 dcpomatic_setup_path_encoding ();
787 /* Enable i18n; this will create a Config object
788 to look for a force-configured language. This Config
789 object will be wrong, however, because dcpomatic_setup
790 hasn't yet been called and there aren't any filters etc.
793 dcpomatic_setup_i18n ();
795 /* Set things up, including filters etc.
796 which will now be internationalised correctly.
800 /* Force the configuration to be re-loaded correctly next
805 _frame = new DOMFrame ();
806 SetTopWindow (_frame);
813 signal_manager = new wxSignalManager (this);
815 PlayServer* server = new PlayServer (_frame);
816 new thread (boost::bind (&PlayServer::run, server));
818 if (!_dcp_to_load.empty() && boost::filesystem::is_directory (_dcp_to_load)) {
820 _frame->load_dcp (_dcp_to_load);
821 } catch (exception& e) {
822 error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load DCP %1.")), _dcp_to_load)), std_to_wx(e.what()));
826 Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
828 if (Config::instance()->check_for_updates ()) {
829 UpdateChecker::instance()->run ();
836 error_dialog (0, _("DCP-o-matic Player could not start."), std_to_wx(e.what()));
840 void OnInitCmdLine (wxCmdLineParser& parser)
842 parser.SetDesc (command_line_description);
843 parser.SetSwitchChars (wxT ("-"));
846 bool OnCmdLineParsed (wxCmdLineParser& parser)
848 if (parser.GetParamCount() > 0) {
849 _dcp_to_load = wx_to_std (parser.GetParam (0));
855 void report_exception ()
859 } catch (FileError& e) {
863 _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM,
864 std_to_wx (e.what()),
865 std_to_wx (e.file().string().c_str ())
868 } catch (exception& e) {
872 _("An exception occurred: %s.\n\n") + REPORT_PROBLEM,
873 std_to_wx (e.what ())
877 error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
881 /* An unhandled exception has occurred inside the main event loop */
882 bool OnExceptionInMainLoop ()
885 /* This will terminate the program */
889 void OnUnhandledException ()
896 signal_manager->ui_idle ();
899 void config_failed_to_load ()
901 message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create."));
904 void config_warning (string m)
906 message_dialog (_frame, std_to_wx (m));