00cc8646894f6519d1e2726f3e7a4fbc1e11d8f3 from master; make the config dialog update...
[dcpomatic.git] / src / wx / dir_picker_ctrl.cc
index b6558a881eee90169ba681cc9ff8757ff2a0b01a..fad545283acfb47aa3d20c0c37b885a35a76e952 100644 (file)
@@ -19,6 +19,7 @@
 
 #include <wx/wx.h>
 #include <wx/stdpaths.h>
+#include <wx/filepicker.h>
 #include <boost/filesystem.hpp>
 #include "dir_picker_ctrl.h"
 #include "wx_util.h"
@@ -28,7 +29,6 @@ using namespace boost;
 
 DirPickerCtrl::DirPickerCtrl (wxWindow* parent)
        : wxPanel (parent)
-       , _parent (parent)
 {
        _sizer = new wxBoxSizer (wxHORIZONTAL);
 
@@ -39,7 +39,7 @@ DirPickerCtrl::DirPickerCtrl (wxWindow* parent)
 
        SetSizerAndFit (_sizer);
 
-       _browse->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (DirPickerCtrl::browse_clicked), 0, this);
+       _browse->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DirPickerCtrl::browse_clicked, this));
 }
 
 void
@@ -52,6 +52,9 @@ DirPickerCtrl::SetPath (wxString p)
        } else {
                _folder->SetLabel (std_to_wx (filesystem::path (wx_to_std (_path)).leaf().string()));
        }
+
+       wxCommandEvent ev (wxEVT_COMMAND_DIRPICKER_CHANGED, wxID_ANY);
+       GetEventHandler()->ProcessEvent (ev);
 }
 
 wxString
@@ -61,10 +64,11 @@ DirPickerCtrl::GetPath () const
 }
 
 void
-DirPickerCtrl::browse_clicked (wxCommandEvent &)
+DirPickerCtrl::browse_clicked ()
 {
        wxDirDialog* d = new wxDirDialog (this);
-       d->ShowModal ();
-       SetPath (d->GetPath ());
+       if (d->ShowModal () == wxID_OK) {
+               SetPath (d->GetPath ());
+       }
        d->Destroy ();
 }