2 Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
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.
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.
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.
22 #include <boost/filesystem.hpp>
27 #include <ApplicationServices/ApplicationServices.h>
29 #include <wx/generic/aboutdlgg.h>
30 #include <wx/stdpaths.h>
31 #include <wx/cmdline.h>
32 #include <wx/preferences.h>
33 #include <dcp/exceptions.h>
34 #include "wx/film_viewer.h"
35 #include "wx/film_editor.h"
36 #include "wx/job_manager_view.h"
37 #include "wx/config_dialog.h"
38 #include "wx/job_wrapper.h"
39 #include "wx/wx_util.h"
40 #include "wx/new_film_dialog.h"
41 #include "wx/properties_dialog.h"
42 #include "wx/wx_ui_signaller.h"
43 #include "wx/about_dialog.h"
44 #include "wx/kdm_dialog.h"
45 #include "wx/servers_list_dialog.h"
46 #include "wx/hints_dialog.h"
47 #include "wx/update_dialog.h"
48 #include "wx/content_panel.h"
49 #include "wx/report_problem_dialog.h"
51 #include "lib/config.h"
53 #include "lib/version.h"
54 #include "lib/ui_signaller.h"
56 #include "lib/job_manager.h"
57 #include "lib/transcode_job.h"
58 #include "lib/exceptions.h"
59 #include "lib/cinema.h"
61 #include "lib/send_kdm_email_job.h"
62 #include "lib/server_finder.h"
63 #include "lib/update.h"
64 #include "lib/content_factory.h"
74 using boost::shared_ptr;
75 using boost::dynamic_pointer_cast;
77 class FilmChangedDialog
80 FilmChangedDialog (string name)
82 _dialog = new wxMessageDialog (
84 wxString::Format (_("Save changes to film \"%s\" before closing?"), std_to_wx (name).data()),
86 wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
97 return _dialog->ShowModal ();
102 FilmChangedDialog (FilmChangedDialog const &);
104 wxMessageDialog* _dialog;
108 #define NEEDS_FILM 0x1
109 #define NOT_DURING_DCP_CREATION 0x2
110 #define NEEDS_CPL 0x4
111 #define NEEDS_SELECTED_VIDEO_CONTENT 0x8
113 map<wxMenuItem*, int> menu_items;
121 /* Allow spare IDs after _history for the recent files list */
122 ID_content_scale_to_fit_width = 100,
123 ID_content_scale_to_fit_height,
126 ID_jobs_send_dcp_to_tms,
129 ID_tools_encoding_servers,
130 ID_tools_check_for_updates,
131 ID_help_report_a_problem,
132 /* IDs for shortcuts (with no associated menu item) */
136 class Frame : public wxFrame
139 Frame (wxString const & title)
140 : wxFrame (NULL, -1, title)
142 , _servers_list_dialog (0)
146 , _history_position (0)
147 , _history_separator (0)
149 #if defined(DCPOMATIC_WINDOWS)
150 if (Config::instance()->win32_console ()) {
153 HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
154 int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
155 FILE* hf_out = _fdopen(hCrt, "w");
156 setvbuf(hf_out, NULL, _IONBF, 1);
159 HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
160 hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
161 FILE* hf_in = _fdopen(hCrt, "r");
162 setvbuf(hf_in, NULL, _IONBF, 128);
165 cout << "DCP-o-matic is starting." << "\n";
169 wxMenuBar* bar = new wxMenuBar;
173 _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&Frame::config_changed, this));
176 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_new, this), ID_file_new);
177 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_open, this), ID_file_open);
178 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_save, this), ID_file_save);
179 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_properties, this), ID_file_properties);
180 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE);
181 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_exit, this), wxID_EXIT);
182 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::edit_preferences, this), wxID_PREFERENCES);
183 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::content_scale_to_fit_width, this), ID_content_scale_to_fit_width);
184 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::content_scale_to_fit_height, this), ID_content_scale_to_fit_height);
185 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_dcp, this), ID_jobs_make_dcp);
186 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_kdms, this), ID_jobs_make_kdms);
187 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_send_dcp_to_tms, this), ID_jobs_send_dcp_to_tms);
188 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_show_dcp, this), ID_jobs_show_dcp);
189 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_hints, this), ID_tools_hints);
190 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_encoding_servers, this), ID_tools_encoding_servers);
191 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_check_for_updates, this), ID_tools_check_for_updates);
192 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_about, this), wxID_ABOUT);
193 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_report_a_problem, this), ID_help_report_a_problem);
195 Bind (wxEVT_CLOSE_WINDOW, boost::bind (&Frame::close, this, _1));
197 /* Use a panel as the only child of the Frame so that we avoid
198 the dark-grey background on Windows.
200 wxPanel* overall_panel = new wxPanel (this, wxID_ANY);
202 _film_editor = new FilmEditor (overall_panel);
203 _film_viewer = new FilmViewer (overall_panel);
204 JobManagerView* job_manager_view = new JobManagerView (overall_panel);
206 wxBoxSizer* right_sizer = new wxBoxSizer (wxVERTICAL);
207 right_sizer->Add (_film_viewer, 2, wxEXPAND | wxALL, 6);
208 right_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6);
210 wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
211 main_sizer->Add (_film_editor, 1, wxEXPAND | wxALL, 6);
212 main_sizer->Add (right_sizer, 2, wxEXPAND | wxALL, 6);
214 set_menu_sensitivity ();
216 _film_editor->FileChanged.connect (bind (&Frame::file_changed, this, _1));
219 JobManager::instance()->ActiveJobsChanged.connect (boost::bind (&Frame::set_menu_sensitivity, this));
221 overall_panel->SetSizer (main_sizer);
223 wxAcceleratorEntry accel[1];
224 accel[0].Set (wxACCEL_CTRL, static_cast<int>('A'), ID_add_file);
225 Bind (wxEVT_MENU, boost::bind (&ContentPanel::add_file_clicked, _film_editor->content_panel()), ID_add_file);
226 wxAcceleratorTable accel_table (1, accel);
227 SetAcceleratorTable (accel_table);
230 void new_film (boost::filesystem::path path)
232 shared_ptr<Film> film (new Film (path));
233 film->write_metadata ();
234 film->set_name (path.filename().generic_string());
238 void load_film (boost::filesystem::path file)
241 maybe_save_then_delete_film ();
243 shared_ptr<Film> film (new Film (file));
244 list<string> const notes = film->read_metadata ();
246 if (film->state_version() == 4) {
249 _("This film was created with an old version of DVD-o-matic and may not load correctly "
250 "in this version. Please check the film's settings carefully.")
254 for (list<string>::const_iterator i = notes.begin(); i != notes.end(); ++i) {
255 error_dialog (0, std_to_wx (*i));
260 catch (std::exception& e) {
261 wxString p = std_to_wx (file.string ());
262 wxCharBuffer b = p.ToUTF8 ();
263 error_dialog (this, wxString::Format (_("Could not open film at %s (%s)"), p.data(), std_to_wx (e.what()).data()));
266 void set_film (shared_ptr<Film> film)
269 _film_viewer->set_film (_film);
270 _film_editor->set_film (_film);
271 set_menu_sensitivity ();
272 Config::instance()->add_to_history (_film->directory ());
275 shared_ptr<Film> film () const {
281 void file_changed (boost::filesystem::path f)
283 string s = wx_to_std (_("DCP-o-matic"));
285 s += " - " + f.string ();
288 SetTitle (std_to_wx (s));
293 NewFilmDialog* d = new NewFilmDialog (this);
294 int const r = d->ShowModal ();
298 if (boost::filesystem::is_directory (d->get_path()) && !boost::filesystem::is_empty(d->get_path())) {
299 if (!confirm_dialog (
302 String::compose (wx_to_std (_("The directory %1 already exists and is not empty. "
303 "Are you sure you want to use it?")),
304 d->get_path().string().c_str())
309 } else if (boost::filesystem::is_regular_file (d->get_path())) {
312 String::compose (wx_to_std (_("%1 already exists as a file, so you cannot use it for a new film.")), d->get_path().c_str())
317 maybe_save_then_delete_film ();
318 new_film (d->get_path ());
326 wxDirDialog* c = new wxDirDialog (
328 _("Select film to open"),
329 std_to_wx (Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()),
330 wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
336 if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
337 error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
344 load_film (wx_to_std (c->GetPath ()));
352 _film->write_metadata ();
355 void file_properties ()
357 PropertiesDialog* d = new PropertiesDialog (this, _film);
362 void file_history (wxCommandEvent& event)
364 vector<boost::filesystem::path> history = Config::instance()->history ();
365 int n = event.GetId() - ID_file_history;
366 if (n >= 0 && n < static_cast<int> (history.size ())) {
367 load_film (history[n]);
373 /* false here allows the close handler to veto the close request */
377 void edit_preferences ()
379 if (!_config_dialog) {
380 _config_dialog = create_config_dialog ();
382 _config_dialog->Show (this);
385 void jobs_make_dcp ()
390 if (!_film->should_be_enough_disk_space (required, available)) {
391 if (!confirm_dialog (this, wxString::Format (_("The DCP for this film will take up about %.1f Gb, and the disk that you are using only has %.1f Gb available. Do you want to continue anyway?"), required, available))) {
396 JobWrapper::make_dcp (this, _film);
399 void jobs_make_kdms ()
405 KDMDialog* d = new KDMDialog (this, _film);
406 if (d->ShowModal () != wxID_OK) {
412 if (d->write_to ()) {
413 write_kdm_files (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation (), d->directory ());
415 JobManager::instance()->add (
416 shared_ptr<Job> (new SendKDMEmailJob (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation ()))
419 } catch (dcp::NotEncryptedError& e) {
420 error_dialog (this, _("CPL's content is not encrypted."));
421 } catch (exception& e) {
422 error_dialog (this, e.what ());
424 error_dialog (this, _("An unknown exception occurred."));
430 void content_scale_to_fit_width ()
432 VideoContentList vc = _film_editor->content_panel()->selected_video ();
433 for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
434 (*i)->scale_and_crop_to_fit_width ();
438 void content_scale_to_fit_height ()
440 VideoContentList vc = _film_editor->content_panel()->selected_video ();
441 for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
442 (*i)->scale_and_crop_to_fit_height ();
446 void jobs_send_dcp_to_tms ()
448 _film->send_dcp_to_tms ();
451 void jobs_show_dcp ()
454 string d = _film->directory().string ();
456 w.assign (d.begin(), d.end());
457 ShellExecute (0, L"open", w.c_str(), 0, 0, SW_SHOWDEFAULT);
459 int r = system ("which nautilus");
460 if (WEXITSTATUS (r) == 0) {
461 r = system (string ("nautilus " + _film->directory().string()).c_str ());
462 if (WEXITSTATUS (r)) {
463 error_dialog (this, _("Could not show DCP (could not run nautilus)"));
466 int r = system ("which konqueror");
467 if (WEXITSTATUS (r) == 0) {
468 r = system (string ("konqueror " + _film->directory().string()).c_str ());
469 if (WEXITSTATUS (r)) {
470 error_dialog (this, _("Could not show DCP (could not run konqueror)"));
479 if (!_hints_dialog) {
480 _hints_dialog = new HintsDialog (this, _film);
483 _hints_dialog->Show ();
486 void tools_encoding_servers ()
488 if (!_servers_list_dialog) {
489 _servers_list_dialog = new ServersListDialog (this);
492 _servers_list_dialog->Show ();
495 void tools_check_for_updates ()
497 UpdateChecker::instance()->run ();
502 AboutDialog* d = new AboutDialog (this);
507 void help_report_a_problem ()
509 ReportProblemDialog* d = new ReportProblemDialog (this, _film);
510 if (d->ShowModal () == wxID_OK) {
518 if (!JobManager::instance()->work_to_do ()) {
522 wxMessageDialog* d = new wxMessageDialog (
524 _("There are unfinished jobs; are you sure you want to quit?"),
525 _("Unfinished jobs"),
526 wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
529 bool const r = d->ShowModal() == wxID_YES;
534 void close (wxCloseEvent& ev)
536 if (!should_close ()) {
541 /* We don't want to hear about any more configuration changes, since they
542 cause the File menu to be altered, which itself will be deleted around
543 now (without, as far as I can see, any way for us to find out).
545 _config_changed_connection.disconnect ();
547 maybe_save_then_delete_film ();
551 void set_menu_sensitivity ()
553 list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
554 list<shared_ptr<Job> >::iterator i = jobs.begin();
555 while (i != jobs.end() && dynamic_pointer_cast<TranscodeJob> (*i) == 0) {
558 bool const dcp_creation = (i != jobs.end ()) && !(*i)->finished ();
559 bool const have_cpl = _film && !_film->cpls().empty ();
560 bool const have_selected_video_content = !_film_editor->content_panel()->selected_video().empty();
562 for (map<wxMenuItem*, int>::iterator j = menu_items.begin(); j != menu_items.end(); ++j) {
566 if ((j->second & NEEDS_FILM) && !_film) {
570 if ((j->second & NOT_DURING_DCP_CREATION) && dcp_creation) {
574 if ((j->second & NEEDS_CPL) && !have_cpl) {
578 if ((j->second & NEEDS_SELECTED_VIDEO_CONTENT) && !have_selected_video_content) {
582 j->first->Enable (enabled);
586 void maybe_save_then_delete_film ()
592 if (_film->dirty ()) {
593 FilmChangedDialog d (_film->name ());
598 _film->write_metadata ();
606 void add_item (wxMenu* menu, wxString text, int id, int sens)
608 wxMenuItem* item = menu->Append (id, text);
609 menu_items.insert (make_pair (item, sens));
612 void setup_menu (wxMenuBar* m)
614 _file_menu = new wxMenu;
615 add_item (_file_menu, _("New...\tCtrl-N"), ID_file_new, ALWAYS);
616 add_item (_file_menu, _("&Open...\tCtrl-O"), ID_file_open, ALWAYS);
617 _file_menu->AppendSeparator ();
618 add_item (_file_menu, _("&Save\tCtrl-S"), ID_file_save, NEEDS_FILM);
619 _file_menu->AppendSeparator ();
620 add_item (_file_menu, _("&Properties..."), ID_file_properties, NEEDS_FILM);
622 _history_position = _file_menu->GetMenuItems().GetCount();
625 _file_menu->AppendSeparator ();
629 add_item (_file_menu, _("&Exit"), wxID_EXIT, ALWAYS);
631 add_item (_file_menu, _("&Quit"), wxID_EXIT, ALWAYS);
635 add_item (_file_menu, _("&Preferences...\tCtrl-P"), wxID_PREFERENCES, ALWAYS);
637 wxMenu* edit = new wxMenu;
638 add_item (edit, _("&Preferences...\tCtrl-P"), wxID_PREFERENCES, ALWAYS);
641 wxMenu* content = new wxMenu;
642 add_item (content, _("Scale to fit &width"), ID_content_scale_to_fit_width, NEEDS_FILM | NEEDS_SELECTED_VIDEO_CONTENT);
643 add_item (content, _("Scale to fit &height"), ID_content_scale_to_fit_height, NEEDS_FILM | NEEDS_SELECTED_VIDEO_CONTENT);
645 wxMenu* jobs_menu = new wxMenu;
646 add_item (jobs_menu, _("&Make DCP\tCtrl-M"), ID_jobs_make_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION);
647 add_item (jobs_menu, _("Make &KDMs...\tCtrl-K"), ID_jobs_make_kdms, NEEDS_FILM);
648 add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL);
649 add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL);
651 wxMenu* tools = new wxMenu;
652 add_item (tools, _("Hints...\tCtrl-H"), ID_tools_hints, 0);
653 add_item (tools, _("Encoding servers..."), ID_tools_encoding_servers, 0);
654 add_item (tools, _("Check for updates"), ID_tools_check_for_updates, 0);
656 wxMenu* help = new wxMenu;
658 add_item (help, _("About DCP-o-matic"), wxID_ABOUT, ALWAYS);
660 add_item (help, _("About"), wxID_ABOUT, ALWAYS);
662 add_item (help, _("Report a problem..."), ID_help_report_a_problem, ALWAYS);
664 m->Append (_file_menu, _("&File"));
666 m->Append (edit, _("&Edit"));
668 m->Append (content, _("&Content"));
669 m->Append (jobs_menu, _("&Jobs"));
670 m->Append (tools, _("&Tools"));
671 m->Append (help, _("&Help"));
674 void config_changed ()
676 for (int i = 0; i < _history_items; ++i) {
677 delete _file_menu->Remove (ID_file_history + i);
680 if (_history_separator) {
681 _file_menu->Remove (_history_separator);
683 delete _history_separator;
684 _history_separator = 0;
686 int pos = _history_position;
688 vector<boost::filesystem::path> history = Config::instance()->history ();
690 if (!history.empty ()) {
691 _history_separator = _file_menu->InsertSeparator (pos++);
694 for (size_t i = 0; i < history.size(); ++i) {
697 s << "&" << (i + 1) << " ";
699 s << history[i].string();
700 _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s.str ()));
703 _history_items = history.size ();
706 FilmEditor* _film_editor;
707 FilmViewer* _film_viewer;
708 HintsDialog* _hints_dialog;
709 ServersListDialog* _servers_list_dialog;
710 wxPreferencesEditor* _config_dialog;
712 shared_ptr<Film> _film;
714 int _history_position;
715 wxMenuItem* _history_separator;
716 boost::signals2::scoped_connection _config_changed_connection;
719 static const wxCmdLineEntryDesc command_line_description[] = {
720 { wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
721 { wxCMD_LINE_OPTION, "c", "content", "add content file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
722 { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
723 { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
727 * @brief The magic App class for wxWidgets.
729 class App : public wxApp
734 SetAppName (_("DCP-o-matic"));
736 if (!wxApp::OnInit()) {
740 #ifdef DCPOMATIC_LINUX
741 unsetenv ("UBUNTU_MENUPROXY");
745 ProcessSerialNumber serial;
746 GetCurrentProcess (&serial);
747 TransformProcessType (&serial, kProcessTransformToForegroundApplication);
750 wxInitAllImageHandlers ();
752 /* Enable i18n; this will create a Config object
753 to look for a force-configured language. This Config
754 object will be wrong, however, because dcpomatic_setup
755 hasn't yet been called and there aren't any scalers, filters etc.
758 dcpomatic_setup_i18n ();
760 /* Set things up, including scalers / filters etc.
761 which will now be internationalised correctly.
765 /* Force the configuration to be re-loaded correctly next
770 _frame = new Frame (_("DCP-o-matic"));
771 SetTopWindow (_frame);
775 if (!_film_to_load.empty() && boost::filesystem::is_directory (_film_to_load)) {
777 _frame->load_film (_film_to_load);
778 } catch (exception& e) {
779 error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load film %1 (%2)")), _film_to_load, e.what())));
783 if (!_film_to_create.empty ()) {
784 _frame->new_film (_film_to_create);
785 if (!_content_to_add.empty ()) {
786 _frame->film()->examine_and_add_content (content_factory (_frame->film(), _content_to_add));
790 ui_signaller = new wxUISignaller (this);
791 Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
793 Bind (wxEVT_TIMER, boost::bind (&App::check, this));
794 _timer.reset (new wxTimer (this));
795 _timer->Start (1000);
797 UpdateChecker::instance()->StateChanged.connect (boost::bind (&App::update_checker_state_changed, this));
798 if (Config::instance()->check_for_updates ()) {
799 UpdateChecker::instance()->run ();
806 error_dialog (0, wxString::Format ("DCP-o-matic could not start: %s", e.what ()));
810 void OnInitCmdLine (wxCmdLineParser& parser)
812 parser.SetDesc (command_line_description);
813 parser.SetSwitchChars (wxT ("-"));
816 bool OnCmdLineParsed (wxCmdLineParser& parser)
818 if (parser.GetParamCount() > 0) {
819 if (parser.Found (wxT ("new"))) {
820 _film_to_create = wx_to_std (parser.GetParam (0));
822 _film_to_load = wx_to_std (parser.GetParam (0));
827 if (parser.Found (wxT ("content"), &content)) {
828 _content_to_add = wx_to_std (content);
834 /* An unhandled exception has occurred inside the main event loop */
835 bool OnExceptionInMainLoop ()
839 } catch (exception& e) {
840 error_dialog (0, wxString::Format (_("An exception occurred (%s)."), e.what ()) + " " + REPORT_PROBLEM); } catch (...) {
841 error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
844 /* This will terminate the program */
848 void OnUnhandledException ()
850 error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
855 ui_signaller->ui_idle ();
861 ServerFinder::instance()->rethrow ();
862 } catch (exception& e) {
863 error_dialog (0, std_to_wx (e.what ()));
867 void update_checker_state_changed ()
869 switch (UpdateChecker::instance()->state ()) {
870 case UpdateChecker::YES:
873 if (Config::instance()->check_for_test_updates ()) {
874 test = UpdateChecker::instance()->test ();
876 UpdateDialog* dialog = new UpdateDialog (_frame, UpdateChecker::instance()->stable (), test);
877 dialog->ShowModal ();
881 case UpdateChecker::NO:
882 if (!UpdateChecker::instance()->last_emit_was_first ()) {
883 error_dialog (_frame, _("There are no new versions of DCP-o-matic available."));
886 case UpdateChecker::FAILED:
887 if (!UpdateChecker::instance()->last_emit_was_first ()) {
888 error_dialog (_frame, _("The DCP-o-matic download server could not be contacted."));
896 shared_ptr<wxTimer> _timer;
897 string _film_to_load;
898 string _film_to_create;
899 string _content_to_add;