mirror of
https://github.com/cookiengineer/audacity
synced 2025-06-16 16:10:06 +02:00
Use XDG dirs by default on Linux
Signed-off-by: Campbell Jones <git@serebit.com>
This commit is contained in:
parent
74f5f2ef98
commit
c0c275ffaf
@ -187,7 +187,11 @@ void AboutDialog::CreateInformationTab(ShuttleGui& AboutDialogGUI) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Location of settings
|
// Location of settings
|
||||||
AddBuildInfoRow(&informationStr, XO("Settings folder:"), FileNames::DataDir());
|
AddBuildInfoRow(&informationStr, XO("Config folder:"), \
|
||||||
|
FileNames::ConfigDir());
|
||||||
|
// Location of data
|
||||||
|
AddBuildInfoRow(&informationStr, XO("Data folder:"), \
|
||||||
|
FileNames::DataDir());
|
||||||
|
|
||||||
informationStr
|
informationStr
|
||||||
<< wxT("<h3>")
|
<< wxT("<h3>")
|
||||||
|
@ -681,7 +681,7 @@ IMPLEMENT_WX_THEME_SUPPORT
|
|||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
wxDISABLE_DEBUG_SUPPORT();
|
wxDISABLE_DEBUG_SUPPORT();
|
||||||
|
|
||||||
// Bug #1986 workaround - This doesn't actually reduce the number of
|
// Bug #1986 workaround - This doesn't actually reduce the number of
|
||||||
// messages, it simply hides them in Release builds. We'll probably
|
// messages, it simply hides them in Release builds. We'll probably
|
||||||
// never be able to get rid of the messages entirely, but we should
|
// never be able to get rid of the messages entirely, but we should
|
||||||
// look into what's causing them, so allow them to show in Debug
|
// look into what's causing them, so allow them to show in Debug
|
||||||
@ -1048,6 +1048,9 @@ bool AudacityApp::OnInit() {
|
|||||||
// AddHandler takes ownership
|
// AddHandler takes ownership
|
||||||
wxFileSystem::AddHandler(safenew wxZipFSHandler);
|
wxFileSystem::AddHandler(safenew wxZipFSHandler);
|
||||||
|
|
||||||
|
// encouraged by wxwidgets
|
||||||
|
wxStandardPaths::Get().SetFileLayout(wxStandardPaths::FileLayout::FileLayout_XDG);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Paths: set search path and temp dir path
|
// Paths: set search path and temp dir path
|
||||||
//
|
//
|
||||||
@ -1197,7 +1200,7 @@ bool AudacityApp::OnInit() {
|
|||||||
|
|
||||||
// Initialize preferences and language
|
// Initialize preferences and language
|
||||||
{
|
{
|
||||||
wxFileName configFileName(FileNames::DataDir(), wxT("tenacity.cfg"));
|
wxFileName configFileName(FileNames::ConfigDir(), wxT("tenacity.cfg"));
|
||||||
auto appName = wxTheApp->GetAppName();
|
auto appName = wxTheApp->GetAppName();
|
||||||
InitPreferences(AudacityFileConfig::Create(
|
InitPreferences(AudacityFileConfig::Create(
|
||||||
appName, wxEmptyString,
|
appName, wxEmptyString,
|
||||||
@ -1309,7 +1312,7 @@ bool AudacityApp::InitPart2() {
|
|||||||
|
|
||||||
AudacityProject* project;
|
AudacityProject* project;
|
||||||
{
|
{
|
||||||
// Bug 718: Position splash screen on same screen
|
// Bug 718: Position splash screen on same screen
|
||||||
// as where Audacity project will appear.
|
// as where Audacity project will appear.
|
||||||
wxRect wndRect;
|
wxRect wndRect;
|
||||||
bool bMaximized = false;
|
bool bMaximized = false;
|
||||||
@ -1326,11 +1329,11 @@ bool AudacityApp::InitPart2() {
|
|||||||
wxDefaultSize,
|
wxDefaultSize,
|
||||||
wxSTAY_ON_TOP);
|
wxSTAY_ON_TOP);
|
||||||
|
|
||||||
// Unfortunately with the Windows 10 Creators update, the splash screen
|
// Unfortunately with the Windows 10 Creators update, the splash screen
|
||||||
// now appears before setting its position.
|
// now appears before setting its position.
|
||||||
// On a dual monitor screen it will appear on one screen and then
|
// On a dual monitor screen it will appear on one screen and then
|
||||||
// possibly jump to the second.
|
// possibly jump to the second.
|
||||||
// We could fix this by writing our own splash screen and using Hide()
|
// We could fix this by writing our own splash screen and using Hide()
|
||||||
// until the splash scren was correctly positioned, then Show()
|
// until the splash scren was correctly positioned, then Show()
|
||||||
|
|
||||||
// Possibly move it on to the second screen...
|
// Possibly move it on to the second screen...
|
||||||
|
@ -47,6 +47,11 @@ used throughout Audacity into this one place.
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(__WXGTK__)
|
||||||
|
static wxString gOldUnixDataDir;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
static wxString gConfigDir;
|
||||||
static wxString gDataDir;
|
static wxString gDataDir;
|
||||||
|
|
||||||
const FileNames::FileType
|
const FileNames::FileType
|
||||||
@ -176,7 +181,7 @@ bool FileNames::HardLinkFile( const FilePath& file1, const FilePath& file2 )
|
|||||||
#ifdef __WXMSW__
|
#ifdef __WXMSW__
|
||||||
|
|
||||||
// Fix forced ASCII conversions and wrong argument order - MJB - 29/01/2019
|
// Fix forced ASCII conversions and wrong argument order - MJB - 29/01/2019
|
||||||
//return ::CreateHardLinkA( file1.c_str(), file2.c_str(), NULL );
|
//return ::CreateHardLinkA( file1.c_str(), file2.c_str(), NULL );
|
||||||
return ( 0 != ::CreateHardLink( file2, file1, NULL ) );
|
return ( 0 != ::CreateHardLink( file2, file1, NULL ) );
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -226,8 +231,49 @@ wxString FileNames::LowerCaseAppNameInPath( const wxString & dirIn){
|
|||||||
return dir;
|
return dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FilePath FileNames::ConfigDir()
|
||||||
|
{
|
||||||
|
#if defined(__WXGTK__)
|
||||||
|
if (gOldUnixDataDir.empty())
|
||||||
|
gOldUnixDataDir = wxFileName::GetHomeDir() + wxT("/.audacity-data");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (gConfigDir.empty())
|
||||||
|
{
|
||||||
|
wxFileName exePath(PlatformCompatibility::GetExecutablePath());
|
||||||
|
#if defined(__WXMAC__)
|
||||||
|
// Path ends for example in "Audacity.app/Contents/MacOSX"
|
||||||
|
// just remove the MacOSX part.
|
||||||
|
exePath.RemoveLastDir();
|
||||||
|
#endif
|
||||||
|
wxFileName portablePrefsPath(exePath.GetPath(), wxT("Portable Settings"));
|
||||||
|
if (::wxDirExists(portablePrefsPath.GetFullPath()))
|
||||||
|
{
|
||||||
|
// Use "Portable Settings" folder
|
||||||
|
gConfigDir = portablePrefsPath.GetFullPath();
|
||||||
|
#if defined(__WXGTK__)
|
||||||
|
} else if (::wxDirExists(gOldUnixDataDir))
|
||||||
|
{
|
||||||
|
// Use old user data dir folder
|
||||||
|
gConfigDir = gOldUnixDataDir;
|
||||||
|
#endif
|
||||||
|
} else {
|
||||||
|
// Use OS-provided user data dir folder
|
||||||
|
wxString configDir(wxStandardPaths::Get().GetUserConfigDir() + wxT("/audacity"));
|
||||||
|
gConfigDir = FileNames::MkDir(configDir);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return gConfigDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
FilePath FileNames::DataDir()
|
FilePath FileNames::DataDir()
|
||||||
{
|
{
|
||||||
|
#if defined(__WXGTK__)
|
||||||
|
if (gOldUnixDataDir.empty())
|
||||||
|
gOldUnixDataDir = wxFileName::GetHomeDir() + wxT("/.audacity-data");
|
||||||
|
#endif
|
||||||
// LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict
|
// LLL: Wouldn't you know that as of WX 2.6.2, there is a conflict
|
||||||
// between wxStandardPaths and wxConfig under Linux. The latter
|
// between wxStandardPaths and wxConfig under Linux. The latter
|
||||||
// creates a normal file as "$HOME/.audacity", while the former
|
// creates a normal file as "$HOME/.audacity", while the former
|
||||||
@ -251,12 +297,25 @@ FilePath FileNames::DataDir()
|
|||||||
{
|
{
|
||||||
// Use "Portable Settings" folder
|
// Use "Portable Settings" folder
|
||||||
gDataDir = portablePrefsPath.GetFullPath();
|
gDataDir = portablePrefsPath.GetFullPath();
|
||||||
|
#if defined(__WXGTK__)
|
||||||
|
} else if (::wxDirExists(gOldUnixDataDir))
|
||||||
|
{
|
||||||
|
// Use old user data dir folder
|
||||||
|
gDataDir = gOldUnixDataDir;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
wxString dataDir;
|
||||||
|
// see if XDG_DATA_HOME is defined. if it is, use its value. if it isn't, use the default
|
||||||
|
// XDG-specified value
|
||||||
|
if ( !wxGetEnv(wxS("XDG_DATA_HOME"), &dataDir) || dataDir.empty() )
|
||||||
|
dataDir = wxFileName::GetHomeDir() + wxT("/.local/share");
|
||||||
|
|
||||||
|
dataDir = dataDir + wxT("/audacity");
|
||||||
|
#else
|
||||||
} else
|
} else
|
||||||
{
|
{
|
||||||
// Use OS-provided user data dir folder
|
// Use OS-provided user data dir folder
|
||||||
wxString dataDir( LowerCaseAppNameInPath( wxStandardPaths::Get().GetUserDataDir() ));
|
wxString dataDir( LowerCaseAppNameInPath( wxStandardPaths::Get().GetUserDataDir() ));
|
||||||
#if defined( __WXGTK__ )
|
|
||||||
dataDir = dataDir + wxT("-data");
|
|
||||||
#endif
|
#endif
|
||||||
gDataDir = FileNames::MkDir(dataDir);
|
gDataDir = FileNames::MkDir(dataDir);
|
||||||
}
|
}
|
||||||
@ -317,12 +376,12 @@ FilePath FileNames::PlugInDir()
|
|||||||
|
|
||||||
FilePath FileNames::PluginRegistry()
|
FilePath FileNames::PluginRegistry()
|
||||||
{
|
{
|
||||||
return wxFileName( DataDir(), wxT("pluginregistry.cfg") ).GetFullPath();
|
return wxFileName( ConfigDir(), wxT("pluginregistry.cfg") ).GetFullPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath FileNames::PluginSettings()
|
FilePath FileNames::PluginSettings()
|
||||||
{
|
{
|
||||||
return wxFileName( DataDir(), wxT("pluginsettings.cfg") ).GetFullPath();
|
return wxFileName( ConfigDir(), wxT("pluginsettings.cfg") ).GetFullPath();
|
||||||
}
|
}
|
||||||
|
|
||||||
FilePath FileNames::BaseDir()
|
FilePath FileNames::BaseDir()
|
||||||
@ -472,7 +531,7 @@ wxFileNameWrapper FileNames::DefaultToDocumentsFolder(const wxString &preference
|
|||||||
|
|
||||||
// MJB: Bug 1899 & Bug 2007. Only create directory if the result is the default path
|
// MJB: Bug 1899 & Bug 2007. Only create directory if the result is the default path
|
||||||
bool bIsDefaultPath = result == defaultPath;
|
bool bIsDefaultPath = result == defaultPath;
|
||||||
if( !bIsDefaultPath )
|
if( !bIsDefaultPath )
|
||||||
{
|
{
|
||||||
// IF the prefs directory doesn't exist - (Deleted by our user perhaps?)
|
// IF the prefs directory doesn't exist - (Deleted by our user perhaps?)
|
||||||
// or exists as a file
|
// or exists as a file
|
||||||
|
@ -75,7 +75,7 @@ namespace FileNames
|
|||||||
, DynamicLibraries // depends on the operating system
|
, DynamicLibraries // depends on the operating system
|
||||||
, TextFiles // *.txt
|
, TextFiles // *.txt
|
||||||
, XMLFiles; // *.xml, *.XML
|
, XMLFiles; // *.xml, *.XML
|
||||||
|
|
||||||
using FileTypes = std::vector< FileType >;
|
using FileTypes = std::vector< FileType >;
|
||||||
|
|
||||||
// Convert fileTypes into a single string as expected by wxWidgets file
|
// Convert fileTypes into a single string as expected by wxWidgets file
|
||||||
@ -112,10 +112,15 @@ namespace FileNames
|
|||||||
FilePaths &otherNames, wxFileName &newName);
|
FilePaths &otherNames, wxFileName &newName);
|
||||||
|
|
||||||
AUDACITY_DLL_API wxString LowerCaseAppNameInPath( const wxString & dirIn);
|
AUDACITY_DLL_API wxString LowerCaseAppNameInPath( const wxString & dirIn);
|
||||||
|
/** \brief Audacity user config directory
|
||||||
|
*
|
||||||
|
* Where audacity keeps its settigns squirreled away, by default ~/.config/audacity/
|
||||||
|
* on Unix, Application Data/Audacity on Windows */
|
||||||
|
FilePath ConfigDir();
|
||||||
/** \brief Audacity user data directory
|
/** \brief Audacity user data directory
|
||||||
*
|
*
|
||||||
* Where audacity keeps its settings and other user data squirreled away,
|
* Where audacity keeps its settings and other user data squirreled away,
|
||||||
* by default ~/.audacity-data/ on Unix, Application Data/Audacity on
|
* by default ~/.local/share/audacity/ on Unix, Application Data/Audacity on
|
||||||
* windows system */
|
* windows system */
|
||||||
AUDACITY_DLL_API FilePath DataDir();
|
AUDACITY_DLL_API FilePath DataDir();
|
||||||
AUDACITY_DLL_API FilePath ResourcesDir();
|
AUDACITY_DLL_API FilePath ResourcesDir();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user