Hand-apply d849d411cff28ef5453085791d0b4d7cd73bd070 from master; replace all assert...
[dcpomatic.git] / src / wx / kdm_dialog.cc
index 42b8297f0fc64e608c6580bbcabee6b9cce5f956..9b1d6bc98ed1e12fdc0811b26f95a4f486ad6c0b 100644 (file)
@@ -96,7 +96,7 @@ KDMDialog::KDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
 
 
        /* Sub-heading: Timing */
-       h = new wxStaticText (this, wxID_ANY, _("Timing"));
+       h = new wxStaticText (this, wxID_ANY, S_("KDM|Timing"));
        h->SetFont (subheading_font);
        vertical->Add (h, 0, wxALIGN_CENTER_VERTICAL | wxTOP, DCPOMATIC_SIZER_Y_GAP * 2);
        
@@ -159,6 +159,16 @@ KDMDialog::KDMDialog (wxWindow* parent, boost::shared_ptr<const Film> film)
        
        table = new wxFlexGridSizer (2, DCPOMATIC_SIZER_X_GAP, 0);
 
+       add_label_to_sizer (table, this, _("KDM type"), true);
+       _type = new wxChoice (this, wxID_ANY);
+       _type->Append ("Modified Transitional 1", ((void *) dcp::MODIFIED_TRANSITIONAL_1));
+       if (!film->interop ()) {
+               _type->Append ("DCI Any", ((void *) dcp::DCI_ANY));
+               _type->Append ("DCI Specific", ((void *) dcp::DCI_SPECIFIC));
+       }
+       table->Add (_type, 1, wxEXPAND);
+       _type->SetSelection (0);
+
        _write_to = new wxRadioButton (this, wxID_ANY, _("Write to"));
        table->Add (_write_to, 1, wxEXPAND);
 
@@ -299,11 +309,11 @@ void
 KDMDialog::add_cinema_clicked ()
 {
        CinemaDialog* d = new CinemaDialog (this, "Add Cinema");
-       d->ShowModal ();
-
-       shared_ptr<Cinema> c (new Cinema (d->name(), d->email()));
-       Config::instance()->add_cinema (c);
-       add_cinema (c);
+       if (d->ShowModal () == wxID_OK) {
+               shared_ptr<Cinema> c (new Cinema (d->name(), d->email()));
+               Config::instance()->add_cinema (c);
+               add_cinema (c);
+       }
 
        d->Destroy ();
 }
@@ -318,13 +328,12 @@ KDMDialog::edit_cinema_clicked ()
        pair<wxTreeItemId, shared_ptr<Cinema> > c = selected_cinemas().front();
        
        CinemaDialog* d = new CinemaDialog (this, "Edit cinema", c.second->name, c.second->email);
-       d->ShowModal ();
-
-       c.second->name = d->name ();
-       c.second->email = d->email ();
-       _targets->SetItemText (c.first, std_to_wx (d->name()));
-
-       Config::instance()->changed ();
+       if (d->ShowModal () == wxID_OK) {
+               c.second->name = d->name ();
+               c.second->email = d->email ();
+               _targets->SetItemText (c.first, std_to_wx (d->name()));
+               Config::instance()->changed ();
+       }
 
        d->Destroy ();  
 }
@@ -375,13 +384,12 @@ KDMDialog::edit_screen_clicked ()
        pair<wxTreeItemId, shared_ptr<Screen> > s = selected_screens().front();
        
        ScreenDialog* d = new ScreenDialog (this, "Edit screen", s.second->name, s.second->certificate);
-       d->ShowModal ();
-
-       s.second->name = d->name ();
-       s.second->certificate = d->certificate ();
-       _targets->SetItemText (s.first, std_to_wx (d->name()));
-
-       Config::instance()->changed ();
+       if (d->ShowModal () == wxID_OK) {
+               s.second->name = d->name ();
+               s.second->certificate = d->certificate ();
+               _targets->SetItemText (s.first, std_to_wx (d->name()));
+               Config::instance()->changed ();
+       }
 
        d->Destroy ();
 }
@@ -464,7 +472,7 @@ boost::filesystem::path
 KDMDialog::cpl () const
 {
        int const item = _cpl->GetSelection ();
-       assert (item >= 0);
+       DCPOMATIC_ASSERT (item >= 0);
        return _cpls[item].cpl_file;
 }
 
@@ -480,6 +488,12 @@ KDMDialog::write_to () const
        return _write_to->GetValue ();
 }
 
+dcp::Formulation
+KDMDialog::formulation () const
+{
+       return (dcp::Formulation) reinterpret_cast<intptr_t> (_type->GetClientData (_type->GetSelection()));
+}
+
 void
 KDMDialog::update_cpl_choice ()
 {
@@ -512,14 +526,17 @@ KDMDialog::update_cpl_summary ()
 void
 KDMDialog::cpl_browse_clicked ()
 {
-       wxFileDialog d (this, _("Select CPL XML file"), wxEmptyString, wxEmptyString, "*.xml");
-       if (d.ShowModal() == wxID_CANCEL) {
+       wxFileDialog* d = new wxFileDialog (this, _("Select CPL XML file"), wxEmptyString, wxEmptyString, "*.xml");
+       if (d->ShowModal() == wxID_CANCEL) {
+               d->Destroy ();
                return;
        }
 
-       boost::filesystem::path cpl_file (wx_to_std (d.GetPath ()));
+       boost::filesystem::path cpl_file (wx_to_std (d->GetPath ()));
        boost::filesystem::path dcp_dir = cpl_file.parent_path ();
 
+       d->Destroy ();
+
        /* XXX: hack alert */
        cxml::Document cpl_document ("CompositionPlaylist");
        cpl_document.read_file (cpl_file);