Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override incorrect dotnet paths in EtoSpecialFolders #2098

Merged
merged 3 commits into from
Feb 28, 2022

Conversation

Miepee
Copy link
Contributor

@Miepee Miepee commented Dec 31, 2021

  • Use XDG_DOWNLOAD_DIR on Linux for EtoSpecialFolder.Downloads (Fix GTK: EtoSpecialFolder.Downloads not following XDG user directories #2096) and the hardcoded download path for everything else.
  • Use XDG_DOCUMENT_DIR on Linux for EtoSpecialFolder.Documents and the harcoded download folder for Mac
  • Return XDG_CONFIG_HOME for EtoSpecialFolder.ApplicationSettings on Linux and HOME/Library/Preferences for Mac
  • update some documentation

Note:
You can apparently rename core user folders in windows, and windows does update them somewhere in the registry. Thus, for EtoSpecialFolder.Downloads it would be more accurate to fetch the downloads folder from the registry.
The exact key is in HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\{374DE290-123F-4565-9164-39C4925E467B}, however there's also a really neat warning with !Do not use this registry key - Use the SHGetFolderPath or SHGetKnownFolderPath function instead 🙃

- Use XDG_DOWNLOAD_DIR on Linux for EtoSpecialFolder.Downloads (Fix picoe#2096) and the hardcoded download path for Mac
- Use XDG_DOCUMENT_DIR on Linux for EtoSpecialFolder.Documents and the harcoded download folder for Mac
- Return XDG_CONFIG_HOME for EtoSpecialFolder.ApplicationSettings on Linux and HOME/Library/Preferences for Mac
- update some documentation
@ManuelHu
Copy link
Contributor

While the currently returned folders are definitely not correct, I'm not sure if this change is great for a 2.x release - it will break all applications that assume e.g. a config file has been written in EtoSpecialFolder.ApplicationSettings.

Independent of the version this will be merged into, all those applications would need some some sort of (platform dependant) upgrade code that has to replicate Eto's old behaviour to be able to migrate old settings files etc. I'm not quite sure how this should be addressed...

@Miepee
Copy link
Contributor Author

Miepee commented Feb 13, 2022

Something that could probably help with this, is to not replace the original values.
Keep EtoSpecialFolder.ApplicationSetting, EtoSpecialFolder.Documents and EtoSpecialFolder.Downloads as they are but mark them as deprecated, and introduce something along the lines of ApplicationSettingsDirectory, DocumentsDirectory and DownloadsDirectory which return the corrected values. That way devs can slowly migrate to the fixed variants with the old methods still available.

At the end of the day, it's up to @cwensley though to decide how this should be handled.

Also fixed a case where the XDG_User_Dir was not considered disabled and didn't use the fallback.
@Miepee
Copy link
Contributor Author

Miepee commented Feb 22, 2022

Took cwensley's suggestion in glitter/matrix and implemented a variable that determines now if the new folders should get returned or the legacy ones.
By default, it will return the new folders, but you can opt-out and use the old behaviour by setting Eto.Gtk.EtoEnvironment.UseXDG to false in your GTK application. The only affected variables by this are ApplicationSettings (Mac), Documents (Mac+Linux) and Downloads (Mac+Linux). Hope documentation for the variable is sufficient.

@ManuelHu
Copy link
Contributor

Yes, that solution sounds reasonable to me. 👍🏻

src/Eto/EtoEnvironment.cs Outdated Show resolved Hide resolved
@cwensley cwensley added this to the 2.6.2 milestone Feb 28, 2022
@cwensley
Copy link
Member

Thanks @Miepee for the PR! It looks great!

@cwensley cwensley merged commit 4d83d60 into picoe:develop Feb 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GTK: EtoSpecialFolder.Downloads not following XDG user directories
3 participants