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"
50 #include "lib/config.h"
52 #include "lib/version.h"
53 #include "lib/ui_signaller.h"
55 #include "lib/job_manager.h"
56 #include "lib/transcode_job.h"
57 #include "lib/exceptions.h"
58 #include "lib/cinema.h"
60 #include "lib/send_kdm_email_job.h"
61 #include "lib/server_finder.h"
62 #include "lib/update.h"
63 #include "lib/content_factory.h"
73 using boost::shared_ptr;
74 using boost::dynamic_pointer_cast;
76 class FilmChangedDialog
79 FilmChangedDialog (string name)
81 _dialog = new wxMessageDialog (
83 wxString::Format (_("Save changes to film \"%s\" before closing?"), std_to_wx (name).data()),
85 wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
96 return _dialog->ShowModal ();
101 FilmChangedDialog (FilmChangedDialog const &);
103 wxMessageDialog* _dialog;
107 #define NEEDS_FILM 0x1
108 #define NOT_DURING_DCP_CREATION 0x2
109 #define NEEDS_CPL 0x4
110 #define NEEDS_SELECTED_VIDEO_CONTENT 0x8
112 map<wxMenuItem*, int> menu_items;
120 /* Allow spare IDs after _history for the recent files list */
121 ID_content_scale_to_fit_width = 100,
122 ID_content_scale_to_fit_height,
125 ID_jobs_send_dcp_to_tms,
128 ID_tools_encoding_servers,
129 ID_tools_check_for_updates,
130 /* IDs for shortcuts (with no associated menu item) */
134 class Frame : public wxFrame
137 Frame (wxString const & title)
138 : wxFrame (NULL, -1, title)
140 , _servers_list_dialog (0)
144 , _history_position (0)
145 , _history_separator (0)
147 #if defined(DCPOMATIC_WINDOWS)
148 if (Config::instance()->win32_console ()) {
151 HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
152 int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
153 FILE* hf_out = _fdopen(hCrt, "w");
154 setvbuf(hf_out, NULL, _IONBF, 1);
157 HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
158 hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
159 FILE* hf_in = _fdopen(hCrt, "r");
160 setvbuf(hf_in, NULL, _IONBF, 128);
163 cout << "DCP-o-matic is starting." << "\n";
167 wxMenuBar* bar = new wxMenuBar;
171 _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&Frame::config_changed, this));
174 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_new, this), ID_file_new);
175 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_open, this), ID_file_open);
176 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_save, this), ID_file_save);
177 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_properties, this), ID_file_properties);
178 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE);
179 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_exit, this), wxID_EXIT);
180 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::edit_preferences, this), wxID_PREFERENCES);
181 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::content_scale_to_fit_width, this), ID_content_scale_to_fit_width);
182 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::content_scale_to_fit_height, this), ID_content_scale_to_fit_height);
183 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_dcp, this), ID_jobs_make_dcp);
184 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_kdms, this), ID_jobs_make_kdms);
185 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_send_dcp_to_tms, this), ID_jobs_send_dcp_to_tms);
186 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_show_dcp, this), ID_jobs_show_dcp);
187 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_hints, this), ID_tools_hints);
188 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_encoding_servers, this), ID_tools_encoding_servers);
189 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_check_for_updates, this), ID_tools_check_for_updates);
190 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_about, this), wxID_ABOUT);
192 Bind (wxEVT_CLOSE_WINDOW, boost::bind (&Frame::close, this, _1));
194 /* Use a panel as the only child of the Frame so that we avoid
195 the dark-grey background on Windows.
197 wxPanel* overall_panel = new wxPanel (this, wxID_ANY);
199 _film_editor = new FilmEditor (overall_panel);
200 _film_viewer = new FilmViewer (overall_panel);
201 JobManagerView* job_manager_view = new JobManagerView (overall_panel, static_cast<JobManagerView::Buttons> (0));
203 wxBoxSizer* right_sizer = new wxBoxSizer (wxVERTICAL);
204 right_sizer->Add (_film_viewer, 2, wxEXPAND | wxALL, 6);
205 right_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6);
207 wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
208 main_sizer->Add (_film_editor, 1, wxEXPAND | wxALL, 6);
209 main_sizer->Add (right_sizer, 2, wxEXPAND | wxALL, 6);
211 set_menu_sensitivity ();
213 _film_editor->FileChanged.connect (bind (&Frame::file_changed, this, _1));
216 JobManager::instance()->ActiveJobsChanged.connect (boost::bind (&Frame::set_menu_sensitivity, this));
218 overall_panel->SetSizer (main_sizer);
220 wxAcceleratorEntry accel[1];
221 accel[0].Set (wxACCEL_CTRL, static_cast<int>('A'), ID_add_file);
222 Bind (wxEVT_MENU, boost::bind (&ContentPanel::add_file_clicked, _film_editor->content_panel()), ID_add_file);
223 wxAcceleratorTable accel_table (1, accel);
224 SetAcceleratorTable (accel_table);
227 void new_film (boost::filesystem::path path)
229 shared_ptr<Film> film (new Film (path));
230 film->write_metadata ();
231 film->set_name (path.filename().generic_string());
235 void load_film (boost::filesystem::path file)
238 maybe_save_then_delete_film ();
240 shared_ptr<Film> film (new Film (file));
241 list<string> const notes = film->read_metadata ();
243 if (film->state_version() == 4) {
246 _("This film was created with an old version of DVD-o-matic and may not load correctly "
247 "in this version. Please check the film's settings carefully.")
251 for (list<string>::const_iterator i = notes.begin(); i != notes.end(); ++i) {
252 error_dialog (0, std_to_wx (*i));
257 catch (std::exception& e) {
258 wxString p = std_to_wx (file.string ());
259 wxCharBuffer b = p.ToUTF8 ();
260 error_dialog (this, wxString::Format (_("Could not open film at %s (%s)"), p.data(), std_to_wx (e.what()).data()));
263 void set_film (shared_ptr<Film> film)
266 _film_viewer->set_film (_film);
267 _film_editor->set_film (_film);
268 set_menu_sensitivity ();
269 Config::instance()->add_to_history (_film->directory ());
272 shared_ptr<Film> film () const {
278 void file_changed (boost::filesystem::path f)
280 string s = wx_to_std (_("DCP-o-matic"));
282 s += " - " + f.string ();
285 SetTitle (std_to_wx (s));
290 NewFilmDialog* d = new NewFilmDialog (this);
291 int const r = d->ShowModal ();
295 if (boost::filesystem::is_directory (d->get_path()) && !boost::filesystem::is_empty(d->get_path())) {
296 if (!confirm_dialog (
299 String::compose (wx_to_std (_("The directory %1 already exists and is not empty. "
300 "Are you sure you want to use it?")),
301 d->get_path().string().c_str())
306 } else if (boost::filesystem::is_regular_file (d->get_path())) {
309 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())
314 maybe_save_then_delete_film ();
315 new_film (d->get_path ());
323 wxDirDialog* c = new wxDirDialog (
325 _("Select film to open"),
326 std_to_wx (Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()),
327 wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
333 if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
334 error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
341 load_film (wx_to_std (c->GetPath ()));
349 _film->write_metadata ();
352 void file_properties ()
354 PropertiesDialog* d = new PropertiesDialog (this, _film);
359 void file_history (wxCommandEvent& event)
361 vector<boost::filesystem::path> history = Config::instance()->history ();
362 int n = event.GetId() - ID_file_history;
363 if (n >= 0 && n < static_cast<int> (history.size ())) {
364 load_film (history[n]);
370 /* false here allows the close handler to veto the close request */
374 void edit_preferences ()
376 if (!_config_dialog) {
377 _config_dialog = create_config_dialog ();
379 _config_dialog->Show (this);
382 void jobs_make_dcp ()
387 if (!_film->should_be_enough_disk_space (required, available)) {
388 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))) {
393 JobWrapper::make_dcp (this, _film);
396 void jobs_make_kdms ()
402 KDMDialog* d = new KDMDialog (this, _film);
403 if (d->ShowModal () != wxID_OK) {
409 if (d->write_to ()) {
410 write_kdm_files (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation (), d->directory ());
412 JobManager::instance()->add (
413 shared_ptr<Job> (new SendKDMEmailJob (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation ()))
416 } catch (dcp::NotEncryptedError& e) {
417 error_dialog (this, _("CPL's content is not encrypted."));
418 } catch (exception& e) {
419 error_dialog (this, e.what ());
421 error_dialog (this, _("An unknown exeception occurred."));
427 void content_scale_to_fit_width ()
429 VideoContentList vc = _film_editor->content_panel()->selected_video ();
430 for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
431 (*i)->scale_and_crop_to_fit_width ();
435 void content_scale_to_fit_height ()
437 VideoContentList vc = _film_editor->content_panel()->selected_video ();
438 for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
439 (*i)->scale_and_crop_to_fit_height ();
443 void jobs_send_dcp_to_tms ()
445 _film->send_dcp_to_tms ();
448 void jobs_show_dcp ()
451 string d = _film->directory().string ();
453 w.assign (d.begin(), d.end());
454 ShellExecute (0, L"open", w.c_str(), 0, 0, SW_SHOWDEFAULT);
456 int r = system ("which nautilus");
457 if (WEXITSTATUS (r) == 0) {
458 r = system (string ("nautilus " + _film->directory().string()).c_str ());
459 if (WEXITSTATUS (r)) {
460 error_dialog (this, _("Could not show DCP (could not run nautilus)"));
463 int r = system ("which konqueror");
464 if (WEXITSTATUS (r) == 0) {
465 r = system (string ("konqueror " + _film->directory().string()).c_str ());
466 if (WEXITSTATUS (r)) {
467 error_dialog (this, _("Could not show DCP (could not run konqueror)"));
476 if (!_hints_dialog) {
477 _hints_dialog = new HintsDialog (this, _film);
480 _hints_dialog->Show ();
483 void tools_encoding_servers ()
485 if (!_servers_list_dialog) {
486 _servers_list_dialog = new ServersListDialog (this);
489 _servers_list_dialog->Show ();
492 void tools_check_for_updates ()
494 UpdateChecker::instance()->run ();
499 AboutDialog* d = new AboutDialog (this);
506 if (!JobManager::instance()->work_to_do ()) {
510 wxMessageDialog* d = new wxMessageDialog (
512 _("There are unfinished jobs; are you sure you want to quit?"),
513 _("Unfinished jobs"),
514 wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
517 bool const r = d->ShowModal() == wxID_YES;
522 void close (wxCloseEvent& ev)
524 if (!should_close ()) {
529 /* We don't want to hear about any more configuration changes, since they
530 cause the File menu to be altered, which itself will be deleted around
531 now (without, as far as I can see, any way for us to find out).
533 _config_changed_connection.disconnect ();
535 maybe_save_then_delete_film ();
539 void set_menu_sensitivity ()
541 list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
542 list<shared_ptr<Job> >::iterator i = jobs.begin();
543 while (i != jobs.end() && dynamic_pointer_cast<TranscodeJob> (*i) == 0) {
546 bool const dcp_creation = (i != jobs.end ()) && !(*i)->finished ();
547 bool const have_cpl = _film && !_film->cpls().empty ();
548 bool const have_selected_video_content = !_film_editor->content_panel()->selected_video().empty();
550 for (map<wxMenuItem*, int>::iterator j = menu_items.begin(); j != menu_items.end(); ++j) {
554 if ((j->second & NEEDS_FILM) && !_film) {
558 if ((j->second & NOT_DURING_DCP_CREATION) && dcp_creation) {
562 if ((j->second & NEEDS_CPL) && !have_cpl) {
566 if ((j->second & NEEDS_SELECTED_VIDEO_CONTENT) && !have_selected_video_content) {
570 j->first->Enable (enabled);
574 void maybe_save_then_delete_film ()
580 if (_film->dirty ()) {
581 FilmChangedDialog d (_film->name ());
586 _film->write_metadata ();
594 void add_item (wxMenu* menu, wxString text, int id, int sens)
596 wxMenuItem* item = menu->Append (id, text);
597 menu_items.insert (make_pair (item, sens));
600 void setup_menu (wxMenuBar* m)
602 _file_menu = new wxMenu;
603 add_item (_file_menu, _("New...\tCtrl-N"), ID_file_new, ALWAYS);
604 add_item (_file_menu, _("&Open...\tCtrl-O"), ID_file_open, ALWAYS);
605 _file_menu->AppendSeparator ();
606 add_item (_file_menu, _("&Save\tCtrl-S"), ID_file_save, NEEDS_FILM);
607 _file_menu->AppendSeparator ();
608 add_item (_file_menu, _("&Properties..."), ID_file_properties, NEEDS_FILM);
610 _history_position = _file_menu->GetMenuItems().GetCount();
613 _file_menu->AppendSeparator ();
617 add_item (_file_menu, _("&Exit"), wxID_EXIT, ALWAYS);
619 add_item (_file_menu, _("&Quit"), wxID_EXIT, ALWAYS);
623 add_item (_file_menu, _("&Preferences...\tCtrl-P"), wxID_PREFERENCES, ALWAYS);
625 wxMenu* edit = new wxMenu;
626 add_item (edit, _("&Preferences...\tCtrl-P"), wxID_PREFERENCES, ALWAYS);
629 wxMenu* content = new wxMenu;
630 add_item (content, _("Scale to fit &width"), ID_content_scale_to_fit_width, NEEDS_FILM | NEEDS_SELECTED_VIDEO_CONTENT);
631 add_item (content, _("Scale to fit &height"), ID_content_scale_to_fit_height, NEEDS_FILM | NEEDS_SELECTED_VIDEO_CONTENT);
633 wxMenu* jobs_menu = new wxMenu;
634 add_item (jobs_menu, _("&Make DCP\tCtrl-M"), ID_jobs_make_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION);
635 add_item (jobs_menu, _("Make &KDMs...\tCtrl-K"), ID_jobs_make_kdms, NEEDS_FILM);
636 add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL);
637 add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL);
639 wxMenu* tools = new wxMenu;
640 add_item (tools, _("Hints...\tCtrl-H"), ID_tools_hints, 0);
641 add_item (tools, _("Encoding servers..."), ID_tools_encoding_servers, 0);
642 add_item (tools, _("Check for updates"), ID_tools_check_for_updates, 0);
644 wxMenu* help = new wxMenu;
646 add_item (help, _("About DCP-o-matic"), wxID_ABOUT, ALWAYS);
648 add_item (help, _("About"), wxID_ABOUT, ALWAYS);
651 m->Append (_file_menu, _("&File"));
653 m->Append (edit, _("&Edit"));
655 m->Append (content, _("&Content"));
656 m->Append (jobs_menu, _("&Jobs"));
657 m->Append (tools, _("&Tools"));
658 m->Append (help, _("&Help"));
661 void config_changed ()
663 for (int i = 0; i < _history_items; ++i) {
664 delete _file_menu->Remove (ID_file_history + i);
667 if (_history_separator) {
668 _file_menu->Remove (_history_separator);
670 delete _history_separator;
671 _history_separator = 0;
673 int pos = _history_position;
675 vector<boost::filesystem::path> history = Config::instance()->history ();
677 if (!history.empty ()) {
678 _history_separator = _file_menu->InsertSeparator (pos++);
681 for (size_t i = 0; i < history.size(); ++i) {
684 s << "&" << (i + 1) << " ";
686 s << history[i].string();
687 _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s.str ()));
690 _history_items = history.size ();
693 FilmEditor* _film_editor;
694 FilmViewer* _film_viewer;
695 HintsDialog* _hints_dialog;
696 ServersListDialog* _servers_list_dialog;
697 wxPreferencesEditor* _config_dialog;
699 shared_ptr<Film> _film;
701 int _history_position;
702 wxMenuItem* _history_separator;
703 boost::signals2::scoped_connection _config_changed_connection;
706 static const wxCmdLineEntryDesc command_line_description[] = {
707 { wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
708 { wxCMD_LINE_OPTION, "c", "content", "add content file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
709 { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
710 { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
714 * @brief The magic App class for wxWidgets.
716 class App : public wxApp
721 SetAppName (_("DCP-o-matic"));
723 if (!wxApp::OnInit()) {
727 #ifdef DCPOMATIC_LINUX
728 unsetenv ("UBUNTU_MENUPROXY");
732 ProcessSerialNumber serial;
733 GetCurrentProcess (&serial);
734 TransformProcessType (&serial, kProcessTransformToForegroundApplication);
737 wxInitAllImageHandlers ();
739 /* Enable i18n; this will create a Config object
740 to look for a force-configured language. This Config
741 object will be wrong, however, because dcpomatic_setup
742 hasn't yet been called and there aren't any scalers, filters etc.
745 dcpomatic_setup_i18n ();
747 /* Set things up, including scalers / filters etc.
748 which will now be internationalised correctly.
752 /* Force the configuration to be re-loaded correctly next
757 _frame = new Frame (_("DCP-o-matic"));
758 SetTopWindow (_frame);
762 if (!_film_to_load.empty() && boost::filesystem::is_directory (_film_to_load)) {
764 _frame->load_film (_film_to_load);
765 } catch (exception& e) {
766 error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load film %1 (%2)")), _film_to_load, e.what())));
770 if (!_film_to_create.empty ()) {
771 _frame->new_film (_film_to_create);
772 if (!_content_to_add.empty ()) {
773 _frame->film()->examine_and_add_content (content_factory (_frame->film(), _content_to_add));
777 ui_signaller = new wxUISignaller (this);
778 Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
780 Bind (wxEVT_TIMER, boost::bind (&App::check, this));
781 _timer.reset (new wxTimer (this));
782 _timer->Start (1000);
784 UpdateChecker::instance()->StateChanged.connect (boost::bind (&App::update_checker_state_changed, this));
785 if (Config::instance()->check_for_updates ()) {
786 UpdateChecker::instance()->run ();
793 error_dialog (0, wxString::Format ("DCP-o-matic could not start: %s", e.what ()));
797 void OnInitCmdLine (wxCmdLineParser& parser)
799 parser.SetDesc (command_line_description);
800 parser.SetSwitchChars (wxT ("-"));
803 bool OnCmdLineParsed (wxCmdLineParser& parser)
805 if (parser.GetParamCount() > 0) {
806 if (parser.Found (wxT ("new"))) {
807 _film_to_create = wx_to_std (parser.GetParam (0));
809 _film_to_load = wx_to_std (parser.GetParam (0));
814 if (parser.Found (wxT ("content"), &content)) {
815 _content_to_add = wx_to_std (content);
821 /* An unhandled exception has occurred inside the main event loop */
822 bool OnExceptionInMainLoop ()
826 } catch (exception& e) {
827 error_dialog (0, wxString::Format (_("An exception occurred (%s). Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."), e.what ()));
829 error_dialog (0, _("An unknown exception occurred. Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."));
832 /* This will terminate the program */
836 void OnUnhandledException ()
838 error_dialog (0, _("An unknown exception occurred. Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."));
843 ui_signaller->ui_idle ();
849 ServerFinder::instance()->rethrow ();
850 } catch (exception& e) {
851 error_dialog (0, std_to_wx (e.what ()));
855 void update_checker_state_changed ()
857 switch (UpdateChecker::instance()->state ()) {
858 case UpdateChecker::YES:
861 if (Config::instance()->check_for_test_updates ()) {
862 test = UpdateChecker::instance()->test ();
864 UpdateDialog* dialog = new UpdateDialog (_frame, UpdateChecker::instance()->stable (), test);
865 dialog->ShowModal ();
869 case UpdateChecker::NO:
870 if (!UpdateChecker::instance()->last_emit_was_first ()) {
871 error_dialog (_frame, _("There are no new versions of DCP-o-matic available."));
874 case UpdateChecker::FAILED:
875 if (!UpdateChecker::instance()->last_emit_was_first ()) {
876 error_dialog (_frame, _("The DCP-o-matic download server could not be contacted."));
884 shared_ptr<wxTimer> _timer;
885 string _film_to_load;
886 string _film_to_create;
887 string _content_to_add;