From 37a7cf86cdd25b8881c030cb62c68ecbe3b2efa3 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 2 Sep 2014 19:39:35 +0100 Subject: Use the DCP-o-matic info dialogue for the batch converter. --- src/tools/dcpomatic_batch.cc | 34 +++++----------------------------- 1 file changed, 5 insertions(+), 29 deletions(-) (limited to 'src') diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 49b341443..234bfea5c 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2013 Carl Hetherington + Copyright (C) 2013-2014 Carl Hetherington 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" @@ -135,34 +136,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 () -- cgit v1.2.3 From 8407612363705f757d3ab26d6e119171c217b00a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 2 Sep 2014 22:09:33 +0100 Subject: Seemingly rather long-winded way of making the JobManagerView in dcpomatic_batch shrink nicely (i.e. shrinking the gauge) when the window is shrunk. It seems surprising that we have to call back to children to tell them to layout / fit-inside, but it does all *seem* to be necessary. --- ChangeLog | 4 ++++ src/tools/dcpomatic_batch.cc | 17 ++++++++++++----- src/wx/job_manager_view.cc | 12 +++++++++++- src/wx/job_manager_view.h | 1 + 4 files changed, 28 insertions(+), 6 deletions(-) (limited to 'src') diff --git a/ChangeLog b/ChangeLog index 9314e4066..54188c26a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-09-02 Carl Hetherington + + * Improve behaviour of batch converter window when it is shrunk (#338). + 2014-09-01 Carl Hetherington * Version 1.73.1 released. diff --git a/src/tools/dcpomatic_batch.cc b/src/tools/dcpomatic_batch.cc index 234bfea5c..de255e65e 100644 --- a/src/tools/dcpomatic_batch.cc +++ b/src/tools/dcpomatic_batch.cc @@ -62,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); @@ -76,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 ()) { @@ -176,6 +182,7 @@ private: } boost::optional _last_parent; + wxSizer* _sizer; }; static const wxCmdLineEntryDesc command_line_description[] = { 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,14 +202,24 @@ 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 j) { 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); void periodic (); + void sized (wxSizeEvent &); wxPanel* _panel; wxFlexGridSizer* _table; -- cgit v1.2.3 From 0390c42a7fc648a116ac3fd0417eac92dfe79f6d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 2 Sep 2014 22:57:44 +0100 Subject: Add a reasonably low timeout to curl fetches. --- src/lib/internet.cc | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src') 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 Date: Wed, 3 Sep 2014 00:28:35 +0100 Subject: Speculative fix for Doremi certificate download on OS X. The while (wxTheApp->Pending ()) wxTheApp->Dispatch() appears to hang on OS X. --- src/lib/ui_signaller.h | 7 +++++++ src/wx/doremi_certificate_dialog.cc | 13 ++++++++++++- src/wx/doremi_certificate_dialog.h | 2 ++ 3 files changed, 21 insertions(+), 1 deletion(-) (limited to 'src') 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 + 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/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 #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 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; }; -- cgit v1.2.3 From fb86361c31c35d7df3dede7b40e4b60e2e7f9c1a Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 3 Sep 2014 00:37:51 +0100 Subject: Similar fix to Dolby cert downloads. --- ChangeLog | 4 ++++ src/wx/dolby_certificate_dialog.cc | 47 +++++++++++++++++++++++++++++++++----- src/wx/dolby_certificate_dialog.h | 4 ++++ src/wx/wx_util.cc | 10 +------- src/wx/wx_util.h | 1 - 5 files changed, 50 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/ChangeLog b/ChangeLog index 54188c26a..d9be8474e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2014-09-03 Carl Hetherington + + * Fix server certificate downloads on OS X (#376). + 2014-09-02 Carl Hetherington * Improve behaviour of batch converter window when it is shrunk (#338). 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 #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 const countries = get_dir (""); _country->Clear (); for (list::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 const cinemas = get_dir (wx_to_std (_country->GetStringSelection())); _cinema->Clear (); for (list::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 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 get_dir (std::string) const; diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc index 218a786b2..23a85534a 100644 --- a/src/wx/wx_util.cc +++ b/src/wx/wx_util.cc @@ -1,5 +1,5 @@ /* - Copyright (C) 2012 Carl Hetherington + Copyright (C) 2012-2014 Carl Hetherington 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 -- cgit v1.2.3 From 42ff121e14f55cbdcff40f7ae488cb9ff7bc6f90 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 3 Sep 2014 22:12:54 +0100 Subject: Better reporting of unknown exceptions in some cases. --- src/tools/dcpomatic.cc | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index 09aebd39c..6b7ad0273 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -798,12 +798,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).")); -- cgit v1.2.3 From 5db632783b3eba64d39538d1f29ccfe26adaaf19 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 3 Sep 2014 22:43:33 +0100 Subject: Update DCP name on change to content video scale. --- src/wx/film_editor.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src') diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 017a9d7c9..f569e0422 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -537,6 +537,8 @@ FilmEditor::film_content_changed (int property) setup_content (); } else if (property == ContentProperty::POSITION) { setup_content (); + } else if (property == VideoContentProperty::VIDEO_SCALE) { + setup_dcp_name (); } } -- cgit v1.2.3 From 4a33cfc3b4c51d4e047879051d70ae56ec8ee6e1 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 3 Sep 2014 23:34:32 +0100 Subject: Put the right 'actual' ratio in DCP titles even with no-stretch and no-scale. --- src/lib/film.cc | 18 +++++++++++------- src/lib/ratio.cc | 17 +++++++++++++++++ src/lib/ratio.h | 1 + 3 files changed, 29 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/lib/film.cc b/src/lib/film.cc index 2701d81b8..b4d12a062 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -580,18 +580,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() != libdcp::TRAILER) { - ContentList cl = content (); Ratio const * content_ratio = 0; - for (ContentList::const_iterator i = cl.begin(); i != cl.end(); ++i) { + ContentList cl = content (); + for (ContentList::iterator i = cl.begin(); i != cl.end(); ++i) { shared_ptr vc = dynamic_pointer_cast (*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/ratio.cc b/src/lib/ratio.cc index 4a5b39a22..554d3c36c 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::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 8b1a1fc71..ab157a9bc 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 all () { return _ratios; } -- cgit v1.2.3