25#include <wx/stattext.h>
26#include <wx/textctrl.h>
29#include <wx/filename.h>
50 virtual wxObject*
Clone() const wxOVERRIDE
55 virtual bool Validate(wxWindow* WXUNUSED(parent)) wxOVERRIDE
57 wxTextCtrl* tc = wxDynamicCast(GetWindow(), wxTextCtrl);
83 wxTextCtrl* tc = wxDynamicCast(GetWindow(), wxTextCtrl);
88 auto keycode = evt.GetUnicodeKey();
89 if (keycode < WXK_SPACE || keycode == WXK_DELETE) {
93 wxString path = tc->GetValue();
94 path.insert(tc->GetInsertionPoint(), keycode);
159 return XO(
"Preferences for Directories");
164 return "Directories_Preferences";
187 S.StartStatic(
XO(
"Default directories"));
190 S.AddFixedText(
XO(
"Leave a field empty to go to the last directory used for that operation.\n"
191 "Fill in a field to always go to that directory for that operation."),
false, 450);
194 S.StartMultiColumn(3, wxEXPAND);
203 S.Id(OpenButtonID).AddButton(
XXO(
"&Browse..."));
233 S.Id(MacrosButtonID).AddButton(
XXO(
"Bro&wse..."));
241 S.StartStatic(
XO(
"Temporary files directory"));
243 S.StartMultiColumn(3, wxEXPAND);
254 S.Id(TempButtonID).AddButton(
XXO(
"Brow&se..."));
257 .AddReadOnlyText(
XXO(
"&Free Space:"),
"");
281 XO(
"Choose a location to place the temporary directory"),
283 int retval = dlog.ShowModal();
284 if (retval != wxID_CANCEL && !dlog.GetPath().empty())
286 wxFileName tmpDirPath;
287 tmpDirPath.AssignDir(dlog.GetPath());
290 XO(
"Temporary files directory cannot be on a FAT drive."))) {
305#if defined(__WXMAC__)
306 newDirName =
wxT(
"SessionData");
307#elif defined(__WXMSW__)
309 newDirName =
wxT(
"SessionData");
311 newDirName =
wxT(
".audacity_temp");
313 auto dirsInPath = tmpDirPath.GetDirs();
319 tmpDirPath != wxFileName(
mTempText->GetValue(),
wxT(
"")) &&
320 (dirsInPath.size() == 0 ||
321 dirsInPath[dirsInPath.size()-1] != newDirName))
323 tmpDirPath.AppendDir(newDirName);
326 mTempText->SetValue(tmpDirPath.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR));
340 wxGetDiskSpace(path, NULL, &space);
342 label = wxDirExists(path)
344 :
XO(
"unavailable - above location doesn't exist");
352 long id = evt.GetId() - ButtonsStart;
353 wxTextCtrl *tc = (wxTextCtrl *) FindWindow(
id + TextsStart);
355 wxString location = tc->GetValue();
358 XO(
"Choose a location"),
360 int retval = dlog.ShowModal();
362 if (retval == wxID_CANCEL)
370 XO(
"Projects cannot be saved to FAT drives.")))
382 tc->SetValue(dlog.GetPath());
388 const wxFileName path { pathString };
391 XO(
"\nDirectory %s does not exist. Create it?")
394 wxYES_NO | wxCENTRE | wxICON_EXCLAMATION);
400 if (!path.Mkdir(0755, wxPATH_MKDIR_FULL)) {
404 XO(
"Directory creation failed.") +
408 .IconStyle(Icon::Error)
409 .ButtonStyle(Button::Ok)
421 wxString path{Temp.GetPath()};
424 XO(
"Directory %s is not suitable (at risk of being cleaned out)")
427 wxOK | wxICON_ERROR);
431 if (!Temp.DirExists()) {
438 XO(
"'Temporary files' directory cannot be set.")))
443 Temp.AppendDir(
wxT(
"canicreate"));
444 path = Temp.GetPath();
445 if (!Temp.Mkdir(0755)) {
447 XO(
"Directory %s is not writable")
450 wxOK | wxICON_ERROR);
454 Temp.RemoveLastDir();
459 if (Temp != oldDir) {
462"Changes to temporary directory will not take effect until Audacity is restarted"),
463 XO(
"Temp Directory Update"),
464 wxOK | wxCENTRE | wxICON_INFORMATION);
467 const wxString openPathString =
mOpenText->GetValue();
468 const wxString savePathString =
mSaveText->GetValue();
469 const wxString importPathString =
mImportText->GetValue();
470 const wxString exportPathString =
mExportText->GetValue();
471 const wxString macroPathString =
mMacrosText->GetValue();
473 const std::initializer_list<TranslatableString> messagesPreference{
474 XO(
"'Open' directory cannot be set.") ,
475 XO(
"'Save' directory cannot be set.") ,
476 XO(
"'Import' directory cannot be set.") ,
477 XO(
"'Export' directory cannot be set.") ,
478 XO(
"'Macro Output' directory cannot be set.") ,
487 for (
auto &
string : { openPathString, savePathString, importPathString, exportPathString, macroPathString} ) {
488 const wxFileName currentPath {
string };
489 const auto & message = *(messagesPreference.begin() +
id);
491 if (currentPath.DirExists()){
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
PrefsPanel::Factory DirectoriesPrefsFactory()
wxBEGIN_EVENT_TABLE(FilesystemValidator, wxValidator) wxEND_EVENT_TABLE() enum
bool CreateDirectory(const wxString pathString, const TranslatableString &message)
#define DIRECTORIES_PREFS_PLUGIN_SYMBOL
XXO("&Cut/Copy/Paste Toolbar")
EVT_COMMAND_RANGE(ID_Slider, ID_Slider+99, wxEVT_COMMAND_SLIDER_UPDATED, NyquistEffect::OnSlider) EVT_COMMAND_RANGE(ID_Text
audacity::BasicSettings * gPrefs
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
ComponentInterfaceSymbol pairs a persistent string identifier used internally with an optional,...
A PrefsPanel used to select directories.
void Populate()
Creates the dialog and its contents.
ReadOnlyText * mFreeSpace
ManualPageID HelpPageName() override
If not empty string, the Help button is added below the panel.
void PopulateOrExchange(ShuttleGui &S) override
void OnTempBrowse(wxCommandEvent &evt)
ComponentInterfaceSymbol GetSymbol() const override
void OnBrowse(wxCommandEvent &evt)
void OnTempText(wxCommandEvent &evt)
TranslatableString GetDescription() const override
virtual bool TransferToWindow() wxOVERRIDE
TranslatableString mMessage
void OnChar(wxKeyEvent &evt)
virtual wxObject * Clone() const wxOVERRIDE
FilesystemValidator(const TranslatableString &message)
virtual bool TransferFromWindow() wxOVERRIDE
virtual bool Validate(wxWindow *WXUNUSED(parent)) wxOVERRIDE
static TranslatableString FormatSize(wxLongLong size)
Convert a number to a string while formatting it in bytes, KB, MB, GB.
Base class for a panel in the PrefsDialog. Classes derived from this class include BatchPrefs,...
std::function< PrefsPanel *(wxWindow *parent, wxWindowID winid, AudacityProject *) > Factory
void SetValue(const wxString &value)
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
virtual bool Read(const wxString &key, bool *value) const =0
MessageBoxResult ShowMessageBox(const TranslatableString &message, MessageBoxOptions options={})
Show a modal message box with either Ok or Yes and No, and optionally Cancel.
FILES_API wxString PreferenceKey(FileNames::Operation op, FileNames::PathType type)
FILES_API bool WritableLocationCheck(const FilePath &path, const TranslatableString &message)
Check location on writable access and return true if checked successfully.
FILES_API bool FATFilesystemDenied(const FilePath &path, const TranslatableString &msg, const BasicUI::WindowPlacement &placement={})
FILES_API bool IsTempDirectoryNameOK(const FilePath &Name)
FILES_API wxString TempDir()
FILES_API const FilePath & DefaultTempDir()
PrefsPanel::Registration sAttachment
MessageBoxOptions && Caption(TranslatableString caption_) &&