Emit no audio from DCPs if none is mapped
[dcpomatic.git] / src / wx / templates_dialog.cc
index 5173cdc5a2557921c03476ad832e6d46cee82fc1..145e4f2b97119d3557c7805705d3e4ce39265d99 100644 (file)
 #include "templates_dialog.h"
 #include "wx_util.h"
 #include "lib/config.h"
-#include "lib/warnings.h"
-DCPOMATIC_DISABLE_WARNINGS
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
-DCPOMATIC_ENABLE_WARNINGS
+LIBDCP_ENABLE_WARNINGS
 
 
 using std::string;
@@ -44,7 +44,7 @@ TemplatesDialog::TemplatesDialog (wxWindow* parent)
        SetSizer (_sizer);
 
        auto hs = new wxBoxSizer (wxHORIZONTAL);
-       _list = new wxListCtrl (this, wxID_ANY, wxDefaultPosition, wxSize (200, 100), wxLC_REPORT | wxLC_SINGLE_SEL);
+       _list = new wxListCtrl(this, wxID_ANY, wxDefaultPosition, wxSize(400, 300), wxLC_REPORT | wxLC_SINGLE_SEL);
 
        wxListItem ip;
        ip.SetId (0);
@@ -57,9 +57,9 @@ TemplatesDialog::TemplatesDialog (wxWindow* parent)
        {
                auto s = new wxBoxSizer (wxVERTICAL);
                _rename = new Button (this, _("Rename..."));
-               s->Add (_rename, 0, wxTOP | wxBOTTOM, 2);
+               s->Add(_rename, 0, wxTOP | wxBOTTOM | wxEXPAND, 2);
                _remove = new Button (this, _("Remove"));
-               s->Add (_remove, 0, wxTOP | wxBOTTOM, 2);
+               s->Add(_remove, 0, wxTOP | wxBOTTOM | wxEXPAND, 2);
                hs->Add (s, 0, wxLEFT, DCPOMATIC_SIZER_X_GAP);
        }
 
@@ -78,6 +78,8 @@ TemplatesDialog::TemplatesDialog (wxWindow* parent)
        _list->Bind (wxEVT_SIZE, bind(&TemplatesDialog::resized, this, _1));
        _config_connection = Config::instance()->Changed.connect (bind(&TemplatesDialog::refresh, this));
 
+       Fit();
+
        refresh ();
        selection_changed ();
 }
@@ -128,17 +130,18 @@ TemplatesDialog::rename_clicked ()
        li.m_mask = wxLIST_MASK_TEXT;
        _list->GetItem (li);
 
-       auto d = new RenameTemplateDialog (this);
-       d->set (li.m_text);
-       if (d->ShowModal() == wxID_OK) {
-               if (!d->get().IsEmpty()) {
-                       Config::instance()->rename_template (wx_to_std (li.m_text), wx_to_std (d->get ()));
-                       _list->SetItem (item, 0, d->get());
-               } else {
-                       error_dialog (this, _("Template names must not be empty."));
-               }
+       RenameTemplateDialog dialog(this);
+       dialog.set(li.m_text);
+       if (dialog.ShowModal() != wxID_OK) {
+               return;
+       }
+
+       if (!dialog.get().IsEmpty()) {
+               Config::instance()->rename_template(wx_to_std(li.m_text), wx_to_std(dialog.get()));
+               _list->SetItem(item, 0, dialog.get());
+       } else {
+               error_dialog (this, _("Template names must not be empty."));
        }
-       d->Destroy ();
 }