Skip to main content

Module preview

Module preview 

Source
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§

ArchiveEntry
One archive member.
ArchiveListing
The first [ARCHIVE_ENTRIES] entries of an archive.
DocumentLines
The first max_lines lines of text, each capped in length, plus whether the file continues past what is shown.
ParseStatus
The result of parsing a structured document.
TableData
A parsed table: up to max_rows rows of up to max_cols cells.

Enums§

ArchiveData
An archive’s listing, or a description when its contents can’t be listed.
DocumentData
A parsed inline document, ready to render. One variant per non-media PreviewKind, so the tree’s render match stays exhaustive.
PreviewKind
What an inline preview can render for a file.

Functions§

detect
The preview path supports, if any. Directories return None: the caller previews their children instead.
load_document
Load the document behind kind. None when the file can’t be read or the kind is media (media is decoded by the tree, not here).