Fix missing content properties when using translations.
authorCarl Hetherington <cth@carlh.net>
Thu, 2 Jun 2016 20:03:03 +0000 (21:03 +0100)
committerCarl Hetherington <cth@carlh.net>
Thu, 2 Jun 2016 20:03:03 +0000 (21:03 +0100)
ChangeLog
src/lib/audio_content.cc
src/lib/content.cc
src/lib/ffmpeg_content.cc
src/lib/user_property.h
src/lib/video_content.cc
src/wx/content_properties_dialog.cc
src/wx/content_properties_dialog.h

index e3935f733a1c711fac1a787afe3c6222fec75b3f..b49063e769e3a69d06fda3b3f7a304c34fb6acea 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2016-06-02  Carl Hetherington  <cth@carlh.net>
 
+       * Fix broken content properties under translation.
+
        * Version 2.8.7 released.
 
 2016-06-01  c.hetherington  <cth@carlh.net>
index b159aa50d4f47a6851c126d15512defd9aad00c6..2b402991cf3696d6a8f303369c8e1f16c624d427 100644 (file)
@@ -292,34 +292,34 @@ AudioContent::add_properties (list<UserProperty>& p) const
        }
 
        if (stream) {
-               p.push_back (UserProperty (_("Audio"), _("Channels"), stream->channels ()));
-               p.push_back (UserProperty (_("Audio"), _("Content audio sample rate"), stream->frame_rate(), _("Hz")));
+               p.push_back (UserProperty (UserProperty::AUDIO, _("Channels"), stream->channels ()));
+               p.push_back (UserProperty (UserProperty::AUDIO, _("Content audio sample rate"), stream->frame_rate(), _("Hz")));
        }
 
        FrameRateChange const frc (_parent->active_video_frame_rate(), _parent->film()->video_frame_rate());
        ContentTime const c (_parent->full_length(), frc);
 
        p.push_back (
-               UserProperty (_("Length"), _("Full length in video frames at content rate"), c.frames_round(frc.source))
+               UserProperty (UserProperty::LENGTH, _("Full length in video frames at content rate"), c.frames_round(frc.source))
                );
 
        if (stream) {
                p.push_back (
                        UserProperty (
-                               _("Length"),
+                               UserProperty::LENGTH,
                                _("Full length in audio samples at content rate"),
                                c.frames_round (stream->frame_rate ())
                                )
                        );
        }
 
-       p.push_back (UserProperty (_("Audio"), _("DCP frame rate"), resampled_frame_rate (), _("Hz")));
-       p.push_back (UserProperty (_("Length"), _("Full length in video frames at DCP rate"), c.frames_round (frc.dcp)));
+       p.push_back (UserProperty (UserProperty::AUDIO, _("DCP frame rate"), resampled_frame_rate (), _("Hz")));
+       p.push_back (UserProperty (UserProperty::LENGTH, _("Full length in video frames at DCP rate"), c.frames_round (frc.dcp)));
 
        if (stream) {
                p.push_back (
                        UserProperty (
-                               _("Length"),
+                               UserProperty::LENGTH,
                                _("Full length in audio samples at DCP rate"),
                                c.frames_round (resampled_frame_rate ())
                                )
index 66b0d477e7f92aa2df87db3e8c2e521ce2a4e98c..b8e7f8ad2910623e8736334b46ad98b8845a61e2 100644 (file)
@@ -359,9 +359,13 @@ Content::active_video_frame_rate () const
 void
 Content::add_properties (list<UserProperty>& p) const
 {
-       p.push_back (UserProperty (_("General"), _("Filename"), path(0).string ()));
+       p.push_back (UserProperty (UserProperty::GENERAL, _("Filename"), path(0).string ()));
 
        if (_video_frame_rate) {
-               p.push_back (UserProperty (_("General"), _("Video frame rate"), raw_convert<string> (_video_frame_rate.get(), 5), _("frames per second")));
+               p.push_back (
+                       UserProperty (
+                               UserProperty::GENERAL, _("Video frame rate"), raw_convert<string> (_video_frame_rate.get(), 5), _("frames per second")
+                               )
+                       );
        }
 }
index cc6a703baf60b8882467a687cbe5b8d1870097b0..0f66180d0a6cd80da8f7d4ff16e99e247d8b3f27 100644 (file)
@@ -122,6 +122,9 @@ FFmpegContent::FFmpegContent (shared_ptr<const Film> film, cxml::ConstNodePtr no
 FFmpegContent::FFmpegContent (shared_ptr<const Film> film, vector<boost::shared_ptr<Content> > c)
        : Content (film, c)
 {
+       /* XXX: this should look at c to decide which of video/audio/subtitle
+          get created.
+       */
        video.reset (new VideoContent (this, c));
        audio.reset (new AudioContent (this, c));
        subtitle.reset (new SubtitleContent (this, c));
@@ -434,21 +437,21 @@ FFmpegContent::add_properties (list<UserProperty>& p) const
                        case AVCOL_RANGE_UNSPECIFIED:
                                /// TRANSLATORS: this means that the range of pixel values used in this
                                /// file is unknown (not specified in the file).
-                               p.push_back (UserProperty (_("Video"), _("Colour range"), _("Unspecified")));
+                               p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), _("Unspecified")));
                                break;
                        case AVCOL_RANGE_MPEG:
                                /// TRANSLATORS: this means that the range of pixel values used in this
                                /// file is limited, so that not all possible values are valid.
                                p.push_back (
                                        UserProperty (
-                                               _("Video"), _("Colour range"), String::compose (_("Limited (%1-%2)"), (total - sub) / 2, (total + sub) / 2)
+                                               UserProperty::VIDEO, _("Colour range"), String::compose (_("Limited (%1-%2)"), (total - sub) / 2, (total + sub) / 2)
                                                )
                                        );
                                break;
                        case AVCOL_RANGE_JPEG:
                                /// TRANSLATORS: this means that the range of pixel values used in this
                                /// file is full, so that all possible pixel values are valid.
-                               p.push_back (UserProperty (_("Video"), _("Colour range"), String::compose (_("Full (0-%1)"), total)));
+                               p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), String::compose (_("Full (0-%1)"), total)));
                                break;
                        default:
                                DCPOMATIC_ASSERT (false);
