summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-01-16 00:33:05 +0100
committerCarl Hetherington <cth@carlh.net>2024-01-16 21:33:29 +0100
commitd464a939f9f851e835b2a4926fafd6eadaa183de (patch)
tree824a491f85ef056d401b37f006bbced3f63919a5
parent4790b63ceadc38fba77954f531a455fff28f8b13 (diff)
Cleanup: rename some methods in FilePickerCtrl and use boost::filesystem::path more.
-rw-r--r--src/wx/export_subtitles_dialog.cc2
-rw-r--r--src/wx/export_video_file_dialog.cc8
-rw-r--r--src/wx/file_picker_ctrl.cc21
-rw-r--r--src/wx/file_picker_ctrl.h11
-rw-r--r--src/wx/full_config_dialog.cc4
-rw-r--r--src/wx/player_config_dialog.cc2
-rw-r--r--src/wx/wx_util.cc4
7 files changed, 29 insertions, 23 deletions
diff --git a/src/wx/export_subtitles_dialog.cc b/src/wx/export_subtitles_dialog.cc
index 3c32fae53..ade58b3fb 100644
--- a/src/wx/export_subtitles_dialog.cc
+++ b/src/wx/export_subtitles_dialog.cc
@@ -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());
}
diff --git a/src/wx/export_video_file_dialog.cc b/src/wx/export_video_file_dialog.cc
index 208481225..8b01282b6 100644
--- a/src/wx/export_video_file_dialog.cc
+++ b/src/wx/export_video_file_dialog.cc
@@ -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());
}
diff --git a/src/wx/file_picker_ctrl.cc b/src/wx/file_picker_ctrl.cc
index 4bb6518ef..07424e74c 100644
--- a/src/wx/file_picker_ctrl.cc
+++ b/src/wx/file_picker_ctrl.cc
@@ -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;
}
diff --git a/src/wx/file_picker_ctrl.h b/src/wx/file_picker_ctrl.h
index df7226655..2411254fa 100644
--- a/src/wx/file_picker_ctrl.h
+++ b/src/wx/file_picker_ctrl.h
@@ -18,25 +18,28 @@
*/
+
#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;
diff --git a/src/wx/full_config_dialog.cc b/src/wx/full_config_dialog.cc
index 2d4679611..f7945a44a 100644
--- a/src/wx/full_config_dialog.cc
+++ b/src/wx/full_config_dialog.cc
@@ -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()
diff --git a/src/wx/player_config_dialog.cc b/src/wx/player_config_dialog.cc
index 5ac1fe28d..512c64c91 100644
--- a/src/wx/player_config_dialog.cc
+++ b/src/wx/player_config_dialog.cc
@@ -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;
diff --git a/src/wx/wx_util.cc b/src/wx/wx_util.cc
index 5f5a96a46..c0f90bd25 100644
--- a/src/wx/wx_util.cc
+++ b/src/wx/wx_util.cc
@@ -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);
}
}