Cleanup: rename some methods in FilePickerCtrl and use boost::filesystem::path more.
authorCarl Hetherington <cth@carlh.net>
Mon, 15 Jan 2024 23:33:05 +0000 (00:33 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 16 Jan 2024 20:33:29 +0000 (21:33 +0100)
src/wx/export_subtitles_dialog.cc
src/wx/export_video_file_dialog.cc
src/wx/file_picker_ctrl.cc
src/wx/file_picker_ctrl.h
src/wx/full_config_dialog.cc
src/wx/player_config_dialog.cc
src/wx/wx_util.cc

index 3c32fae536f900ef1934da7c7e80ae24cd48e765..ade58b3fb06c871a7df18b1b12406ed9dccb7261 100644 (file)
@@ -97,7 +97,7 @@ boost::filesystem::path
 ExportSubtitlesDialog::path () const
 {
        if (_file->IsEnabled()) {
-               wxFileName fn (_file->GetPath());
+               wxFileName fn(std_to_wx(_file->path().string()));
                fn.SetExt (_interop ? "xml" : "mxf");
                return wx_to_std (fn.GetFullPath());
        }
index 208481225d09a5642ef169f882af06dc382587c1..8b01282b659cdbd848b6efa0b8ead841dc18b54b 100644 (file)
@@ -97,7 +97,7 @@ ExportVideoFileDialog::ExportVideoFileDialog (wxWindow* parent, string name)
           so disable its check and the caller will have to do it themselves.
        */
        _file = new FilePickerCtrl (this, _("Select output file"), format_filters[0], false, false);
-       _file->SetPath (_initial_name);
+       _file->set_path(_initial_name);
        add (_file);
 
        for (int i = 0; i < FORMATS; ++i) {
@@ -167,8 +167,8 @@ ExportVideoFileDialog::format_changed ()
 {
        auto const selection = _format->GetSelection();
        DCPOMATIC_ASSERT (selection >= 0 && selection < FORMATS);
-       _file->SetWildcard (format_filters[selection]);
-       _file->SetPath (_initial_name);
+       _file->set_wildcard(format_filters[selection]);
+       _file->set_path(_initial_name);
        _x264_crf->Enable (formats[selection] == ExportFormat::H264_AAC);
        for (int i = 0; i < 2; ++i) {
                _x264_crf_label[i]->Enable(formats[selection] == ExportFormat::H264_AAC);
@@ -180,7 +180,7 @@ ExportVideoFileDialog::format_changed ()
 boost::filesystem::path
 ExportVideoFileDialog::path () const
 {
-       wxFileName fn (_file->GetPath());
+       wxFileName fn(std_to_wx(_file->path().string()));
        fn.SetExt (format_extensions[_format->GetSelection()]);
        return wx_to_std (fn.GetFullPath());
 }
index 4bb6518efc2fe33a91ac26812a701a5fba9bd55e..07424e74cd82182cc9670c411eea98dbb7a6a0f8 100644 (file)
@@ -55,13 +55,14 @@ FilePickerCtrl::FilePickerCtrl (wxWindow* parent, wxString prompt, wxString wild
        _file->Bind (wxEVT_BUTTON, boost::bind (&FilePickerCtrl::browse_clicked, this));
 }
 
+
 void
-FilePickerCtrl::SetPath (wxString p)
+FilePickerCtrl::set_path(boost::filesystem::path path)
 {
-       _path = p;
+       _path = path;
 
-       if (!_path.IsEmpty ()) {
-               _file->SetLabel(std_to_wx(filesystem::path(wx_to_std(_path)).filename().string()));
+       if (!_path.empty()) {
+               _file->SetLabel(std_to_wx(_path.filename().string()));
        } else {
                _file->SetLabel (_("(None)"));
        }
@@ -70,12 +71,14 @@ FilePickerCtrl::SetPath (wxString p)
        GetEventHandler()->ProcessEvent (ev);
 }
 
-wxString
-FilePickerCtrl::GetPath () const
+
+boost::filesystem::path
+FilePickerCtrl::path() const
 {
        return _path;
 }
 
+
 void
 FilePickerCtrl::browse_clicked ()
 {
@@ -84,14 +87,14 @@ FilePickerCtrl::browse_clicked ()
                style |= wxFD_OVERWRITE_PROMPT;
        }
        wxFileDialog dialog(this, _prompt, wxEmptyString, wxEmptyString, _wildcard, style);
-       dialog.SetPath(_path);
+       dialog.SetPath(std_to_wx(_path.string()));
        if (dialog.ShowModal() == wxID_OK) {
-               SetPath(dialog.GetPath());
+               set_path(boost::filesystem::path(wx_to_std(dialog.GetPath())));
        }
 }
 
 void
-FilePickerCtrl::SetWildcard (wxString w)
+FilePickerCtrl::set_wildcard(wxString w)
 {
        _wildcard = w;
 }
index df7226655ecbb75fd69b47b97a514aea4b678923..2411254faa53c0c385164ad3f0eeb168f364e692 100644 (file)
 
 */
 
+
 #include <dcp/warnings.h>
 LIBDCP_DISABLE_WARNINGS
 #include <wx/wx.h>
 LIBDCP_ENABLE_WARNINGS
+#include <boost/filesystem.hpp>
+
 
 class FilePickerCtrl : public wxPanel
 {
 public:
        FilePickerCtrl (wxWindow* parent, wxString prompt, wxString wildcard, bool open, bool warn_overwrite);
 
-       wxString GetPath () const;
-       void SetPath (wxString);
-       void SetWildcard (wxString);
+       boost::filesystem::path path() const;
+       void set_path(boost::filesystem::path path);
+       void set_wildcard(wxString);
 
 private:
        void browse_clicked ();
 
        wxButton* _file;
-       wxString _path;
+       boost::filesystem::path _path;
        wxSizer* _sizer;
        wxString _prompt;
        wxString _wildcard;
index 2d4679611c9f6981332636fbee39a282af830d84..f7945a44a4404f1076e2f9f3334d0068ebe2e238 100644 (file)
@@ -216,7 +216,7 @@ private:
        void config_file_changed ()
        {
                auto config = Config::instance();
-               boost::filesystem::path new_file = wx_to_std(_config_file->GetPath());
+               auto const new_file = _config_file->path();
                if (new_file == config->config_read_file()) {
                        return;
                }
@@ -240,7 +240,7 @@ private:
 
        void cinemas_file_changed ()
        {
-               Config::instance()->set_cinemas_file (wx_to_std (_cinemas_file->GetPath ()));
+               Config::instance()->set_cinemas_file(_cinemas_file->path());
        }
 
        void default_add_file_location_changed()
index 5ac1fe28d2f75760a1c3bd6e72442458d9d97cd2..512c64c91314157093116fa9c0a0d045f7f2e010 100644 (file)
@@ -208,7 +208,7 @@ private:
 
        void debug_log_file_changed ()
        {
-               Config::instance()->set_player_debug_log_file(wx_to_std(_debug_log_file->GetPath()));
+               Config::instance()->set_player_debug_log_file(_debug_log_file->path());
        }
 
        wxChoice* _player_mode;
index 5f5a96a46a6f956cfcf30ebbfd7ea78762d8de6c..c0f90bd251083676377928818d39d1795c81aa0a 100644 (file)
@@ -222,14 +222,14 @@ string_client_data (wxClientData* o)
 void
 checked_set (FilePickerCtrl* widget, boost::filesystem::path value)
 {
-       if (widget->GetPath() != std_to_wx (value.string())) {
+       if (widget->path() != value) {
                if (value.empty()) {
                        /* Hack to make wxWidgets clear the control when we are passed
                           an empty value.
                        */
                        value = " ";
                }
-               widget->SetPath (std_to_wx (value.string()));
+               widget->set_path(value);
        }
 }