Sign things that come out of the combiner (#2028).
[dcpomatic.git] / src / wx / film_name_location_dialog.cc
index d91171acb52799e7699c7793fa8244a253ec452e..2ef6c9955714e474f1e3a40e116a63d4371d811f 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2017 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2020 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -20,6 +20,7 @@
 
 #include "wx_util.h"
 #include "film_name_location_dialog.h"
+#include "check_box.h"
 #ifdef DCPOMATIC_USE_OWN_PICKER
 #include "dir_picker_ctrl.h"
 #endif
@@ -27,7 +28,6 @@
 #include "lib/compose.hpp"
 #include <wx/stdpaths.h>
 #include <boost/filesystem.hpp>
-#include <boost/foreach.hpp>
 
 using namespace std;
 using namespace boost;
@@ -56,7 +56,7 @@ FilmNameLocationDialog::FilmNameLocationDialog (wxWindow* parent, wxString title
        add (_folder);
 
        if (offer_templates) {
-               _use_template = new wxCheckBox (this, wxID_ANY, _("From template"));
+               _use_template = new CheckBox (this, _("From template"));
                add (_use_template);
                _template_name = new wxChoice (this, wxID_ANY);
                add (_template_name);
@@ -67,7 +67,7 @@ FilmNameLocationDialog::FilmNameLocationDialog (wxWindow* parent, wxString title
        if (offer_templates) {
                _template_name->Enable (false);
 
-               BOOST_FOREACH (string i, Config::instance()->templates ()) {
+               for (auto i: Config::instance()->templates ()) {
                        _template_name->Append (std_to_wx (i));
                }
 
@@ -75,8 +75,22 @@ FilmNameLocationDialog::FilmNameLocationDialog (wxWindow* parent, wxString title
        }
 
        layout ();
+
+       _name->Bind (wxEVT_TEXT, bind(&FilmNameLocationDialog::setup_sensitivity, this));
+       setup_sensitivity ();
+}
+
+
+void
+FilmNameLocationDialog::setup_sensitivity ()
+{
+       wxButton* ok = dynamic_cast<wxButton *>(FindWindowById(wxID_OK, this));
+       if (ok) {
+               ok->Enable (!_name->GetValue().IsEmpty());
+       }
 }
 
+
 void
 FilmNameLocationDialog::use_template_clicked ()
 {