X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Fdir_picker_ctrl.cc;h=fe4937edf5cc8002f24dfff543b188167723b516;hb=e60bb3e51bd1508b149e6b8f6608f09b5196ae26;hp=05b680288c248baaf0605f88d67eac45e71556d5;hpb=8cb200670cbb98cff22695b1e693533d1160911d;p=dcpomatic.git diff --git a/src/wx/dir_picker_ctrl.cc b/src/wx/dir_picker_ctrl.cc index 05b680288..fe4937edf 100644 --- a/src/wx/dir_picker_ctrl.cc +++ b/src/wx/dir_picker_ctrl.cc @@ -19,6 +19,7 @@ #include #include +#include #include #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,26 +39,22 @@ DirPickerCtrl::DirPickerCtrl (wxWindow* parent) SetSizerAndFit (_sizer); - _browse->Connect (wxID_ANY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (DirPickerCtrl::browse_clicked), 0, this); - - /* Do this after the fit so that our folder label stays long */ - SetPath (wxStandardPaths::Get().GetDocumentsDir()); + _browse->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&DirPickerCtrl::browse_clicked, this)); } void DirPickerCtrl::SetPath (wxString p) { _path = p; - + if (_path == wxStandardPaths::Get().GetDocumentsDir()) { _folder->SetLabel (_("My Documents")); } else { -#if BOOST_FILESYSTEM_VERSION == 3 _folder->SetLabel (std_to_wx (filesystem::path (wx_to_std (_path)).leaf().string())); -#else - _folder->SetLabel (std_to_wx (filesystem::path (wx_to_std (_path)).leaf())); -#endif } + + wxCommandEvent ev (wxEVT_COMMAND_DIRPICKER_CHANGED, wxID_ANY); + GetEventHandler()->ProcessEvent (ev); } wxString @@ -68,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 (); }