@@ -458,17 +461,17 @@ FFmpegContent::add_properties (list<UserProperty>& p) const
                        case AVCOL_RANGE_UNSPECIFIED:
                                /// TRANSLATORS: this means that the range of pixel values used in this
                                /// file is unknown (not specified in the file).
-                               p.push_back (UserProperty (_("Video"), _("Colour range"), _("Unspecified")));
+                               p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), _("Unspecified")));
                                break;
                        case AVCOL_RANGE_MPEG:
                                /// TRANSLATORS: this means that the range of pixel values used in this
                                /// file is limited, so that not all possible values are valid.
-                               p.push_back (UserProperty (_("Video"), _("Colour range"), _("Limited")));
+                               p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), _("Limited")));
                                break;
                        case AVCOL_RANGE_JPEG:
                                /// TRANSLATORS: this means that the range of pixel values used in this
                                /// file is full, so that all possible pixel values are valid.
-                               p.push_back (UserProperty (_("Video"), _("Colour range"), _("Full")));
+                               p.push_back (UserProperty (UserProperty::VIDEO, _("Colour range"), _("Full")));
                                break;
                        default:
                                DCPOMATIC_ASSERT (false);
@@ -490,7 +493,7 @@ FFmpegContent::add_properties (list<UserProperty>& p) const
                };
 
                DCPOMATIC_ASSERT (AVCOL_PRI_NB <= 11);
-               p.push_back (UserProperty (_("Video"), _("Colour primaries"), primaries[_color_primaries]));
+               p.push_back (UserProperty (UserProperty::VIDEO, _("Colour primaries"), primaries[_color_primaries]));
 
                char const * transfers[] = {
                        _("Unspecified"),
@@ -514,7 +517,7 @@ FFmpegContent::add_properties (list<UserProperty>& p) const
                };
 
                DCPOMATIC_ASSERT (AVCOL_TRC_NB <= 18);
-               p.push_back (UserProperty (_("Video"), _("Colour transfer characteristic"), transfers[_color_trc]));
+               p.push_back (UserProperty (UserProperty::VIDEO, _("Colour transfer characteristic"), transfers[_color_trc]));
 
                char const * spaces[] = {
                        _("RGB / sRGB (IEC61966-2-1)"),
@@ -531,10 +534,10 @@ FFmpegContent::add_properties (list<UserProperty>& p) const
                };
 
                DCPOMATIC_ASSERT (AVCOL_SPC_NB == 11);
-               p.push_back (UserProperty (_("Video"), _("Colourspace"), spaces[_colorspace]));
+               p.push_back (UserProperty (UserProperty::VIDEO, _("Colourspace"), spaces[_colorspace]));
 
                if (_bits_per_pixel) {
-                       p.push_back (UserProperty (_("Video"), _("Bits per pixel"), raw_convert<string> (_bits_per_pixel.get ())));
+                       p.push_back (UserProperty (UserProperty::VIDEO, _("Bits per pixel"), raw_convert<string> (_bits_per_pixel.get ())));
                }
        }
 
