Windows support

This commit is contained in:
sarah committed 2026-10-09 14:30:59 +02:00
1 parent 6b2b35f5da
commit b295db3fb6
9 files changed
+136 -26

No files matched your search

+7 -4
View File
@@ -5,10 +5,13 @@ from pathlib import Path
import toml
from Core import BookmarksPath, ConfigDir
from Core import BookmarksPath, ConfigDir, IsWindows
DefaultIcon = "BOOKMARK_OUTLINE"
TrashPath = Path.home() / ".local" / "share" / "Trash" / "files"
# The freedesktop trash folder (Linux). Windows' Recycle Bin isn't a folder
# that can be browsed, so there's no Trash bookmark there (deleting still goes
# to the Recycle Bin, through send2trash).
TrashPath = None if IsWindows else Path.home() / ".local" / "share" / "Trash" / "files"
# One-time marker: without it, re-adding the Trash bookmark to old files (see
# LoadBookmarks) would run on every load and undo the user removing it.
@@ -41,7 +44,7 @@ def DefaultBookmarks() -> list[Bookmark]:
Bookmark("Documents", Path.home() / "Documents", "DESCRIPTION_OUTLINED"),
Bookmark("Downloads", Path.home() / "Downloads", "DOWNLOAD_OUTLINED"),
Bookmark("Pictures", Path.home() / "Pictures", "IMAGE_OUTLINED"),
Bookmark("Trash", TrashPath, "DELETE_OUTLINE"),
*([Bookmark("Trash", TrashPath, "DELETE_OUTLINE")] if TrashPath else []),
]
@@ -74,7 +77,7 @@ def LoadBookmarks() -> list[Bookmark]:
# Trash used to be a hardcoded Sidebar entry, not a real bookmark (so it
# couldn't be edited). Migrate existing bookmark files that predate that —
# but only once, so deliberately removing Trash afterwards actually sticks.
if not _TrashMigrationMarker.exists():
if TrashPath is not None and not _TrashMigrationMarker.exists():
if not any(B.Path == TrashPath for B in Bookmarks):
Bookmarks.append(Bookmark("Trash", TrashPath, "DELETE_OUTLINE"))
SaveBookmarks(Bookmarks)