Expand description
Inline file previews.
“View Thumbnail” is really a generic inline-preview toggle: it shows a small
rendering of a file below its row. This module decides what a file can
show and loads the data; crate::ui::tree turns that data into widgets.
Detection is content-based. The file’s first bytes are handed to GIO’s
content_type_guess alongside its name, so extensionless and misnamed files
classify correctly (fake.png holding text is text, not an image). A
well-known extension is only consulted as a tiebreaker when the content is
unrecognisably generic (an empty file, say).
PreviewKind is the single registry: add a variant there, teach
[kind_for_content_type] about it, add a DocumentData arm, and the tree
gains the new preview.
Structs§
- Archive
Entry - One archive member.
- Archive
Listing - The first [
ARCHIVE_ENTRIES] entries of an archive. - Document
Lines - The first
max_lineslines oftext, each capped in length, plus whether the file continues past what is shown. - Parse
Status - The result of parsing a structured document.
- Table
Data - A parsed table: up to
max_rowsrows of up tomax_colscells.
Enums§
- Archive
Data - An archive’s listing, or a description when its contents can’t be listed.
- Document
Data - A parsed inline document, ready to render. One variant per non-media
PreviewKind, so the tree’s render match stays exhaustive. - Preview
Kind - What an inline preview can render for a file.
Functions§
- detect
- The preview
pathsupports, if any. Directories returnNone: the caller previews their children instead. - load_
document - Load the document behind
kind.Nonewhen the file can’t be read or the kind is media (media is decoded by the tree, not here).