mirror of
https://git.srhtnin.garden/sarah/SaraFem.git
synced 2026-10-15 02:23:17 +02:00
Add directory drop targets in the file list; fix Copy/Cut/Paste to use the real OS clipboard
Drag-and-drop: directories in the middle file list (list and grid view) are now drop targets too, same MoveIntoDirectory sidebar bookmarks and the filetree already use. Clipboard: Copy/Cut/Paste now goes through Clipboard.set_files/get_files (the real OS clipboard) instead of private in-process Python state, so it works between separate SaraFem windows and interoperates with other apps. Cut-vs-copy has no OS clipboard equivalent, so that one bit lives in a small ~/.cache/SaraFem/ClipboardMode.txt sidecar every window reads fresh on pass.
This commit is contained in:
1 parent
65f5b89908
commit
6c48796dde
2 files changed
+94
-26
No files matched your search
@@ -48,6 +48,28 @@ ActiveFontFamily = BundledFontFamily # set by ApplyAppearance, read by BuildThe
|
||||
CacheDir = Path.home() / ".cache" / "SaraFem"
|
||||
ThumbnailCacheDir = CacheDir / "Thumbnails"
|
||||
|
||||
# Copy/Cut/Paste uses the real OS clipboard (Clipboard.set_files/get_files —
|
||||
# see Browser._DoSetClipboard/_DoPaste) instead of private Python state, so
|
||||
# it actually works between two separate SaraFem windows (each its own
|
||||
# process) and interoperates with other apps' file managers. The one thing
|
||||
# the OS file clipboard has no concept of is a cut-vs-copy flag, so that one
|
||||
# bit lives here instead, in a tiny sidecar file every SaraFem window reads
|
||||
# fresh on Paste rather than trusting its own possibly-stale local state.
|
||||
ClipboardModePath = CacheDir / "ClipboardMode.txt"
|
||||
|
||||
|
||||
def SetClipboardMode(Mode: str) -> None:
|
||||
CacheDir.mkdir(parents=True, exist_ok=True)
|
||||
ClipboardModePath.write_text(Mode)
|
||||
|
||||
|
||||
def GetClipboardMode() -> str:
|
||||
try:
|
||||
Mode = ClipboardModePath.read_text().strip()
|
||||
except OSError:
|
||||
return "copy"
|
||||
return Mode if Mode in ("copy", "cut") else "copy"
|
||||
|
||||
# Config moved from ~/.config/SaraFem/ into a SaraSuite-wide layout so other
|
||||
# Sara* programs (SaraTag, SaraView) can eventually read from the same place.
|
||||
SharedConfigDir = Path.home() / ".config" / "SaraSuite"
|
||||
|
||||
Reference in new issue
Block a user