Store subtitle language(s) in Film, and allow setup of those
[dcpomatic.git] / src / wx / language_tag_dialog.cc
index 0d0203e90a7af71a3c8237a9e5f1504035a08361..94e266f2c5b88e2a4e601fc5b528632ba54eb84b 100644 (file)
@@ -70,6 +70,11 @@ public:
                                SetItemState (item, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
                                EnsureVisible (item);
                        }
+               } else {
+                       if (GetItemCount() > 0) {
+                               /* The new list sometimes isn't visible without this */
+                               EnsureVisible (0);
+                       }
                }
        }
 
@@ -219,18 +224,7 @@ LanguageTagDialog::LanguageTagDialog (wxWindow* parent, dcp::LanguageTag tag)
 
        SetSizerAndFit (overall_sizer);
 
-       bool have_language = false;
-       vector<pair<dcp::LanguageTag::SubtagType, dcp::LanguageTag::SubtagData> > subtags = tag.subtags();
-       for (vector<pair<dcp::LanguageTag::SubtagType, dcp::LanguageTag::SubtagData> >::const_iterator i = subtags.begin(); i != subtags.end(); ++i) {
-               add_to_current_tag (i->first, i->second);
-               if (i->first == dcp::LanguageTag::LANGUAGE) {
-                       have_language = true;
-               }
-       }
-
-       if (!have_language) {
-               add_to_current_tag (dcp::LanguageTag::LANGUAGE, dcp::LanguageTag::SubtagData("en", "English"));
-       }
+       set (tag);
 
        _add_script->Bind (wxEVT_BUTTON, boost::bind(&LanguageTagDialog::add_to_current_tag, this, dcp::LanguageTag::SCRIPT, boost::optional<dcp::LanguageTag::SubtagData>()));
        _add_region->Bind (wxEVT_BUTTON, boost::bind(&LanguageTagDialog::add_to_current_tag, this, dcp::LanguageTag::REGION, boost::optional<dcp::LanguageTag::SubtagData>()));
@@ -298,6 +292,27 @@ dcp::LanguageTag LanguageTagDialog::get () const
 }
 
 
+void
+LanguageTagDialog::set (dcp::LanguageTag tag)
+{
+       _current_tag_subtags.clear ();
+       _current_tag_list->DeleteAllItems ();
+
+       bool have_language = false;
+       vector<pair<dcp::LanguageTag::SubtagType, dcp::LanguageTag::SubtagData> > subtags = tag.subtags();
+       for (vector<pair<dcp::LanguageTag::SubtagType, dcp::LanguageTag::SubtagData> >::const_iterator i = subtags.begin(); i != subtags.end(); ++i) {
+               add_to_current_tag (i->first, i->second);
+               if (i->first == dcp::LanguageTag::LANGUAGE) {
+                       have_language = true;
+               }
+       }
+
+       if (!have_language) {
+               add_to_current_tag (dcp::LanguageTag::LANGUAGE, dcp::LanguageTag::SubtagData("en", "English"));
+       }
+}
+
+
 string LanguageTagDialog::subtag_type_name (dcp::LanguageTag::SubtagType type)
 {
        switch (type) {