index b27cd4151f3693f6b021ee6d62992fb10df20150..a7a6f63da2336f6eece25b5e4dd994df669cc65f 100644 (file)
 class UserProperty
 {
 public:
+       enum Category {
+               GENERAL,
+               VIDEO,
+               AUDIO,
+               LENGTH
+       };
+
        template <class T>
-       UserProperty (std::string category_, std::string key_, T value_, std::string unit_ = "")
+       UserProperty (Category category_, std::string key_, T value_, std::string unit_ = "")
                : category (category_)
                , key (key_)
                , value (raw_convert<std::string> (value_))
                , unit (unit_)
        {}
 
-       std::string category;
+       Category category;
        std::string key;
        std::string value;
        std::string unit;
index 9ffc63c5d365906d0bbd2b66b4bd0bf16629b96b..473bd784c7887cf0e12838af28a9eb98a4d81db4 100644 (file)
@@ -419,8 +419,8 @@ VideoContent::processing_description () const
 void
 VideoContent::add_properties (list<UserProperty>& p) const
 {
-       p.push_back (UserProperty (_("Video"), _("Length"), raw_convert<string> (length ()), _("video frames")));
-       p.push_back (UserProperty (_("Video"), _("Size"), raw_convert<string> (size().width) + "x" + raw_convert<string> (size().height)));
+       p.push_back (UserProperty (UserProperty::VIDEO, _("Length"), raw_convert<string> (length ()), _("video frames")));
+       p.push_back (UserProperty (UserProperty::VIDEO, _("Size"), raw_convert<string> (size().width) + "x" + raw_convert<string> (size().height)));
 }
 
 void
index 8bb0a6b1f2fd6489e71204a6528164e10f02e88c..bd20d48e6e99c4326d2ff62e5c5c4d6e28b70aeb 100644 (file)
@@ -37,7 +37,7 @@ using boost::dynamic_pointer_cast;
 ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr<Content> content)
        : TableDialog (parent, _("Content Properties"), 2, 1, false)
 {
-       map<string, list<UserProperty> > grouped;
+       map<UserProperty::Category, list<UserProperty> > grouped;
        BOOST_FOREACH (UserProperty i, content->user_properties()) {
                if (grouped.find(i.category) == grouped.end()) {
                        grouped[i.category] = list<UserProperty> ();
@@ -45,10 +45,10 @@ ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr<C
                grouped[i.category].push_back (i);
        }
 
-       maybe_add_group (grouped, wx_to_std (_("General")));
-       maybe_add_group (grouped, wx_to_std (_("Video")));
-       maybe_add_group (grouped, wx_to_std (_("Audio")));
-       maybe_add_group (grouped, wx_to_std (_("Length")));
+       maybe_add_group (grouped, UserProperty::GENERAL);
+       maybe_add_group (grouped, UserProperty::VIDEO);
+       maybe_add_group (grouped, UserProperty::AUDIO);
+       maybe_add_group (grouped, UserProperty::LENGTH);
 
        layout ();
 
@@ -60,14 +60,30 @@ ContentPropertiesDialog::ContentPropertiesDialog (wxWindow* parent, shared_ptr<C
 }
 
 void
-ContentPropertiesDialog::maybe_add_group (map<string, list<UserProperty> > const & groups, string name)
+ContentPropertiesDialog::maybe_add_group (map<UserProperty::Category, list<UserProperty> > const & groups, UserProperty::Category category)
 {
-       map<string, list<UserProperty> >::const_iterator i = groups.find (name);
+       map<UserProperty::Category, list<UserProperty> >::const_iterator i = groups.find (category);
        if (i == groups.end()) {
                return;
        }
 
-       wxStaticText* m = new wxStaticText (this, wxID_ANY, std_to_wx (i->first));
+       wxString category_name;
+       switch (i->first) {
+       case UserProperty::GENERAL:
+               category_name = _("General");
+               break;
+       case UserProperty::VIDEO:
+               category_name = _("Video");
+               break;
+       case UserProperty::AUDIO:
+               category_name = _("Audio");
+               break;
+       case UserProperty::LENGTH:
+               category_name = _("Length");
+               break;
+       }
+
+       wxStaticText* m = new wxStaticText (this, wxID_ANY, category_name);
        wxFont font (*wxNORMAL_FONT);
        font.SetWeight (wxFONTWEIGHT_BOLD);
        m->SetFont (font);
index eb6f11ddb8a0cf1496eaa7c0c54e9b61d7bb779f..92aa5c6d739b51e9619273cb0cdd6c5106b7d0e3 100644 (file)
@@ -19,6 +19,7 @@
 */
 
 #include "table_dialog.h"
+#include "lib/user_property.h"
 #include <boost/shared_ptr.hpp>
 #include <list>
 #include <map>
@@ -32,5 +33,5 @@ public:
        ContentPropertiesDialog (wxWindow* parent, boost::shared_ptr<Content> content);
 
 private:
-       void maybe_add_group (std::map<std::string, std::list<UserProperty> > const & groups, std::string name);
+       void maybe_add_group (std::map<UserProperty::Category, std::list<UserProperty> > const & groups, UserProperty::Category category);
 };