From: Carl Hetherington Date: Wed, 24 Aug 2016 10:16:24 +0000 (+0100) Subject: Bump libdcp for new method. X-Git-Tag: v2.9.16~17 X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=commitdiff_plain;h=3412af70b950dcdc604413ef05c26becda6da789;hp=a26b6e9e392a1ac342a19e0d33d92865819c6ded Bump libdcp for new method. --- diff --git a/cscript b/cscript index e4a68a53f..137781398 100644 --- a/cscript +++ b/cscript @@ -237,7 +237,7 @@ def dependencies(target): ffmpeg_options = {} return (('ffmpeg-cdist', '1d4a1a4', ffmpeg_options), - ('libdcp', 'c178a9d'), + ('libdcp', '04def4c'), ('libsub', '067c21c')) def configure_options(target): diff --git a/src/lib/atmos_mxf_content.cc b/src/lib/atmos_mxf_content.cc index f8cc05178..2fd9ead06 100644 --- a/src/lib/atmos_mxf_content.cc +++ b/src/lib/atmos_mxf_content.cc @@ -79,10 +79,10 @@ AtmosMXFContent::summary () const } void -AtmosMXFContent::as_xml (xmlpp::Node* node) const +AtmosMXFContent::as_xml (xmlpp::Node* node, bool with_paths) const { node->add_child("Type")->add_child_text ("AtmosMXF"); - Content::as_xml (node); + Content::as_xml (node, with_paths); } DCPTime diff --git a/src/lib/atmos_mxf_content.h b/src/lib/atmos_mxf_content.h index 10c969a7d..0f5225c2e 100644 --- a/src/lib/atmos_mxf_content.h +++ b/src/lib/atmos_mxf_content.h @@ -32,7 +32,7 @@ public: void examine (boost::shared_ptr job); std::string summary () const; - void as_xml (xmlpp::Node* node) const; + void as_xml (xmlpp::Node* node, bool with_path) const; DCPTime full_length () const; static bool valid_mxf (boost::filesystem::path path); diff --git a/src/lib/config.cc b/src/lib/config.cc index 4184a7d1d..383ffdbd6 100644 --- a/src/lib/config.cc +++ b/src/lib/config.cc @@ -588,3 +588,11 @@ Config::set_cinemas_file (boost::filesystem::path file) changed (OTHER); } + +void +Config::save_template (shared_ptr film, string name) const +{ + boost::filesystem::create_directories (path ("templates")); + shared_ptr doc = film->metadata (false); + doc->write_to_file_formatted (path("templates") / tidy_for_filename (name)); +} diff --git a/src/lib/config.h b/src/lib/config.h index a988cda6b..3df5c3795 100644 --- a/src/lib/config.h +++ b/src/lib/config.h @@ -514,6 +514,8 @@ public: void write () const; + void save_template (boost::shared_ptr film, std::string name) const; + static Config* instance (); static void drop (); static void restore_defaults (); diff --git a/src/lib/content.cc b/src/lib/content.cc index 9083635f2..a27032e9c 100644 --- a/src/lib/content.cc +++ b/src/lib/content.cc @@ -135,12 +135,14 @@ Content::Content (shared_ptr film, vector > c) } void -Content::as_xml (xmlpp::Node* node) const +Content::as_xml (xmlpp::Node* node, bool with_paths) const { boost::mutex::scoped_lock lm (_mutex); - for (vector::const_iterator i = _paths.begin(); i != _paths.end(); ++i) { - node->add_child("Path")->add_child_text (i->string ()); + if (with_paths) { + for (vector::const_iterator i = _paths.begin(); i != _paths.end(); ++i) { + node->add_child("Path")->add_child_text (i->string ()); + } } node->add_child("Digest")->add_child_text (_digest); node->add_child("Position")->add_child_text (raw_convert (_position.get ())); diff --git a/src/lib/content.h b/src/lib/content.h index f8b5493c0..e126c994b 100644 --- a/src/lib/content.h +++ b/src/lib/content.h @@ -86,7 +86,7 @@ public: */ virtual std::string technical_summary () const; - virtual void as_xml (xmlpp::Node *) const; + virtual void as_xml (xmlpp::Node *, bool with_paths) const; virtual DCPTime full_length () const = 0; virtual std::string identifier () const; /** @return points at which to split this content when diff --git a/src/lib/dcp_content.cc b/src/lib/dcp_content.cc index 03e6f1aaa..5cacc824a 100644 --- a/src/lib/dcp_content.cc +++ b/src/lib/dcp_content.cc @@ -192,7 +192,7 @@ DCPContent::technical_summary () const } void -DCPContent::as_xml (xmlpp::Node* node) const +DCPContent::as_xml (xmlpp::Node* node, bool with_paths) const { node->add_child("Type")->add_child_text ("DCP"); diff --git a/src/lib/dcp_content.h b/src/lib/dcp_content.h index f3a8236a2..79c35d0e8 100644 --- a/src/lib/dcp_content.h +++ b/src/lib/dcp_content.h @@ -62,7 +62,7 @@ public: void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; - void as_xml (xmlpp::Node *) const; + void as_xml (xmlpp::Node *, bool with_paths) const; std::string identifier () const; void set_default_colour_conversion (); diff --git a/src/lib/ffmpeg_content.cc b/src/lib/ffmpeg_content.cc index b5c5ce0a8..bc913a9ae 100644 --- a/src/lib/ffmpeg_content.cc +++ b/src/lib/ffmpeg_content.cc @@ -181,10 +181,10 @@ FFmpegContent::FFmpegContent (shared_ptr film, vectoradd_child("Type")->add_child_text ("FFmpeg"); - Content::as_xml (node); + Content::as_xml (node, with_paths); if (video) { video->as_xml (node); diff --git a/src/lib/ffmpeg_content.h b/src/lib/ffmpeg_content.h index 666322669..b341aa012 100644 --- a/src/lib/ffmpeg_content.h +++ b/src/lib/ffmpeg_content.h @@ -57,7 +57,7 @@ public: void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; - void as_xml (xmlpp::Node *) const; + void as_xml (xmlpp::Node *, bool with_paths) const; DCPTime full_length () const; std::string identifier () const; diff --git a/src/lib/film.cc b/src/lib/film.cc index edb911217..31c47540f 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -329,7 +329,7 @@ Film::send_dcp_to_tms () } shared_ptr -Film::metadata () const +Film::metadata (bool with_content_paths) const { shared_ptr doc (new xmlpp::Document); xmlpp::Element* root = doc->create_root_node ("Metadata"); @@ -364,7 +364,7 @@ Film::metadata () const root->add_child("ReelType")->add_child_text (raw_convert (static_cast (_reel_type))); root->add_child("ReelLength")->add_child_text (raw_convert (_reel_length)); root->add_child("UploadAfterMakeDCP")->add_child_text (_upload_after_make_dcp ? "1" : "0"); - _playlist->as_xml (root->add_child ("Playlist")); + _playlist->as_xml (root->add_child ("Playlist"), with_content_paths); return doc; } diff --git a/src/lib/film.h b/src/lib/film.h index 82d1f78c0..abe5c214f 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -93,7 +93,7 @@ public: std::list read_metadata (); void write_metadata () const; - boost::shared_ptr metadata () const; + boost::shared_ptr metadata (bool with_content_paths = true) const; std::string isdcf_name (bool if_created_now) const; std::string dcp_name (bool if_created_now = false) const; diff --git a/src/lib/image_content.cc b/src/lib/image_content.cc index 825f6da25..b27483978 100644 --- a/src/lib/image_content.cc +++ b/src/lib/image_content.cc @@ -100,10 +100,10 @@ ImageContent::technical_summary () const } void -ImageContent::as_xml (xmlpp::Node* node) const +ImageContent::as_xml (xmlpp::Node* node, bool with_paths) const { node->add_child("Type")->add_child_text ("Image"); - Content::as_xml (node); + Content::as_xml (node, with_paths); if (video) { video->as_xml (node); diff --git a/src/lib/image_content.h b/src/lib/image_content.h index edcbec6dd..660d2ef9f 100644 --- a/src/lib/image_content.h +++ b/src/lib/image_content.h @@ -36,7 +36,7 @@ public: void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; - void as_xml (xmlpp::Node *) const; + void as_xml (xmlpp::Node *, bool with_paths) const; DCPTime full_length () const; std::string identifier () const; diff --git a/src/lib/playlist.cc b/src/lib/playlist.cc index a8b5a26eb..a30dde633 100644 --- a/src/lib/playlist.cc +++ b/src/lib/playlist.cc @@ -175,10 +175,10 @@ Playlist::set_from_xml (shared_ptr film, cxml::ConstNodePtr node, in /** @param node node */ void -Playlist::as_xml (xmlpp::Node* node) +Playlist::as_xml (xmlpp::Node* node, bool with_content_paths) { BOOST_FOREACH (shared_ptr i, _content) { - i->as_xml (node->add_child ("Content")); + i->as_xml (node->add_child ("Content"), with_content_paths); } } diff --git a/src/lib/playlist.h b/src/lib/playlist.h index e84b51a73..0a5c087de 100644 --- a/src/lib/playlist.h +++ b/src/lib/playlist.h @@ -45,7 +45,7 @@ public: Playlist (); ~Playlist (); - void as_xml (xmlpp::Node *); + void as_xml (xmlpp::Node *, bool with_content_paths); void set_from_xml (boost::shared_ptr, cxml::ConstNodePtr, int, std::list &); void add (boost::shared_ptr); diff --git a/src/lib/text_subtitle_content.cc b/src/lib/text_subtitle_content.cc index 63144766a..08722a065 100644 --- a/src/lib/text_subtitle_content.cc +++ b/src/lib/text_subtitle_content.cc @@ -75,10 +75,10 @@ TextSubtitleContent::technical_summary () const } void -TextSubtitleContent::as_xml (xmlpp::Node* node) const +TextSubtitleContent::as_xml (xmlpp::Node* node, bool with_paths) const { node->add_child("Type")->add_child_text ("TextSubtitle"); - Content::as_xml (node); + Content::as_xml (node, with_paths); if (subtitle) { subtitle->as_xml (node); diff --git a/src/lib/text_subtitle_content.h b/src/lib/text_subtitle_content.h index 3b9d396f6..fd0bad12a 100644 --- a/src/lib/text_subtitle_content.h +++ b/src/lib/text_subtitle_content.h @@ -38,7 +38,7 @@ public: void examine (boost::shared_ptr); std::string summary () const; std::string technical_summary () const; - void as_xml (xmlpp::Node *) const; + void as_xml (xmlpp::Node *, bool with_paths) const; DCPTime full_length () const; private: diff --git a/src/tools/dcpomatic.cc b/src/tools/dcpomatic.cc index d4695f1fa..1fccb992a 100644 --- a/src/tools/dcpomatic.cc +++ b/src/tools/dcpomatic.cc @@ -143,6 +143,7 @@ enum { ID_file_new = 1, ID_file_open, ID_file_save, + ID_file_save_as_template, ID_file_history, /* Allow spare IDs after _history for the recent files list */ ID_content_scale_to_fit_width = 100, @@ -210,6 +211,7 @@ public: Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_new, this), ID_file_new); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_open, this), ID_file_open); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_save, this), ID_file_save); + Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_save_as_template, this), ID_file_save_as_template); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_history, this, _1), ID_file_history, ID_file_history + HISTORY_SIZE); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::file_exit, this), wxID_EXIT); Bind (wxEVT_COMMAND_MENU_SELECTED, boost::bind (&DOMFrame::edit_preferences, this), wxID_PREFERENCES); @@ -339,7 +341,7 @@ private: SetTitle (std_to_wx (s)); } - void file_new () + void file_new (bool from_template) { NewFilmDialog* d = new NewFilmDialog (this); int const r = d->ShowModal (); @@ -366,7 +368,7 @@ private: } if (maybe_save_then_delete_film ()) { - new_film (d->get_path ()); + new_film (d->get_path(), d->template_name()); } } @@ -404,6 +406,22 @@ private: _film->write_metadata (); } + void file_save_as_template () + { + SaveTemplateDialog* td = new SaveTemplateDialog (this); + int const r = d->ShowModal (); + if (r == wxID_OK) { + bool ok = true; + if (Config::instance()->existing_template (r->name ())) { + ok = confirm_dialog (td, _("There is already a template with this name. Do you want to overwrite it?")); + } + if (ok) { + Config::instance()->save_template (_film, r->name ()); + } + } + d->Destroy (); + } + void file_history (wxCommandEvent& event) { vector history = Config::instance()->history (); @@ -826,6 +844,8 @@ private: add_item (_file_menu, _("&Open...\tCtrl-O"), ID_file_open, ALWAYS); _file_menu->AppendSeparator (); add_item (_file_menu, _("&Save\tCtrl-S"), ID_file_save, NEEDS_FILM); + _file_menu->AppendSeparator (); + add_item (_file_menu, _("&Save as template"), ID_file_save_as_template, NEEDS_FILM); _history_position = _file_menu->GetMenuItems().GetCount(); diff --git a/src/wx/new_film_dialog.cc b/src/wx/new_film_dialog.cc index 04b9e1057..4883810d0 100644 --- a/src/wx/new_film_dialog.cc +++ b/src/wx/new_film_dialog.cc @@ -46,6 +46,10 @@ NewFilmDialog::NewFilmDialog (wxWindow* parent) _folder = new wxDirPickerCtrl (this, wxID_ANY, wxEmptyString, wxDirSelectorPromptStr, wxDefaultPosition, wxSize (300, -1)); #endif + _use_template = new wxCheckButton (this, wxID_ANY, _("From template")); + add (_use_template); + _template_name = new wxChoice (this, wxID_ANY); + if (!_directory) { _directory = Config::instance()->default_directory_or (wx_to_std (wxStandardPaths::Get().GetDocumentsDir())); } @@ -54,10 +58,23 @@ NewFilmDialog::NewFilmDialog (wxWindow* parent) add (_folder); _name->SetFocus (); + _template_name->Enable (false); + + BOOST_FOREACH (string i, Config::instance()->template_names ()) { + _template_name->Append (std_to_wx (i)); + } + + _use_template->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, bind (&NewFilmDialog::use_template_clicked, this)); layout (); } +void +NewFilmDialog::use_template_clicked () +{ + _template_name->Enable (_use_template->GetValue ()); +} + NewFilmDialog::~NewFilmDialog () { _directory = wx_to_std (_folder->GetPath ()); @@ -71,3 +88,13 @@ NewFilmDialog::get_path () const p /= wx_to_std (_name->GetValue ()); return p; } + +optional +NewFilmDialog::template_name () const +{ + if (!_use_template->GetValue ()) { + return optional (); + } + + return wx_to_std (_template_name->GetValue ()); +} diff --git a/src/wx/new_film_dialog.h b/src/wx/new_film_dialog.h index 6dc83d815..4096b4303 100644 --- a/src/wx/new_film_dialog.h +++ b/src/wx/new_film_dialog.h @@ -31,7 +31,8 @@ public: NewFilmDialog (wxWindow *); ~NewFilmDialog (); - boost::filesystem::path get_path () const; + boost::filesystem::path path () const; + boost::optional template_name () const; private: wxTextCtrl* _name; @@ -40,5 +41,7 @@ private: #else wxDirPickerCtrl* _folder; #endif + wxCheckButton* _use_template; + wxChoice* _template_name; static boost::optional _directory; }; diff --git a/src/wx/wscript b/src/wx/wscript index ee77e6c20..1f9aed6b3 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -75,6 +75,7 @@ sources = """ repeat_dialog.cc report_problem_dialog.cc rgba_colour_picker.cc + save_template_dialog.cc screen_dialog.cc screens_panel.cc self_dkdm_dialog.cc