26#include <wx/stattext.h>
27#include <wx/textctrl.h>
32#include <wx/filename.h>
36#include "../ShuttleGui.h"
38#include "../widgets/AudacityMessageBox.h"
39#include "../widgets/ReadOnlyText.h"
40#include "../widgets/wxTextCtrlWrapper.h"
55 virtual wxObject*
Clone() const wxOVERRIDE
60 virtual bool Validate(wxWindow* WXUNUSED(parent)) wxOVERRIDE
62 wxTextCtrl* tc = wxDynamicCast(GetWindow(), wxTextCtrl);
88 wxTextCtrl* tc = wxDynamicCast(GetWindow(), wxTextCtrl);
93 auto keycode = evt.GetUnicodeKey();
94 if (keycode < WXK_SPACE || keycode == WXK_DELETE) {
98 wxString path = tc->GetValue();
99 path.insert(tc->GetInsertionPoint(), keycode);
164 return XO(
"Preferences for Directories");
169 return "Directories_Preferences";
192 S.StartStatic(
XO(
"Default directories"));
195 S.AddFixedText(
XO(
"Leave a field empty to go to the last directory used for that operation.\n"
196 "Fill in a field to always go to that directory for that operation."),
false, 450);
199 S.StartMultiColumn(3, wxEXPAND);
208 S.Id(OpenButtonID).AddButton(
XXO(
"&Browse..."));
238 S.Id(MacrosButtonID).AddButton(
XXO(
"Bro&wse..."));
246 S.StartStatic(
XO(
"Temporary files directory"));
248 S.StartMultiColumn(3, wxEXPAND);
259 S.Id(TempButtonID).AddButton(
XXO(
"Brow&se..."));
262 .AddReadOnlyText(
XXO(
"&Free Space:"),
"");
286 XO(
"Choose a location to place the temporary directory"),
288 int retval = dlog.ShowModal();
289 if (retval != wxID_CANCEL && !dlog.GetPath().empty())
291 wxFileName tmpDirPath;
292 tmpDirPath.AssignDir(dlog.GetPath());
295 XO(
"Temporary files directory cannot be on a FAT drive."))) {
310#if defined(__WXMAC__)
311 newDirName = wxT(
"SessionData");
312#elif defined(__WXMSW__)
314 newDirName = wxT(
"SessionData");
316 newDirName = wxT(
".audacity_temp");
318 auto dirsInPath = tmpDirPath.GetDirs();
324 tmpDirPath != wxFileName(
mTempText->GetValue(), wxT(
"")) &&
325 (dirsInPath.size() == 0 ||
326 dirsInPath[dirsInPath.size()-1] != newDirName))
328 tmpDirPath.AppendDir(newDirName);
331 mTempText->SetValue(tmpDirPath.GetPath(wxPATH_GET_VOLUME|wxPATH_GET_SEPARATOR));
345 wxGetDiskSpace(path, NULL, &space);
347 label = wxDirExists(path)
349 :
XO(
"unavailable - above location doesn't exist");
357 long id = evt.GetId() - ButtonsStart;
358 wxTextCtrl *tc = (wxTextCtrl *) FindWindow(
id + TextsStart);
360 wxString location = tc->GetValue();
363 XO(
"Choose a location"),
365 int retval = dlog.ShowModal();
367 if (retval == wxID_CANCEL)
375 XO(
"Projects cannot be saved to FAT drives.")))
387 tc->SetValue(dlog.GetPath());
393 const wxFileName path { pathString };
396 XO(
"\nDirectory %s does not exist. Create it?")
399 wxYES_NO | wxCENTRE | wxICON_EXCLAMATION);
405 if (!path.Mkdir(0755, wxPATH_MKDIR_FULL)) {
409 XO(
"Directory creation failed.") +
413 .IconStyle(Icon::Error)
414 .ButtonStyle(Button::Ok)
426 wxString path{Temp.GetPath()};
429 XO(
"Directory %s is not suitable (at risk of being cleaned out)")
432 wxOK | wxICON_ERROR);
436 if (!Temp.DirExists()) {
443 XO(
"'Temporary files' directory cannot be set.")))
448 Temp.AppendDir(wxT(
"canicreate"));
449 path = Temp.GetPath();
450 if (!Temp.Mkdir(0755)) {
452 XO(
"Directory %s is not writable")
455 wxOK | wxICON_ERROR);
459 Temp.RemoveLastDir();
464 if (Temp != oldDir) {
467"Changes to temporary directory will not take effect until Audacity is restarted"),
468 XO(
"Temp Directory Update"),
469 wxOK | wxCENTRE | wxICON_INFORMATION);
472 const wxString openPathString =
mOpenText->GetValue();
473 const wxString savePathString =
mSaveText->GetValue();
474 const wxString importPathString =
mImportText->GetValue();
475 const wxString exportPathString =
mExportText->GetValue();
476 const wxString macroPathString =
mMacrosText->GetValue();
478 const std::initializer_list<TranslatableString> messagesPreference{
479 XO(
"'Open' directory cannot be set.") ,
480 XO(
"'Save' directory cannot be set.") ,
481 XO(
"'Import' directory cannot be set.") ,
482 XO(
"'Export' directory cannot be set.") ,
483 XO(
"'Macro Output' directory cannot be set.") ,
492 for (
auto &
string : { openPathString, savePathString, importPathString, exportPathString, macroPathString} ) {
493 const wxFileName currentPath {
string };
494 const auto & message = *(messagesPreference.begin() +
id);
496 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
EVT_COMMAND_RANGE(ID_Slider, ID_Slider+NUMBER_OF_BANDS - 1, wxEVT_COMMAND_SLIDER_UPDATED, EffectEqualization::OnSlider) EffectEqualization
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
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_) &&