patch_1.diff:
- Do not use data_path_global for user-data when C::B starts in portable mode.
It's not portable to have user-data in global-path and (what's more) the global-data-path is not user-writable on linux (and Mac?).
Instead keep the user-data in the exe-path (as the config-files.
patch_2.diff:
- BrowseTracker-plugin: use ConfigManager do determine the config-folder.
It's better maintainable and should work correct after last commit.
And it does not (try to) write the conf-file in the root-folder with new personalities.
patch_3.diff:
- CodeSnippets-plugin: use ConfigManager do determine the config-folder.
It's better maintainable and should work correct after last commit.
patch_4.diff:
- DoxyBlocks-plugin: use ConfigManager do determine the config-folder.
It's better maintainable and should work correct after last commit.
And it does not (try to) write the conf-file in the root-folder with new personalities.
patch_5.diff:
- Linux: Use standard-conform paths for config- and data-folders.
Use glib to determine the paths, as wxWidgets still can not do this.
All platforms: move UserTemplates into share/codeblocks to have the same layout on all platforms.
The old config and usewr-data folders are moved to the correct place (after a hint).
Are there patches supposed to be applied with git am?I never used git am and the patches are normal git diffs, but they are overworked with a script to make them (tortoise-)svn compatible.
OK... Is there any particular reason for using glib function instead of wxStandardPathsBase::GetDocumentsDir()?GetDocumentsDir() just returns the users home-folder.
wxString wxStandardPathsBase::GetDocumentsDir() const
{
#if defined(__UNIX__) && !defined(__WXMAC__)
{
wxLogNull logNull;
wxString homeDir = wxFileName::GetHomeDir();
wxString configPath;
if (wxGetenv(wxT("XDG_CONFIG_HOME")))
configPath = wxGetenv(wxT("XDG_CONFIG_HOME"));
else
configPath = homeDir + wxT("/.config");
wxString dirsFile = configPath + wxT("/user-dirs.dirs");
if (wxFileExists(dirsFile))
{
wxTextFile textFile;
if (textFile.Open(dirsFile))
{
size_t i;
for (i = 0; i < textFile.GetLineCount(); i++)
{
wxString line(textFile[i]);
int pos = line.Find(wxT("XDG_DOCUMENTS_DIR"));
if (pos != wxNOT_FOUND)
{
wxString value = line.AfterFirst(wxT('='));
value.Replace(wxT("$HOME"), homeDir);
value.Trim(true);
value.Trim(false);
if (!value.IsEmpty() && wxDirExists(value))
return value;
else
break;
}
}
}
}
}
#endif
return wxFileName::GetHomeDir();
}
wxStandardPaths::GetDocumentsDir
wxString GetDocumentsDir() const
Return the directory containing the current user's documents.
Example return values:
Unix: ~ (the home directory)
Windows: C:\Documents and Settings\username\Documents
Mac: ~/Documents
This function is new since wxWidgets version 2.7.0
virtual wxString wxStandardPaths::GetDocumentsDir() const
Return the directory containing the current user's documents.
Example return values:
Unix: ~ (the home directory)
Windows: "C:\Documents and Settings\username\My Documents"
Mac: ~/Documents
Since
2.7.0
See Also
GetAppDocumentsDir()
wxString wxStandardPathsBase::GetDocumentsDir() const
{
return wxFileName::GetHomeDir();
}
We also have dependencies on several other third-party libs, like e.g. gtk+ .I think we will be able to drop this dependency when we switch to wx30.
I worked on this patche(es), because I got mails from other (linux) developpers and maintainers, that asked for more standard-compliancy.I like the idea, so I'm not against the change.
Currrently I do not have the power or the time to work much on C::B...No problem with that, could you give me raw git patches, so I can continue your work?
wxGTK already depends on glib, so it is not really a new dependency.From the point of view of C::B it is abstracted away. If you want to go with the glib dependency, you'll have to change the spec file and probably the debian files.
I think we should drop the wx2.8 compatibility as soon as possible after moving to wx3, because the actual code is already cluttered with compatibility-ifdefs and hard to maintain therefore.+1 here.
wxString XDGUserData()
{
wxString data_home;
if (wxGetEnv(wxT("XDG_DATA_HOME"), data_home))
return wxFileName(data_home, wxT("codeblocks")).GetFullPath();
else
return wxFileName(wxFileName::GetHomeDir(),wxT(".local/share/codeblocks")).GetFullPath();
}
wxString XDGUserConfig()
{
wxString config_home;
if (wxGetEnv(wxT("XDG_CONFIG_HOME"), config_home))
return wxFileName(config_home, wxT("codeblocks")).GetFullPath();
else
return wxFileName(wxFileName::GetHomeDir(),wxT(".config/codeblocks")).GetFullPath();
}
void ConfigManager::InitPaths()
{
ConfigManager::config_folder = ConfigManager::GetUserDataFolder();
ConfigManager::home_folder = wxStandardPathsBase::Get().GetUserConfigDir();
Also, why in line 1475 of the unpatched code are we setting home_folder to the config dir?It's only used on windows in crashhandler.cpp in CrashHandlerSaveEditorFiles().Codevoid ConfigManager::InitPaths()
{
ConfigManager::config_folder = ConfigManager::GetUserDataFolder();
ConfigManager::home_folder = wxStandardPathsBase::Get().GetUserConfigDir();
What is home_folder supposed to mean? I guess it's not used anywhere but still...
Yes , I forgot these files. Even if it works, because glib2-devel is in the dependency-chain of wxGTK-devel (at least on Fedora), but this is , of course, not guaranteed.wxGTK already depends on glib, so it is not really a new dependency.From the point of view of C::B it is abstracted away. If you want to go with the glib dependency, you'll have to change the spec file and probably the debian files.
ln -s ~/.config/codeblocks ~/.codeblocks
mkdir ~/.codeblocks/share
ln -s ~/.local/share/codeblocks ~/.codeblocks/share/codeblocks
Please test and give feedback, especially tests on Mac would be fine, because the the portable stuff has slightly changed: if the main config-file is found besides the executable, the user-data folder should always be there and not in the global-data-folder.OK, so I've ran it some days now (Jens: The all-in-one-patch worked flawlessly) and so far I see no issues on Windows. Even better: The not portable files like dragscroll and the spellchecker stuff are now truly portable and work.