Documentation
¶
Overview ¶
Package shell holds the pure composition/model logic of the desktop shell: the launchable-app index, MIME "open with" resolution, the categorized application-menu model, the directory listing model and the thumbnail cache-key derivation. None of it touches a rendering surface, so every branch is unit-coverable against temp-dir fixtures; the render package turns these models into go-widgets widgets.
Index ¶
Constants ¶
const MimeDirectory = "inode/directory"
MimeDirectory is the MIME type the shell assigns to directory entries.
Variables ¶
This section is empty.
Functions ¶
func Thumbnailable ¶
Thumbnailable reports whether a file item should be given an image preview: a regular file whose classified MIME type is an image/* type. Directories, unclassified items and non-image files are not thumbnailed.
Types ¶
type App ¶
type App struct {
ID string
Name string
GenericName string
Comment string
Icon string
Exec string
Categories []string
Keywords []string
Terminal bool
// contains filtered or unexported fields
}
App is one launchable application, distilled from a desktop entry into the fields a dock / launcher needs. The originating entry is retained so the launcher can expand its Exec line at click time.
func (App) Entry ¶
func (a App) Entry() *desktopentry.Entry
Entry returns the desktop entry this App was built from (nil for an App that was not derived from one). The launcher passes it to desktopentry.ExpandExec.
type AppIndex ¶
type AppIndex struct {
// contains filtered or unexported fields
}
AppIndex is a sorted, de-duplicated, searchable set of launchable apps.
func NewAppIndex ¶
func NewAppIndex(entries []*desktopentry.Entry) *AppIndex
NewAppIndex builds an index from scanned desktop entries. Non-launchable entries (wrong Type, no Exec) are dropped; the first entry seen for a given non-empty id wins (desktopentry.Scan already applies XDG directory precedence, so "first" means "highest priority"). Apps are ordered case-insensitively by their display label.
type Category ¶
Category is one branch of the application menu: a user-visible directory name (plus its icon) and the launchable apps allocated to it.
type Dir ¶
Dir is a listed directory: its path and its items, directories first then files, each group ordered case-insensitively by name.
func ListDir ¶
ListDir lists path into a Dir. It does not classify MIME types (call Classify for that); a read failure (missing / unreadable directory) is returned as an error.
type MenuModel ¶
type MenuModel struct {
Categories []Category
}
MenuModel is the desktop application menu flattened into an ordered list of non-empty categories, ready to render as a go-widgets Menu / MenuBar. Nested submenus are walked depth-first, so a category appears once per menu node that carries apps, in menu (layout) order.
func NewMenuModel ¶
NewMenuModel flattens a resolved menu.Tree. A nil tree (or a tree with a nil Root) yields an empty model. Only menu nodes that actually contain apps become categories; a purely structural submenu with no direct apps is skipped but still descended into.
type OpenWith ¶
OpenWith is the resolved "open with" answer for a path or MIME type: the classified MIME type, the default application (if any) and the ordered list of candidate applications.
type Resolver ¶
type Resolver struct {
// contains filtered or unexported fields
}
Resolver answers MIME classification and application-association queries by combining a shared MIME-info database with a mimeapps.list resolver.
func NewResolver ¶
NewResolver wires a MIME database and an application-association resolver into a Resolver.
func (*Resolver) ResolveName ¶
ResolveName classifies a bare name plus optional content bytes and resolves the associated applications. It performs no I/O, so it is the pure seam the path-based helper builds on.
func (*Resolver) ResolvePath ¶
ResolvePath classifies path by both name and content and resolves its associated applications. Directories (and other non-regular paths) are classified by name only. A stat failure (e.g. the path does not exist) or a content-read failure is returned as an error.
type Thumbnailer ¶
type Thumbnailer struct {
// contains filtered or unexported fields
}
Thumbnailer derives the freedesktop Thumbnail Managing Standard cache keys and paths for a file grid. It delegates the URI canonicalization, MD5 hash and cache-path layout to github.com/go-thumbnail/thumbnail (the owner of that mechanism) and adds only the shell's policy: which items are thumbnailed and under which stable key.
func NewThumbnailer ¶
func NewThumbnailer(size thumbnail.Size) *Thumbnailer
NewThumbnailer builds a Thumbnailer for the given standard thumbnail size.
func (*Thumbnailer) Key ¶
func (t *Thumbnailer) Key(it FileItem) string
Key returns the stable cache key (the MD5 hash of the file's canonical file:// URI) for a thumbnailable item, or "" when the item is not thumbnailable. Two items with the same path always produce the same key.
func (*Thumbnailer) Path ¶
func (t *Thumbnailer) Path(it FileItem) string
Path returns the on-disk cache path where the item's thumbnail lives (or would be generated), or "" for a non-thumbnailable item.