diff options
| author | Carl Hetherington <cth@carlh.net> | 2014-09-04 00:05:04 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2014-09-04 00:05:04 +0100 |
| commit | cb1dfa9ec09af2abf6d10e4bf2764476db83841b (patch) | |
| tree | 5ccd5fd123fa07702b6cf647cedb7df8e8917fa0 /src | |
| parent | dc120d521c740b7f1ec356538139c5769a5f54be (diff) | |
| parent | 4092121ad052f406e8b5c5a2debbd8256321f182 (diff) | |
Merge master.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/film.cc | 16 | ||||
| -rw-r--r-- | src/lib/internet.cc | 4 | ||||
| -rw-r--r-- | src/lib/ratio.cc | 17 | ||||
| -rw-r--r-- | src/lib/ratio.h | 1 | ||||
| -rw-r--r-- | src/lib/ui_signaller.h | 7 | ||||
| -rw-r--r-- | src/tools/dcpomatic.cc | 13 | ||||
| -rw-r--r-- | src/tools/dcpomatic_batch.cc | 51 | ||||
| -rw-r--r-- | src/wx/dcp_panel.cc | 4 | ||||
| -rw-r--r-- | src/wx/dolby_certificate_dialog.cc | 47 | ||||
| -rw-r--r-- | src/wx/dolby_certificate_dialog.h | 4 | ||||
| -rw-r--r-- | src/wx/doremi_certificate_dialog.cc | 13 | ||||
| -rw-r--r-- | src/wx/doremi_certificate_dialog.h | 2 | ||||
| -rw-r--r-- | src/wx/job_manager_view.cc | 12 | ||||
| -rw-r--r-- | src/wx/job_manager_view.h | 1 | ||||
| -rw-r--r-- | src/wx/wx_util.cc | 10 | ||||
| -rw-r--r-- | src/wx/wx_util.h | 1 |
16 files changed, 142 insertions, 61 deletions
diff --git a/src/lib/film.cc b/src/lib/film.cc index 577c29e3a..475dd6844 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -591,18 +591,22 @@ Film::isdcf_name (bool if_created_now) const d << "_" << container()->isdcf_name(); } - /* XXX: this only works for content which has been scaled to a given ratio, - and uses the first bit of content only. - */ + /* XXX: this uses the first bit of content only */ /* The standard says we don't do this for trailers, for some strange reason */ if (dcp_content_type() && dcp_content_type()->libdcp_kind() != dcp::TRAILER) { ContentList cl = content (); Ratio const * content_ratio = 0; - for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) { + for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) { shared_ptr<VideoContent> vc = dynamic_pointer_cast<VideoContent> (*i); - if (vc && (content_ratio == 0 || vc->scale().ratio() != content_ratio)) { - content_ratio = vc->scale().ratio(); + if (vc) { + /* Here's the first piece of video content */ + if (vc->scale().ratio ()) { + content_ratio = vc->scale().ratio (); + } else { + content_ratio = Ratio::from_ratio (vc->video_size().ratio ()); + } + break; } } diff --git a/src/lib/internet.cc b/src/lib/internet.cc index c28e650fd..1c61e96e3 100644 --- a/src/lib/internet.cc +++ b/src/lib/internet.cc @@ -56,6 +56,8 @@ get_from_zip_url (string url, string file, function<void (boost::filesystem::pat curl_easy_setopt (curl, CURLOPT_WRITEFUNCTION, get_from_zip_url_data); curl_easy_setopt (curl, CURLOPT_WRITEDATA, f); curl_easy_setopt (curl, CURLOPT_FTP_USE_EPSV, 0); + /* Maximum time is 20s */ + curl_easy_setopt (curl, CURLOPT_TIMEOUT, 20); CURLcode const cr = curl_easy_perform (curl); @@ -117,6 +119,8 @@ ftp_ls (string url) url += "/"; } curl_easy_setopt (curl, CURLOPT_URL, url.c_str ()); + /* 20s timeout */ + curl_easy_setopt (curl, CURLOPT_TIMEOUT, 20); string ls_raw; struct curl_slist* commands = 0; diff --git a/src/lib/ratio.cc b/src/lib/ratio.cc index bb6963658..fc36415c5 100644 --- a/src/lib/ratio.cc +++ b/src/lib/ratio.cc @@ -56,3 +56,20 @@ Ratio::from_id (string i) return *j; } + +/** @return Ratio corresponding to a given fractional ratio (+/- 0.01), or 0 */ +Ratio const * +Ratio::from_ratio (float r) +{ + vector<Ratio const *>::iterator j = _ratios.begin (); + while (j != _ratios.end() && fabs ((*j)->ratio() - r) > 0.01) { + ++j; + } + + if (j == _ratios.end ()) { + return 0; + } + + return *j; +} + diff --git a/src/lib/ratio.h b/src/lib/ratio.h index 22fc7662c..69e3726c8 100644 --- a/src/lib/ratio.h +++ b/src/lib/ratio.h @@ -52,6 +52,7 @@ public: static void setup_ratios (); static Ratio const * from_id (std::string i); + static Ratio const * from_ratio (float r); static std::vector<Ratio const *> all () { return _ratios; } diff --git a/src/lib/ui_signaller.h b/src/lib/ui_signaller.h index 1d62547f6..ee4d230d4 100644 --- a/src/lib/ui_signaller.h +++ b/src/lib/ui_signaller.h @@ -54,8 +54,15 @@ public: } } + /* Do something next time the UI is idle */ + template <typename T> + void when_idle (T f) { + _service.post (f); + } + /** Call this in the UI when it is idle */ size_t ui_idle () { + /* This executes any functors that have been post()ed to _service */ return _service.poll (); } diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 8763e35cb..3bef7bce3 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -802,12 +802,21 @@ class App : public wxApp return true; } + /* An unhandled exception has occurred inside the main event loop */ bool OnExceptionInMainLoop () { - error_dialog (0, _("An unknown exception occurred. Please report this problem to the DCP-o-matic author (carl@dcpomatic.com).")); + try { + throw; + } catch (exception& e) { + error_dialog (0, wxString::Format (_("An exception occurred (%s). Please report this problem to the DCP-o-matic author (carl@dcpomatic.com)."), e.what ())); + } catch (...) { + error_dialog (0, _("An unknown exception occurred. Please report this problem to the DCP-o-matic author (carl@dcpomatic.com).")); + } + + /* This will terminate the program */ return false; } - + void OnUnhandledException () { error_dialog (0, _("An unknown exception occurred. Please report this problem to the DCP-o-matic author (carl@dcpomatic.com).")); diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 49b341443..de255e65e 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington <cth@carlh.net> + Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -28,6 +28,7 @@ #include "lib/film.h" #include "lib/job_manager.h" #include "wx/wx_util.h" +#include "wx/about_dialog.h" #include "wx/wx_ui_signaller.h" #include "wx/job_manager_view.h" @@ -61,6 +62,7 @@ class Frame : public wxFrame public: Frame (wxString const & title) : wxFrame (NULL, -1, title) + , _sizer (new wxBoxSizer (wxVERTICAL)) { wxMenuBar* bar = new wxMenuBar; setup_menu (bar); @@ -75,24 +77,29 @@ public: s->Add (panel, 1, wxEXPAND); SetSizer (s); - wxSizer* sizer = new wxBoxSizer (wxVERTICAL); - JobManagerView* job_manager_view = new JobManagerView (panel, JobManagerView::PAUSE); - sizer->Add (job_manager_view, 1, wxALL | wxEXPAND, 6); + _sizer->Add (job_manager_view, 1, wxALL | wxEXPAND, 6); wxSizer* buttons = new wxBoxSizer (wxHORIZONTAL); wxButton* add = new wxButton (panel, wxID_ANY, _("Add Film...")); add->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&Frame::add_film, this)); buttons->Add (add, 1, wxALL, 6); - sizer->Add (buttons, 0, wxALL, 6); + _sizer->Add (buttons, 0, wxALL, 6); - panel->SetSizer (sizer); + panel->SetSizer (_sizer); Bind (wxEVT_CLOSE_WINDOW, boost::bind (&Frame::close, this, _1)); + Bind (wxEVT_SIZE, boost::bind (&Frame::sized, this, _1)); } private: + void sized (wxSizeEvent& ev) + { + _sizer->Layout (); + ev.Skip (); + } + bool should_close () { if (!JobManager::instance()->work_to_do ()) { @@ -135,34 +142,9 @@ private: void help_about () { - wxAboutDialogInfo info; - info.SetName (_("DCP-o-matic Batch Converter")); - if (strcmp (dcpomatic_git_commit, "release") == 0) { - info.SetVersion (std_to_wx (String::compose ("version %1", dcpomatic_version))); - } else { - info.SetVersion (std_to_wx (String::compose ("version %1 git %2", dcpomatic_version, dcpomatic_git_commit))); - } - info.SetDescription (_("Free, open-source DCP generation from almost anything.")); - info.SetCopyright (_("(C) 2012-2013 Carl Hetherington, Terrence Meiczinger, Paul Davis, Ole Laursen")); - - wxArrayString authors; - authors.Add (wxT ("Carl Hetherington")); - authors.Add (wxT ("Terrence Meiczinger")); - authors.Add (wxT ("Paul Davis")); - authors.Add (wxT ("Ole Laursen")); - info.SetDevelopers (authors); - - wxArrayString translators; - translators.Add (wxT ("Olivier Perriere")); - translators.Add (wxT ("Lilian Lefranc")); - translators.Add (wxT ("Thierry Journet")); - translators.Add (wxT ("Massimiliano Broggi")); - translators.Add (wxT ("Manuel AC")); - translators.Add (wxT ("Adam Klotblixt")); - info.SetTranslators (translators); - - info.SetWebSite (wxT ("http://carlh.net/software/dcpomatic")); - wxAboutBox (info); + AboutDialog* d = new AboutDialog (this); + d->ShowModal (); + d->Destroy (); } void add_film () @@ -200,6 +182,7 @@ private: } boost::optional<boost::filesystem::path> _last_parent; + wxSizer* _sizer; }; static const wxCmdLineEntryDesc command_line_description[] = { diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index ce02c46c8..d68edefc8 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -311,7 +311,9 @@ DCPPanel::film_changed (int p) void DCPPanel::film_content_changed (int property) { - if (property == FFmpegContentProperty::AUDIO_STREAM || property == SubtitleContentProperty::USE_SUBTITLES) { + if (property == FFmpegContentProperty::AUDIO_STREAM || + property == SubtitleContentProperty::USE_SUBTITLES || + property == VideoContentProperty::VIDEO_SCALE) { setup_dcp_name (); } } diff --git a/src/wx/dolby_certificate_dialog.cc b/src/wx/dolby_certificate_dialog.cc index a05a3bbc7..5e094844d 100644 --- a/src/wx/dolby_certificate_dialog.cc +++ b/src/wx/dolby_certificate_dialog.cc @@ -21,6 +21,7 @@ #include <curl/curl.h> #include "lib/compose.hpp" #include "lib/internet.h" +#include "lib/ui_signaller.h" #include "dolby_certificate_dialog.h" #include "wx_util.h" @@ -74,8 +75,17 @@ DolbyCertificateDialog::setup_countries () _country->Append (_("Fetching...")); _country->SetSelection (0); - run_gui_loop (); - + +#ifdef DCPOMATIC_OSX + /* See DoremiCertificateDialog for discussion about this daft delay */ + wxMilliSleep (200); +#endif + ui_signaller->when_idle (boost::bind (&DolbyCertificateDialog::finish_setup_countries, this)); +} + +void +DolbyCertificateDialog::finish_setup_countries () +{ list<string> const countries = get_dir (""); _country->Clear (); for (list<string>::const_iterator i = countries.begin(); i != countries.end(); ++i) { @@ -89,8 +99,16 @@ DolbyCertificateDialog::country_selected () _cinema->Clear (); _cinema->Append (_("Fetching...")); _cinema->SetSelection (0); - run_gui_loop (); - + +#ifdef DCPOMATIC_OSX + wxMilliSleep (200); +#endif + ui_signaller->when_idle (boost::bind (&DolbyCertificateDialog::finish_country_selected, this)); +} + +void +DolbyCertificateDialog::finish_country_selected () +{ list<string> const cinemas = get_dir (wx_to_std (_country->GetStringSelection())); _cinema->Clear (); for (list<string>::const_iterator i = cinemas.begin(); i != cinemas.end(); ++i) { @@ -104,8 +122,16 @@ DolbyCertificateDialog::cinema_selected () _serial->Clear (); _serial->Append (_("Fetching...")); _serial->SetSelection (0); - run_gui_loop (); +#ifdef DCPOMATIC_OSX + wxMilliSleep (200); +#endif + ui_signaller->when_idle (boost::bind (&DolbyCertificateDialog::finish_cinema_selected, this)); +} + +void +DolbyCertificateDialog::finish_cinema_selected () +{ string const dir = String::compose ("%1/%2", wx_to_std (_country->GetStringSelection()), wx_to_std (_cinema->GetStringSelection())); list<string> const zips = get_dir (dir); @@ -129,8 +155,17 @@ void DolbyCertificateDialog::download () { _message->SetLabel (_("Downloading certificate")); - run_gui_loop (); +#ifdef DCPOMATIC_OSX + wxMilliSleep (200); +#endif + + ui_signaller->when_idle (boost::bind (&DolbyCertificateDialog::finish_download, this)); +} + +void +DolbyCertificateDialog::finish_download () +{ string const zip = string_client_data (_serial->GetClientObject (_serial->GetSelection ())); string const file = String::compose ( diff --git a/src/wx/dolby_certificate_dialog.h b/src/wx/dolby_certificate_dialog.h index 194150363..e9bbffda0 100644 --- a/src/wx/dolby_certificate_dialog.h +++ b/src/wx/dolby_certificate_dialog.h @@ -27,9 +27,13 @@ public: private: void download (); + void finish_download (); void setup_countries (); + void finish_setup_countries (); void country_selected (); + void finish_country_selected (); void cinema_selected (); + void finish_cinema_selected (); void serial_selected (); std::list<std::string> get_dir (std::string) const; diff --git a/src/wx/doremi_certificate_dialog.cc b/src/wx/doremi_certificate_dialog.cc index b4cd14eaf..4b5d58b37 100644 --- a/src/wx/doremi_certificate_dialog.cc +++ b/src/wx/doremi_certificate_dialog.cc @@ -21,6 +21,7 @@ #include <zip.h> #include "lib/compose.hpp" #include "lib/util.h" +#include "lib/ui_signaller.h" #include "lib/internet.h" #include "doremi_certificate_dialog.h" #include "wx_util.h" @@ -51,8 +52,18 @@ DoremiCertificateDialog::download () } _message->SetLabel (_("Downloading certificate")); - run_gui_loop (); +#ifdef DCPOMATIC_OSX + /* This is necessary on OS X, otherwise the SetLabel() above has no visible effect */ + wxMilliSleep (200); +#endif + + ui_signaller->when_idle (boost::bind (&DoremiCertificateDialog::finish_download, this, serial)); +} + +void +DoremiCertificateDialog::finish_download (string serial) +{ /* Try dcp2000, imb and ims prefixes (see mantis #375) */ optional<string> error = get_from_zip_url ( diff --git a/src/wx/doremi_certificate_dialog.h b/src/wx/doremi_certificate_dialog.h index 281184726..b249736ec 100644 --- a/src/wx/doremi_certificate_dialog.h +++ b/src/wx/doremi_certificate_dialog.h @@ -28,5 +28,7 @@ private: void download (); void set_sensitivity (); + void finish_download (std::string serial); + wxTextCtrl* _serial; }; diff --git a/src/wx/job_manager_view.cc b/src/wx/job_manager_view.cc index df9c6f5f1..5146243b4 100644 --- a/src/wx/job_manager_view.cc +++ b/src/wx/job_manager_view.cc @@ -202,15 +202,25 @@ JobManagerView::JobManagerView (wxWindow* parent, Buttons buttons) _panel->SetSizer (_table); SetScrollRate (0, 32); + EnableScrolling (false, true); Bind (wxEVT_TIMER, boost::bind (&JobManagerView::periodic, this)); _timer.reset (new wxTimer (this)); _timer->Start (1000); - + + Bind (wxEVT_SIZE, boost::bind (&JobManagerView::sized, this, _1)); JobManager::instance()->JobAdded.connect (bind (&JobManagerView::job_added, this, _1)); } void +JobManagerView::sized (wxSizeEvent& ev) +{ + _table->FitInside (_panel); + _table->Layout (); + ev.Skip (); +} + +void JobManagerView::job_added (weak_ptr<Job> j) { shared_ptr<Job> job = j.lock (); diff --git a/src/wx/job_manager_view.h b/src/wx/job_manager_view.h index c4bb1e218..83ce4ee5a 100644 --- a/src/wx/job_manager_view.h +++ b/src/wx/job_manager_view.h @@ -43,6 +43,7 @@ public: private: void job_added (boost::weak_ptr<Job>); void periodic (); + void sized (wxSizeEvent &); wxPanel* _panel; wxFlexGridSizer* _table; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 94a08f372..cf8b75dd2 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington <cth@carlh.net> + Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -312,14 +312,6 @@ wx_get (wxSpinCtrlDouble* w) return w->GetValue (); } -void -run_gui_loop () -{ - while (wxTheApp->Pending ()) { - wxTheApp->Dispatch (); - } -} - /** @param s String of the form Context|String * @return translation, or String if no translation is available. */ diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index 6dfc0bf5c..f0e20be95 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -63,7 +63,6 @@ extern wxStaticText* add_label_to_grid_bag_sizer (wxGridBagSizer *, wxWindow *, extern std::string wx_to_std (wxString); extern wxString std_to_wx (std::string); extern void dcpomatic_setup_i18n (); -extern void run_gui_loop (); extern wxString context_translation (wxString); /** @class ThreadedStaticText |
