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
115 : wxFrame (0, -1, _("DCP-o-matic Player"))
116 , _update_news_requested (false)
119 , _screen (SCREEN_WINDOW)
123 , _history_position (0)
124 , _history_separator (0)
127 #if defined(DCPOMATIC_WINDOWS)
128 maybe_open_console ();
129 cout << "DCP-o-matic Player is starting." << "\n";
132 wxMenuBar* bar = new wxMenuBar;
134 set_menu_sensitivity ();
137 #ifdef DCPOMATIC_WINDOWS
138 SetIcon (wxIcon (std_to_wx ("id")));
141 _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&DOMFrame::config_changed, this));
144 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_open, this), ID_file_open);
145 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_ov, this), ID_file_add_ov);
146 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_add_kdm, this), ID_file_add_kdm);
147 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE);
148 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_close, this), ID_file_close);
149 Bind (wxEVT_MENU, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT);
150 Bind (wxEVT_MENU, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES);
151 Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_full_screen, this), ID_view_full_screen);
152 Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_dual_screen, this), ID_view_dual_screen);
153 Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_closed_captions, this), ID_view_closed_captions);
154 Bind (wxEVT_MENU, boost::bind (&DOMFrame::view_cpl, this, _1), ID_view_cpl, ID_view_cpl + MAX_CPLS);
155 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(0)), ID_view_scale_full);
156 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(1)), ID_view_scale_half);
157 Bind (wxEVT_MENU, boost::bind (&DOMFrame::set_decode_reduction, this, optional<int>(2)), ID_view_scale_quarter);
158 Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_about, this), wxID_ABOUT);
159 Bind (wxEVT_MENU, boost::bind (&DOMFrame::help_report_a_problem, this), ID_help_report_a_problem);
160 Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_verify, this), ID_tools_verify);
161 Bind (wxEVT_MENU, boost::bind (&DOMFrame::tools_check_for_updates, this), ID_tools_check_for_updates);
163 /* Use a panel as the only child of the Frame so that we avoid
164 the dark-grey background on Windows.
166 _overall_panel = new wxPanel (this, wxID_ANY);
168 _viewer.reset (new FilmViewer (_overall_panel));
169 _controls = new Controls (_overall_panel, _viewer);
170 _viewer->set_dcp_decode_reduction (Config::instance()->decode_reduction ());
171 _info = new PlayerInformation (_overall_panel, _viewer);
172 wxSizer* main_sizer = new wxBoxSizer (wxVERTICAL);
173 main_sizer->Add (_viewer->panel(), 1, wxEXPAND);
174 main_sizer->Add (_controls, 0, wxEXPAND | wxALL, 6);
175 main_sizer->Add (_info, 0, wxEXPAND | wxALL, 6);
176 _overall_panel->SetSizer (main_sizer);
179 int accelerators = 4;
181 int accelerators = 3;
184 wxAcceleratorEntry* accel = new wxAcceleratorEntry[accelerators];
185 accel[0].Set(wxACCEL_NORMAL, WXK_SPACE, ID_start_stop);
186 accel[1].Set(wxACCEL_NORMAL, WXK_LEFT, ID_back_frame);
187 accel[2].Set(wxACCEL_NORMAL, WXK_RIGHT, ID_forward_frame);
189 accel[3].Set(wxACCEL_CTRL, static_cast<int>('W'), ID_file_close);
191 wxAcceleratorTable accel_table (accelerators, accel);
192 SetAcceleratorTable (accel_table);
195 Bind (wxEVT_MENU, boost::bind (&DOMFrame::start_stop_pressed, this), ID_start_stop);
196 Bind (wxEVT_MENU, boost::bind (&DOMFrame::back_frame, this), ID_back_frame);
197 Bind (wxEVT_MENU, boost::bind (&DOMFrame::forward_frame, this), ID_forward_frame);
199 _cinema_dialog = new CinemaPlayerDialog (this, _viewer);
201 UpdateChecker::instance()->StateChanged.connect (boost::bind (&DOMFrame::update_checker_state_changed, this));
204 void set_decode_reduction (optional<int> reduction)
206 _viewer->set_dcp_decode_reduction (reduction);
207 _info->triggered_update ();
208 Config::instance()->set_decode_reduction (reduction);
211 void load_dcp (boost::filesystem::path dir)
213 _film.reset (new Film (optional<boost::filesystem::path>()));
214 shared_ptr<DCPContent> dcp;
216 dcp.reset (new DCPContent (_film, dir));
217 } catch (boost::filesystem::filesystem_error& e) {
218 error_dialog (this, _("Could not load DCP"), std_to_wx (e.what()));
222 _film->examine_and_add_content (dcp, true);
223 bool const ok = progress (_("Loading DCP"));
224 if (!ok || !report_errors_from_last_job()) {
228 setup_from_dcp (dcp);
230 if (dcp->three_d()) {
231 _film->set_three_d (true);
234 _viewer->set_film (_film);
235 _viewer->seek (DCPTime(), true);
236 _info->triggered_update ();
238 Config::instance()->add_to_player_history (dir);
240 set_menu_sensitivity ();
242 wxMenuItemList old = _cpl_menu->GetMenuItems();
243 for (wxMenuItemList::iterator i = old.begin(); i != old.end(); ++i) {
244 _cpl_menu->Remove (*i);
247 DCPExaminer ex (dcp);
248 int id = ID_view_cpl;
249 BOOST_FOREACH (shared_ptr<dcp::CPL> i, ex.cpls()) {
250 wxMenuItem* j = _cpl_menu->AppendRadioItem(
252 wxString::Format("%s (%s)", std_to_wx(i->annotation_text()).data(), std_to_wx(i->id()).data())
254 j->Check(!dcp->cpl() || i->id() == *dcp->cpl());
261 void setup_menu (wxMenuBar* m)
263 _file_menu = new wxMenu;
264 _file_menu->Append (ID_file_open, _("&Open...\tCtrl-O"));
265 _file_add_ov = _file_menu->Append (ID_file_add_ov, _("&Add OV..."));
266 _file_add_kdm = _file_menu->Append (ID_file_add_kdm, _("&Add KDM..."));
268 _history_position = _file_menu->GetMenuItems().GetCount();
270 _file_menu->AppendSeparator ();
271 _file_menu->Append (ID_file_close, _("&Close"));
272 _file_menu->AppendSeparator ();
275 _file_menu->Append (wxID_EXIT, _("&Exit"));
277 _file_menu->Append (wxID_EXIT, _("&Quit"));
281 _file_menu->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
283 wxMenu* edit = new wxMenu;
284 edit->Append (wxID_PREFERENCES, _("&Preferences...\tCtrl-P"));
287 _cpl_menu = new wxMenu;
289 wxMenu* view = new wxMenu;
290 optional<int> c = Config::instance()->decode_reduction();
291 _view_cpl = view->Append(ID_view_cpl, _("CPL"), _cpl_menu);
292 view->AppendCheckItem(ID_view_full_screen, _("Full screen\tF11"))->Check(_screen == SCREEN_FULL);
293 view->AppendCheckItem(ID_view_dual_screen, _("Dual screen\tShift+F11"))->Check(_screen == SCREEN_DUAL);
294 view->Append(ID_view_closed_captions, _("Closed captions..."));
295 view->AppendSeparator();
296 view->AppendRadioItem(ID_view_scale_appropriate, _("Set decode resolution to match display"))->Check(!static_cast<bool>(c));
297 view->AppendRadioItem(ID_view_scale_full, _("Decode at full resolution"))->Check(c && c.get() == 0);
298 view->AppendRadioItem(ID_view_scale_half, _("Decode at half resolution"))->Check(c && c.get() == 1);
299 view->AppendRadioItem(ID_view_scale_quarter, _("Decode at quarter resolution"))->Check(c && c.get() == 2);
301 wxMenu* tools = new wxMenu;
302 _tools_verify = tools->Append (ID_tools_verify, _("Verify DCP"));
303 tools->AppendSeparator ();
304 tools->Append (ID_tools_check_for_updates, _("Check for updates"));
306 wxMenu* help = new wxMenu;
308 help->Append (wxID_ABOUT, _("About DCP-o-matic"));
310 help->Append (wxID_ABOUT, _("About"));
312 help->Append (ID_help_report_a_problem, _("Report a problem..."));
314 m->Append (_file_menu, _("&File"));
316 m->Append (edit, _("&Edit"));
318 m->Append (view, _("&View"));
319 m->Append (tools, _("&Tools"));
320 m->Append (help, _("&Help"));
325 wxString d = wxStandardPaths::Get().GetDocumentsDir();
326 if (Config::instance()->last_player_load_directory()) {
327 d = std_to_wx (Config::instance()->last_player_load_directory()->string());
330 wxDirDialog* c = new wxDirDialog (this, _("Select DCP to open"), d, wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST);
335 if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
336 error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
343 boost::filesystem::path const dcp (wx_to_std (c->GetPath ()));
345 Config::instance()->set_last_player_load_directory (dcp.parent_path());
353 wxDirDialog* c = new wxDirDialog (
355 _("Select DCP to open as OV"),
356 wxStandardPaths::Get().GetDocumentsDir(),
357 wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
363 if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
364 error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
371 DCPOMATIC_ASSERT (_film);
372 shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
373 DCPOMATIC_ASSERT (dcp);
374 dcp->add_ov (wx_to_std(c->GetPath()));
375 JobManager::instance()->add(shared_ptr<Job>(new ExamineContentJob (_film, dcp)));
376 bool const ok = progress (_("Loading DCP"));
377 if (!ok || !report_errors_from_last_job()) {
380 setup_from_dcp (dcp);
384 _info->triggered_update ();
389 wxFileDialog* d = new wxFileDialog (this, _("Select KDM"));
391 if (d->ShowModal() == wxID_OK) {
392 DCPOMATIC_ASSERT (_film);
393 shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
394 DCPOMATIC_ASSERT (dcp);
396 dcp->add_kdm (dcp::EncryptedKDM (dcp::file_to_string (wx_to_std (d->GetPath ()), MAX_KDM_SIZE)));
397 dcp->examine (shared_ptr<Job>());
398 } catch (exception& e) {
399 error_dialog (this, wxString::Format (_("Could not load KDM.")), std_to_wx(e.what()));
406 _info->triggered_update ();
409 void file_history (wxCommandEvent& event)
411 vector<boost::filesystem::path> history = Config::instance()->player_history ();
412 int n = event.GetId() - ID_file_history;
413 if (n >= 0 && n < static_cast<int> (history.size ())) {
414 load_dcp (history[n]);
420 _viewer->set_film (shared_ptr<Film>());
422 _info->triggered_update ();
423 set_menu_sensitivity ();
431 void edit_preferences ()
433 if (!_config_dialog) {
434 _config_dialog = create_player_config_dialog ();
436 _config_dialog->Show (this);
439 void view_cpl (wxCommandEvent& ev)
441 shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
442 DCPOMATIC_ASSERT (dcp);
443 DCPExaminer ex (dcp);
444 int id = ev.GetId() - ID_view_cpl;
445 DCPOMATIC_ASSERT (id >= 0);
446 DCPOMATIC_ASSERT (id < int(ex.cpls().size()));
447 list<shared_ptr<dcp::CPL> > cpls = ex.cpls();
448 list<shared_ptr<dcp::CPL> >::iterator i = cpls.begin();
454 dcp->set_cpl ((*i)->id());
455 dcp->examine (shared_ptr<Job>());
458 void view_full_screen ()
460 if (_screen == SCREEN_FULL) {
461 _screen = SCREEN_WINDOW;
463 _screen = SCREEN_FULL;
468 void view_dual_screen ()
470 if (_screen == SCREEN_DUAL) {
471 _screen = SCREEN_WINDOW;
473 _screen = SCREEN_DUAL;
480 _controls->Show (_screen == SCREEN_WINDOW);
481 _info->Show (_screen == SCREEN_WINDOW);
482 _overall_panel->SetBackgroundColour (_screen == SCREEN_WINDOW ? wxNullColour : wxColour(0, 0, 0));
483 ShowFullScreen (_screen != SCREEN_WINDOW);
484 if (_screen == SCREEN_DUAL) {
485 _cinema_dialog->Show ();
486 if (wxDisplay::GetCount() > 1) {
488 _cinema_dialog->Move (wxDisplay(0).GetClientArea().GetWidth(), 0);
493 void view_closed_captions ()
495 _viewer->show_closed_captions ();
500 shared_ptr<DCPContent> dcp = boost::dynamic_pointer_cast<DCPContent>(_film->content().front());
501 DCPOMATIC_ASSERT (dcp);
503 JobManager* jm = JobManager::instance ();
504 jm->add (shared_ptr<Job> (new VerifyDCPJob (dcp->directories())));
505 bool const ok = progress (_("Verifying DCP"));
510 DCPOMATIC_ASSERT (!jm->get().empty());
511 shared_ptr<VerifyDCPJob> last = dynamic_pointer_cast<VerifyDCPJob> (jm->get().back());
512 DCPOMATIC_ASSERT (last);
514 VerifyDCPDialog* d = new VerifyDCPDialog (this, last);
519 void tools_check_for_updates ()
521 UpdateChecker::instance()->run ();
522 _update_news_requested = true;
527 AboutDialog* d = new AboutDialog (this);
532 void help_report_a_problem ()
534 ReportProblemDialog* d = new ReportProblemDialog (this);
535 if (d->ShowModal () == wxID_OK) {
541 void update_checker_state_changed ()
543 UpdateChecker* uc = UpdateChecker::instance ();
545 bool const announce =
546 _update_news_requested ||
547 (uc->stable() && Config::instance()->check_for_updates()) ||
548 (uc->test() && Config::instance()->check_for_updates() && Config::instance()->check_for_test_updates());
550 _update_news_requested = false;
556 if (uc->state() == UpdateChecker::YES) {
557 UpdateDialog* dialog = new UpdateDialog (this, uc->stable (), uc->test ());
558 dialog->ShowModal ();
560 } else if (uc->state() == UpdateChecker::FAILED) {
561 error_dialog (this, _("The DCP-o-matic download server could not be contacted."));
563 error_dialog (this, _("There are no new versions of DCP-o-matic available."));
566 _update_news_requested = false;
569 void config_changed ()
571 /* Instantly save any config changes when using the player GUI */
573 Config::instance()->write_config();
574 } catch (exception& e) {
578 _("Could not write to config file at %s. Your changes have not been saved."),
579 std_to_wx (Config::instance()->cinemas_file().string()).data()
584 for (int i = 0; i < _history_items; ++i) {
585 delete _file_menu->Remove (ID_file_history + i);
588 if (_history_separator) {
589 _file_menu->Remove (_history_separator);
591 delete _history_separator;
592 _history_separator = 0;
594 int pos = _history_position;
596 vector<boost::filesystem::path> history = Config::instance()->player_history ();
598 if (!history.empty ()) {
599 _history_separator = _file_menu->InsertSeparator (pos++);
602 for (size_t i = 0; i < history.size(); ++i) {
605 s = String::compose ("&%1 %2", i + 1, history[i].string());
607 s = history[i].string();
609 _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s));
612 _history_items = history.size ();
615 void set_menu_sensitivity ()
617 _tools_verify->Enable (static_cast<bool>(_film));
618 _file_add_ov->Enable (static_cast<bool>(_film));
619 _file_add_kdm->Enable (static_cast<bool>(_film));
620 _view_cpl->Enable (static_cast<bool>(_film));
623 void start_stop_pressed ()
625 if (_viewer->playing()) {
634 _viewer->seek_by (-_viewer->one_video_frame(), true);
637 void forward_frame ()
639 _viewer->seek_by (_viewer->one_video_frame(), true);
644 /** @return false if the task was cancelled */
645 bool progress (wxString task)
647 JobManager* jm = JobManager::instance ();
649 wxProgressDialog* progress = new wxProgressDialog (_("DCP-o-matic Player"), task, 100, 0, wxPD_CAN_ABORT);
653 while (jm->work_to_do() || signal_manager->ui_idle()) {
655 if (!progress->Pulse()) {
656 /* user pressed cancel */
657 BOOST_FOREACH (shared_ptr<Job> i, jm->get()) {
665 progress->Destroy ();
669 bool report_errors_from_last_job ()
671 JobManager* jm = JobManager::instance ();
673 DCPOMATIC_ASSERT (!jm->get().empty());
675 shared_ptr<Job> last = jm->get().back();
676 if (last->finished_in_error()) {
677 error_dialog(this, std_to_wx(last->error_summary()) + ".\n", std_to_wx(last->error_details()));
684 void setup_from_dcp (shared_ptr<DCPContent> dcp)
686 BOOST_FOREACH (shared_ptr<TextContent> i, dcp->text) {
691 Ratio const * r = Ratio::nearest_from_ratio(dcp->video->size().ratio());
693 _film->set_container(r);
698 bool _update_news_requested;
699 PlayerInformation* _info;
700 wxPreferencesEditor* _config_dialog;
702 CinemaPlayerDialog* _cinema_dialog;
703 wxPanel* _overall_panel;
705 wxMenuItem* _view_cpl;
708 int _history_position;
709 wxMenuItem* _history_separator;
710 shared_ptr<FilmViewer> _viewer;
712 boost::shared_ptr<Film> _film;
713 boost::signals2::scoped_connection _config_changed_connection;
714 wxMenuItem* _file_add_ov;
715 wxMenuItem* _file_add_kdm;
716 wxMenuItem* _tools_verify;
719 static const wxCmdLineEntryDesc command_line_description[] = {
720 { wxCMD_LINE_PARAM, 0, 0, "DCP to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
721 { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
724 class PlayServer : public Server
727 explicit PlayServer (DOMFrame* frame)
728 : Server (PLAYER_PLAY_PORT)
732 void handle (shared_ptr<Socket> socket)
735 int const length = socket->read_uint32 ();
736 scoped_array<char> buffer (new char[length]);
737 socket->read (reinterpret_cast<uint8_t*> (buffer.get()), length);
738 string s (buffer.get());
739 signal_manager->when_idle (bind (&DOMFrame::load_dcp, _frame, s));
740 socket->write (reinterpret_cast<uint8_t const *> ("OK"), 3);
751 * @brief The magic App class for wxWidgets.
753 class App : public wxApp
766 wxInitAllImageHandlers ();
768 Config::FailedToLoad.connect (boost::bind (&App::config_failed_to_load, this));
769 Config::Warning.connect (boost::bind (&App::config_warning, this, _1));
771 wxSplashScreen* splash = maybe_show_splash ();
773 SetAppName (_("DCP-o-matic Player"));
775 if (!wxApp::OnInit()) {
779 #ifdef DCPOMATIC_LINUX
780 unsetenv ("UBUNTU_MENUPROXY");
784 ProcessSerialNumber serial;
785 GetCurrentProcess (&serial);
786 TransformProcessType (&serial, kProcessTransformToForegroundApplication);
789 dcpomatic_setup_path_encoding ();
791 /* Enable i18n; this will create a Config object
792 to look for a force-configured language. This Config
793 object will be wrong, however, because dcpomatic_setup
794 hasn't yet been called and there aren't any filters etc.
797 dcpomatic_setup_i18n ();
799 /* Set things up, including filters etc.
800 which will now be internationalised correctly.
804 /* Force the configuration to be re-loaded correctly next
809 _frame = new DOMFrame ();
810 SetTopWindow (_frame);
817 signal_manager = new wxSignalManager (this);
819 PlayServer* server = new PlayServer (_frame);
820 new thread (boost::bind (&PlayServer::run, server));
822 if (!_dcp_to_load.empty() && boost::filesystem::is_directory (_dcp_to_load)) {
824 _frame->load_dcp (_dcp_to_load);
825 } catch (exception& e) {
826 error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load DCP %1.")), _dcp_to_load)), std_to_wx(e.what()));
830 Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
832 if (Config::instance()->check_for_updates ()) {
833 UpdateChecker::instance()->run ();
840 error_dialog (0, _("DCP-o-matic Player could not start."), std_to_wx(e.what()));
844 void OnInitCmdLine (wxCmdLineParser& parser)
846 parser.SetDesc (command_line_description);
847 parser.SetSwitchChars (wxT ("-"));
850 bool OnCmdLineParsed (wxCmdLineParser& parser)
852 if (parser.GetParamCount() > 0) {
853 _dcp_to_load = wx_to_std (parser.GetParam (0));
859 void report_exception ()
863 } catch (FileError& e) {
867 _("An exception occurred: %s (%s)\n\n") + REPORT_PROBLEM,
868 std_to_wx (e.what()),
869 std_to_wx (e.file().string().c_str ())
872 } catch (exception& e) {
876 _("An exception occurred: %s.\n\n") + REPORT_PROBLEM,
877 std_to_wx (e.what ())
881 error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
885 /* An unhandled exception has occurred inside the main event loop */
886 bool OnExceptionInMainLoop ()
889 /* This will terminate the program */
893 void OnUnhandledException ()
900 signal_manager->ui_idle ();
903 void config_failed_to_load ()
905 message_dialog (_frame, _("The existing configuration failed to load. Default values will be used instead. These may take a short time to create."));
908 void config_warning (string m)
910 message_dialog (_frame, std_to_wx (m));