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.
21 #include "lib/config.h"
23 #include "lib/version.h"
24 #include "lib/ui_signaller.h"
26 #include "lib/job_manager.h"
27 #include "lib/transcode_job.h"
28 #include "lib/exceptions.h"
29 #include "lib/cinema.h"
31 #include "lib/send_kdm_email_job.h"
32 #include "lib/server_finder.h"
33 #include "lib/update.h"
34 #include "lib/content_factory.h"
35 #include "wx/film_viewer.h"
36 #include "wx/film_editor.h"
37 #include "wx/job_manager_view.h"
38 #include "wx/config_dialog.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"
50 #include <dcp/exceptions.h>
51 #include <wx/generic/aboutdlgg.h>
52 #include <wx/stdpaths.h>
53 #include <wx/cmdline.h>
54 #include <wx/preferences.h>
59 #include <ApplicationServices/ApplicationServices.h>
61 #include <boost/filesystem.hpp>
77 using boost::shared_ptr;
78 using boost::dynamic_pointer_cast;
80 class FilmChangedDialog
83 FilmChangedDialog (string name)
85 _dialog = new wxMessageDialog (
87 wxString::Format (_("Save changes to film \"%s\" before closing?"), std_to_wx (name).data()),
88 /* TRANSLATORS: this is the heading for a dialog box, which tells the user that the current
89 project (Film) has been changed since it was last saved.
92 wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
103 return _dialog->ShowModal ();
108 FilmChangedDialog (FilmChangedDialog const &);
110 wxMessageDialog* _dialog;
114 #define NEEDS_FILM 0x1
115 #define NOT_DURING_DCP_CREATION 0x2
116 #define NEEDS_CPL 0x4
117 #define NEEDS_SELECTED_VIDEO_CONTENT 0x8
119 map<wxMenuItem*, int> menu_items;
127 /* Allow spare IDs after _history for the recent files list */
128 ID_content_scale_to_fit_width = 100,
129 ID_content_scale_to_fit_height,
132 ID_jobs_send_dcp_to_tms,
135 ID_tools_encoding_servers,
136 ID_tools_check_for_updates,
137 ID_help_report_a_problem,
138 /* IDs for shortcuts (with no associated menu item) */
142 class Frame : public wxFrame
145 Frame (wxString const & title)
146 : wxFrame (NULL, -1, title)
148 , _servers_list_dialog (0)
152 , _history_position (0)
153 , _history_separator (0)
155 #if defined(DCPOMATIC_WINDOWS)
156 if (Config::instance()->win32_console ()) {
159 HANDLE handle_out = GetStdHandle(STD_OUTPUT_HANDLE);
160 int hCrt = _open_osfhandle((intptr_t) handle_out, _O_TEXT);
161 FILE* hf_out = _fdopen(hCrt, "w");
162 setvbuf(hf_out, NULL, _IONBF, 1);
165 HANDLE handle_in = GetStdHandle(STD_INPUT_HANDLE);
166 hCrt = _open_osfhandle((intptr_t) handle_in, _O_TEXT);
167 FILE* hf_in = _fdopen(hCrt, "r");
168 setvbuf(hf_in, NULL, _IONBF, 128);
171 cout << "DCP-o-matic is starting." << "\n";
175 wxMenuBar* bar = new wxMenuBar;
179 _config_changed_connection = Config::instance()->Changed.connect (boost::bind (&Frame::config_changed, this));
182 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_new, this), ID_file_new);
183 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_open, this), ID_file_open);
184 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_save, this), ID_file_save);
185 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_properties, this), ID_file_properties);
186 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE);
187 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::file_exit, this), wxID_EXIT);
188 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::edit_preferences, this), wxID_PREFERENCES);
189 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::content_scale_to_fit_width, this), ID_content_scale_to_fit_width);
190 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::content_scale_to_fit_height, this), ID_content_scale_to_fit_height);
191 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_dcp, this), ID_jobs_make_dcp);
192 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_make_kdms, this), ID_jobs_make_kdms);
193 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_send_dcp_to_tms, this), ID_jobs_send_dcp_to_tms);
194 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::jobs_show_dcp, this), ID_jobs_show_dcp);
195 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_hints, this), ID_tools_hints);
196 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_encoding_servers, this), ID_tools_encoding_servers);
197 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::tools_check_for_updates, this), ID_tools_check_for_updates);
198 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_about, this), wxID_ABOUT);
199 Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&Frame::help_report_a_problem, this), ID_help_report_a_problem);
201 Bind (wxEVT_CLOSE_WINDOW, boost::bind (&Frame::close, this, _1));
203 /* Use a panel as the only child of the Frame so that we avoid
204 the dark-grey background on Windows.
206 wxPanel* overall_panel = new wxPanel (this, wxID_ANY);
208 _film_editor = new FilmEditor (overall_panel);
209 _film_viewer = new FilmViewer (overall_panel);
210 JobManagerView* job_manager_view = new JobManagerView (overall_panel);
212 wxBoxSizer* right_sizer = new wxBoxSizer (wxVERTICAL);
213 right_sizer->Add (_film_viewer, 2, wxEXPAND | wxALL, 6);
214 right_sizer->Add (job_manager_view, 1, wxEXPAND | wxALL, 6);
216 wxBoxSizer* main_sizer = new wxBoxSizer (wxHORIZONTAL);
217 main_sizer->Add (_film_editor, 1, wxEXPAND | wxALL, 6);
218 main_sizer->Add (right_sizer, 2, wxEXPAND | wxALL, 6);
220 set_menu_sensitivity ();
222 _film_editor->FileChanged.connect (bind (&Frame::file_changed, this, _1));
225 JobManager::instance()->ActiveJobsChanged.connect (boost::bind (&Frame::set_menu_sensitivity, this));
227 overall_panel->SetSizer (main_sizer);
229 wxAcceleratorEntry accel[1];
230 accel[0].Set (wxACCEL_CTRL, static_cast<int>('A'), ID_add_file);
231 Bind (wxEVT_MENU, boost::bind (&ContentPanel::add_file_clicked, _film_editor->content_panel()), ID_add_file);
232 wxAcceleratorTable accel_table (1, accel);
233 SetAcceleratorTable (accel_table);
236 void new_film (boost::filesystem::path path)
238 shared_ptr<Film> film (new Film (path));
239 film->write_metadata ();
240 film->set_name (path.filename().generic_string());
244 void load_film (boost::filesystem::path file)
247 maybe_save_then_delete_film ();
249 shared_ptr<Film> film (new Film (file));
250 list<string> const notes = film->read_metadata ();
252 if (film->state_version() == 4) {
255 _("This film was created with an old version of DVD-o-matic and may not load correctly "
256 "in this version. Please check the film's settings carefully.")
260 for (list<string>::const_iterator i = notes.begin(); i != notes.end(); ++i) {
261 error_dialog (0, std_to_wx (*i));
266 catch (std::exception& e) {
267 wxString p = std_to_wx (file.string ());
268 wxCharBuffer b = p.ToUTF8 ();
269 error_dialog (this, wxString::Format (_("Could not open film at %s (%s)"), p.data(), std_to_wx (e.what()).data()));
272 void set_film (shared_ptr<Film> film)
275 _film_viewer->set_film (_film);
276 _film_editor->set_film (_film);
277 set_menu_sensitivity ();
278 Config::instance()->add_to_history (_film->directory ());
281 shared_ptr<Film> film () const {
287 void file_changed (boost::filesystem::path f)
289 string s = wx_to_std (_("DCP-o-matic"));
291 s += " - " + f.string ();
294 SetTitle (std_to_wx (s));
299 NewFilmDialog* d = new NewFilmDialog (this);
300 int const r = d->ShowModal ();
304 if (boost::filesystem::is_directory (d->get_path()) && !boost::filesystem::is_empty(d->get_path())) {
305 if (!confirm_dialog (
308 String::compose (wx_to_std (_("The directory %1 already exists and is not empty. "
309 "Are you sure you want to use it?")),
310 d->get_path().string().c_str())
315 } else if (boost::filesystem::is_regular_file (d->get_path())) {
318 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())
323 maybe_save_then_delete_film ();
324 new_film (d->get_path ());
332 wxDirDialog* c = new wxDirDialog (
334 _("Select film to open"),
335 std_to_wx (Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())).string ()),
336 wxDEFAULT_DIALOG_STYLE | wxDD_DIR_MUST_EXIST
342 if (r == wxID_OK && c->GetPath() == wxStandardPaths::Get().GetDocumentsDir()) {
343 error_dialog (this, _("You did not select a folder. Make sure that you select a folder before clicking Open."));
350 load_film (wx_to_std (c->GetPath ()));
358 _film->write_metadata ();
361 void file_properties ()
363 PropertiesDialog* d = new PropertiesDialog (this, _film);
368 void file_history (wxCommandEvent& event)
370 vector<boost::filesystem::path> history = Config::instance()->history ();
371 int n = event.GetId() - ID_file_history;
372 if (n >= 0 && n < static_cast<int> (history.size ())) {
373 load_film (history[n]);
379 /* false here allows the close handler to veto the close request */
383 void edit_preferences ()
385 if (!_config_dialog) {
386 _config_dialog = create_config_dialog ();
388 _config_dialog->Show (this);
391 void jobs_make_dcp ()
396 if (!_film->should_be_enough_disk_space (required, available)) {
397 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))) {
404 } catch (BadSettingError& e) {
405 error_dialog (this, wxString::Format (_("Bad setting for %s (%s)"), std_to_wx(e.setting()).data(), std_to_wx(e.what()).data()));
406 } catch (std::exception& e) {
407 error_dialog (this, wxString::Format (_("Could not make DCP: %s"), std_to_wx(e.what()).data()));
411 void jobs_make_kdms ()
417 KDMDialog* d = new KDMDialog (this, _film);
418 if (d->ShowModal () != wxID_OK) {
424 if (d->write_to ()) {
425 write_kdm_files (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation (), d->directory ());
427 JobManager::instance()->add (
428 shared_ptr<Job> (new SendKDMEmailJob (_film, d->screens (), d->cpl (), d->from (), d->until (), d->formulation ()))
431 } catch (dcp::NotEncryptedError& e) {
432 error_dialog (this, _("CPL's content is not encrypted."));
433 } catch (exception& e) {
434 error_dialog (this, e.what ());
436 error_dialog (this, _("An unknown exception occurred."));
442 void content_scale_to_fit_width ()
444 VideoContentList vc = _film_editor->content_panel()->selected_video ();
445 for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
446 (*i)->scale_and_crop_to_fit_width ();
450 void content_scale_to_fit_height ()
452 VideoContentList vc = _film_editor->content_panel()->selected_video ();
453 for (VideoContentList::iterator i = vc.begin(); i != vc.end(); ++i) {
454 (*i)->scale_and_crop_to_fit_height ();
458 void jobs_send_dcp_to_tms ()
460 _film->send_dcp_to_tms ();
463 void jobs_show_dcp ()
466 string d = _film->directory().string ();
468 w.assign (d.begin(), d.end());
469 ShellExecute (0, L"open", w.c_str(), 0, 0, SW_SHOWDEFAULT);
471 int r = system ("which nautilus");
472 if (WEXITSTATUS (r) == 0) {
473 r = system (string ("nautilus " + _film->directory().string()).c_str ());
474 if (WEXITSTATUS (r)) {
475 error_dialog (this, _("Could not show DCP (could not run nautilus)"));
478 int r = system ("which konqueror");
479 if (WEXITSTATUS (r) == 0) {
480 r = system (string ("konqueror " + _film->directory().string()).c_str ());
481 if (WEXITSTATUS (r)) {
482 error_dialog (this, _("Could not show DCP (could not run konqueror)"));
491 if (!_hints_dialog) {
492 _hints_dialog = new HintsDialog (this, _film);
495 _hints_dialog->Show ();
498 void tools_encoding_servers ()
500 if (!_servers_list_dialog) {
501 _servers_list_dialog = new ServersListDialog (this);
504 _servers_list_dialog->Show ();
507 void tools_check_for_updates ()
509 UpdateChecker::instance()->run ();
514 AboutDialog* d = new AboutDialog (this);
519 void help_report_a_problem ()
521 ReportProblemDialog* d = new ReportProblemDialog (this, _film);
522 if (d->ShowModal () == wxID_OK) {
530 if (!JobManager::instance()->work_to_do ()) {
534 wxMessageDialog* d = new wxMessageDialog (
536 _("There are unfinished jobs; are you sure you want to quit?"),
537 _("Unfinished jobs"),
538 wxYES_NO | wxYES_DEFAULT | wxICON_QUESTION
541 bool const r = d->ShowModal() == wxID_YES;
546 void close (wxCloseEvent& ev)
548 if (!should_close ()) {
553 /* We don't want to hear about any more configuration changes, since they
554 cause the File menu to be altered, which itself will be deleted around
555 now (without, as far as I can see, any way for us to find out).
557 _config_changed_connection.disconnect ();
559 maybe_save_then_delete_film ();
563 void set_menu_sensitivity ()
565 list<shared_ptr<Job> > jobs = JobManager::instance()->get ();
566 list<shared_ptr<Job> >::iterator i = jobs.begin();
567 while (i != jobs.end() && dynamic_pointer_cast<TranscodeJob> (*i) == 0) {
570 bool const dcp_creation = (i != jobs.end ()) && !(*i)->finished ();
571 bool const have_cpl = _film && !_film->cpls().empty ();
572 bool const have_selected_video_content = !_film_editor->content_panel()->selected_video().empty();
574 for (map<wxMenuItem*, int>::iterator j = menu_items.begin(); j != menu_items.end(); ++j) {
578 if ((j->second & NEEDS_FILM) && !_film) {
582 if ((j->second & NOT_DURING_DCP_CREATION) && dcp_creation) {
586 if ((j->second & NEEDS_CPL) && !have_cpl) {
590 if ((j->second & NEEDS_SELECTED_VIDEO_CONTENT) && !have_selected_video_content) {
594 j->first->Enable (enabled);
598 void maybe_save_then_delete_film ()
604 if (_film->dirty ()) {
605 FilmChangedDialog d (_film->name ());
610 _film->write_metadata ();
618 void add_item (wxMenu* menu, wxString text, int id, int sens)
620 wxMenuItem* item = menu->Append (id, text);
621 menu_items.insert (make_pair (item, sens));
624 void setup_menu (wxMenuBar* m)
626 _file_menu = new wxMenu;
627 add_item (_file_menu, _("New...\tCtrl-N"), ID_file_new, ALWAYS);
628 add_item (_file_menu, _("&Open...\tCtrl-O"), ID_file_open, ALWAYS);
629 _file_menu->AppendSeparator ();
630 add_item (_file_menu, _("&Save\tCtrl-S"), ID_file_save, NEEDS_FILM);
631 _file_menu->AppendSeparator ();
632 add_item (_file_menu, _("&Properties..."), ID_file_properties, NEEDS_FILM);
634 _history_position = _file_menu->GetMenuItems().GetCount();
637 _file_menu->AppendSeparator ();
641 add_item (_file_menu, _("&Exit"), wxID_EXIT, ALWAYS);
643 add_item (_file_menu, _("&Quit"), wxID_EXIT, ALWAYS);
647 add_item (_file_menu, _("&Preferences...\tCtrl-P"), wxID_PREFERENCES, ALWAYS);
649 wxMenu* edit = new wxMenu;
650 add_item (edit, _("&Preferences...\tCtrl-P"), wxID_PREFERENCES, ALWAYS);
653 wxMenu* content = new wxMenu;
654 add_item (content, _("Scale to fit &width"), ID_content_scale_to_fit_width, NEEDS_FILM | NEEDS_SELECTED_VIDEO_CONTENT);
655 add_item (content, _("Scale to fit &height"), ID_content_scale_to_fit_height, NEEDS_FILM | NEEDS_SELECTED_VIDEO_CONTENT);
657 wxMenu* jobs_menu = new wxMenu;
658 add_item (jobs_menu, _("&Make DCP\tCtrl-M"), ID_jobs_make_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION);
659 add_item (jobs_menu, _("Make &KDMs...\tCtrl-K"), ID_jobs_make_kdms, NEEDS_FILM);
660 add_item (jobs_menu, _("&Send DCP to TMS"), ID_jobs_send_dcp_to_tms, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL);
661 add_item (jobs_menu, _("S&how DCP"), ID_jobs_show_dcp, NEEDS_FILM | NOT_DURING_DCP_CREATION | NEEDS_CPL);
663 wxMenu* tools = new wxMenu;
664 add_item (tools, _("Hints...\tCtrl-H"), ID_tools_hints, 0);
665 add_item (tools, _("Encoding servers..."), ID_tools_encoding_servers, 0);
666 add_item (tools, _("Check for updates"), ID_tools_check_for_updates, 0);
668 wxMenu* help = new wxMenu;
670 add_item (help, _("About DCP-o-matic"), wxID_ABOUT, ALWAYS);
672 add_item (help, _("About"), wxID_ABOUT, ALWAYS);
674 add_item (help, _("Report a problem..."), ID_help_report_a_problem, ALWAYS);
676 m->Append (_file_menu, _("&File"));
678 m->Append (edit, _("&Edit"));
680 m->Append (content, _("&Content"));
681 m->Append (jobs_menu, _("&Jobs"));
682 m->Append (tools, _("&Tools"));
683 m->Append (help, _("&Help"));
686 void config_changed ()
688 for (int i = 0; i < _history_items; ++i) {
689 delete _file_menu->Remove (ID_file_history + i);
692 if (_history_separator) {
693 _file_menu->Remove (_history_separator);
695 delete _history_separator;
696 _history_separator = 0;
698 int pos = _history_position;
700 vector<boost::filesystem::path> history = Config::instance()->history ();
702 if (!history.empty ()) {
703 _history_separator = _file_menu->InsertSeparator (pos++);
706 for (size_t i = 0; i < history.size(); ++i) {
709 s << "&" << (i + 1) << " ";
711 s << history[i].string();
712 _file_menu->Insert (pos++, ID_file_history + i, std_to_wx (s.str ()));
715 _history_items = history.size ();
718 FilmEditor* _film_editor;
719 FilmViewer* _film_viewer;
720 HintsDialog* _hints_dialog;
721 ServersListDialog* _servers_list_dialog;
722 wxPreferencesEditor* _config_dialog;
724 shared_ptr<Film> _film;
726 int _history_position;
727 wxMenuItem* _history_separator;
728 boost::signals2::scoped_connection _config_changed_connection;
731 static const wxCmdLineEntryDesc command_line_description[] = {
732 { wxCMD_LINE_SWITCH, "n", "new", "create new film", wxCMD_LINE_VAL_NONE, wxCMD_LINE_PARAM_OPTIONAL },
733 { wxCMD_LINE_OPTION, "c", "content", "add content file", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
734 { wxCMD_LINE_PARAM, 0, 0, "film to load or create", wxCMD_LINE_VAL_STRING, wxCMD_LINE_PARAM_OPTIONAL },
735 { wxCMD_LINE_NONE, "", "", "", wxCmdLineParamType (0), 0 }
739 * @brief The magic App class for wxWidgets.
741 class App : public wxApp
746 SetAppName (_("DCP-o-matic"));
748 if (!wxApp::OnInit()) {
752 #ifdef DCPOMATIC_LINUX
753 unsetenv ("UBUNTU_MENUPROXY");
757 ProcessSerialNumber serial;
758 GetCurrentProcess (&serial);
759 TransformProcessType (&serial, kProcessTransformToForegroundApplication);
762 wxInitAllImageHandlers ();
764 /* Enable i18n; this will create a Config object
765 to look for a force-configured language. This Config
766 object will be wrong, however, because dcpomatic_setup
767 hasn't yet been called and there aren't any scalers, filters etc.
770 dcpomatic_setup_i18n ();
772 /* Set things up, including scalers / filters etc.
773 which will now be internationalised correctly.
777 /* Force the configuration to be re-loaded correctly next
782 _frame = new Frame (_("DCP-o-matic"));
783 SetTopWindow (_frame);
787 if (!_film_to_load.empty() && boost::filesystem::is_directory (_film_to_load)) {
789 _frame->load_film (_film_to_load);
790 } catch (exception& e) {
791 error_dialog (0, std_to_wx (String::compose (wx_to_std (_("Could not load film %1 (%2)")), _film_to_load, e.what())));
795 if (!_film_to_create.empty ()) {
796 _frame->new_film (_film_to_create);
797 if (!_content_to_add.empty ()) {
798 _frame->film()->examine_and_add_content (content_factory (_frame->film(), _content_to_add), true);
802 ui_signaller = new wxUISignaller (this);
803 Bind (wxEVT_IDLE, boost::bind (&App::idle, this));
805 Bind (wxEVT_TIMER, boost::bind (&App::check, this));
806 _timer.reset (new wxTimer (this));
807 _timer->Start (1000);
809 UpdateChecker::instance()->StateChanged.connect (boost::bind (&App::update_checker_state_changed, this));
810 if (Config::instance()->check_for_updates ()) {
811 UpdateChecker::instance()->run ();
818 error_dialog (0, wxString::Format ("DCP-o-matic could not start: %s", e.what ()));
822 void OnInitCmdLine (wxCmdLineParser& parser)
824 parser.SetDesc (command_line_description);
825 parser.SetSwitchChars (wxT ("-"));
828 bool OnCmdLineParsed (wxCmdLineParser& parser)
830 if (parser.GetParamCount() > 0) {
831 if (parser.Found (wxT ("new"))) {
832 _film_to_create = wx_to_std (parser.GetParam (0));
834 _film_to_load = wx_to_std (parser.GetParam (0));
839 if (parser.Found (wxT ("content"), &content)) {
840 _content_to_add = wx_to_std (content);
846 /* An unhandled exception has occurred inside the main event loop */
847 bool OnExceptionInMainLoop ()
851 } catch (FileError& e) {
852 error_dialog (0, wxString::Format (_("An exception occurred: %s in %s.\n\n" + REPORT_PROBLEM), e.what(), e.file().string().c_str ()));
853 } catch (exception& e) {
854 error_dialog (0, wxString::Format (_("An exception occurred: %s.\n\n"), e.what ()) + " " + REPORT_PROBLEM);
856 error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
859 /* This will terminate the program */
863 void OnUnhandledException ()
865 error_dialog (0, _("An unknown exception occurred.") + " " + REPORT_PROBLEM);
870 ui_signaller->ui_idle ();
876 ServerFinder::instance()->rethrow ();
877 } catch (exception& e) {
878 error_dialog (0, std_to_wx (e.what ()));
882 void update_checker_state_changed ()
884 switch (UpdateChecker::instance()->state ()) {
885 case UpdateChecker::YES:
888 if (Config::instance()->check_for_test_updates ()) {
889 test = UpdateChecker::instance()->test ();
891 UpdateDialog* dialog = new UpdateDialog (_frame, UpdateChecker::instance()->stable (), test);
892 dialog->ShowModal ();
896 case UpdateChecker::NO:
897 if (!UpdateChecker::instance()->last_emit_was_first ()) {
898 error_dialog (_frame, _("There are no new versions of DCP-o-matic available."));
901 case UpdateChecker::FAILED:
902 if (!UpdateChecker::instance()->last_emit_was_first ()) {
903 error_dialog (_frame, _("The DCP-o-matic download server could not be contacted."));
911 shared_ptr<wxTimer> _timer;
912 string _film_to_load;
913 string _film_to_create;
914 string _content_to_add;