Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Choosing files

FilesPlugin (in DefaultPlugins, egui_pop::api::files) chooses files and folders without ever holding a frame: Files::choose returns a Pending, the host contract’s result to come (ADR 0010), which gives { "paths": [...] }, or null when the person cancelled.

  • The in-app picker, egui-pop’s own: what answers, unless an application turns to the fallback below.
  • The system’s chooser (feature native-dialogs of the facade, through rfd): a fallback kept in case an application cannot do with the in-app picker, off at build time and at run time. The xdg desktop portal on Linux, the common dialogs on Windows, the open and save panels on macOS. It is made on the interface thread and awaited on a thread of its own.
use egui_pop::api::files::{self, Chosen, FileRequest, FilesPlugin, FILES};
use egui_pop::egui;
use egui_pop::prelude::*;

let mut app = App::builder().plugin(FilesPlugin::in_app()).build(&egui::Context::default()).unwrap();
let h = app.handle().clone();
let f = h.service(&FILES).unwrap();
let pending = f.choose(
    &h,
    FileRequest::open("Open an image").filter("Images", &["png", "jpg"]),
);
// The picker is open; the frame goes on. An agent (or a test) answers it
// as a person would.
let id = f.open_ids()[0];
f.deliver(id, Some(vec!["/photos/harbour.png".into()])).unwrap();

// The next frame finishes the choice (the `file.chosen` step).
let ctx = egui::Context::default();
let mut out = ctx.run_ui(egui::RawInput::default(), |ui| app.show(ui));
out.textures_delta.clear(); // no renderer here
let result = pending.take().unwrap();
assert_eq!(files::chosen(&result), Ok(Chosen::Paths(vec!["/photos/harbour.png".into()])));

A request is one of FileRequest::open, open_many, save (with a proposed name) and folder, with a starting directory, a purpose and filters. A path field of a form dialog (Descriptor::path) goes through the same chooser when its Browse button is pressed; inside a dialog of its own, an application starts the choice with Files::choose_inline and draws the in-app picker where it wants it (Files::show_inline). Files::highlighted says which entry it highlights, for another panel to follow (linked panels).

The system’s chooser, a fallback

The system’s chooser is never used by itself. It takes all of these:

  1. the native-dialogs feature, off by default (build time);
  2. the application allowing it, AppBuilder::system_file_chooser(true), off by default (run time). Only then is the person’s setting files.native declared, on by default;
  3. that setting on, a request without choices (rfd cannot show them) and, on Linux and the BSDs, a session bus for the portal;
  4. no test running. files::system_chooser_refused refuses it, whatever the feature and the application say, when any of these holds (files::system_chooser_refusal says which):
    • cfg(test): egui-pop-api’s own unit tests;
    • a harness of egui_pop_test was made: each (app, app_at, app_wgpu, harness_for, themed) calls files::refuse_system_chooser, for the whole process, so an application’s own tests built on it are covered;
    • EGUI_POP_TEST is set in the environment (egui-pop’s CI sets it), for a test run that uses neither;
    • the process is a test of cargo-nextest (NEXTEST);
    • the frames come with no window’s focus: egui_kittest and a bare Context::run say none, while a window of eframe or egui-winit always says whether it has the focus. An integration that does not report it gets the in-app picker.
use egui_pop::prelude::*;

// A fallback for an application that cannot do with the in-app picker.
let builder = App::builder()
    .plugins(egui_pop::api::DefaultPlugins)
    .system_file_chooser(true);
let _ = builder;

Tests never need it, and never build with it: test with the default features. CI only lints native-dialogs (clippy), it runs no test with it.

The last folder per purpose

FileRequest::purpose("import") names what the choice is for. Its last folder is kept under that key, so an import and an export do not share one, as Windows’ SetClientGuid and the identifier of a macOS panel do.

use egui_pop::api::files::FileRequest;

// Starts in ~/Pictures the first time, then where the last import was made.
let import = FileRequest::open("Import").purpose("import").directory("/home/me/Pictures");
// Always starts in the document's folder; still updates the last folder.
let save_as = FileRequest::save("Save as", "a.png").purpose("export").force_directory("/work/doc");
let _ = (import, save_as);

With a purpose, a choice starts in the first of these that exists:

  1. the purpose’s last folder (files::last_folder);
  2. the request’s directory: a first-time default, as Windows’ guidance has it (SetDefaultFolder, which does not hide the last location, rather than SetFolder, which does);
  3. home.

So an explicit directory does not beat a remembered folder on later openings. A request that means it uses FileRequest::force_directory, which swaps the first two (SetFolder).

  • What is kept. On a choice only (a cancel keeps nothing): the folder chosen, or the parent of the first path, as file.chosen gives it after its hooks. It is in the host’s store, saved with the settings (settings/files.last_folders), for the last LAST_FOLDERS_KEPT (32) purposes.
  • Recent places stay global. A purpose without a last folder or a directory starts at home, not in the last recent place, which may be another purpose’s.
  • No purpose keeps nothing per choice: the request’s directory, else the last recent place, else home.
  • The system’s chooser gets the same folder through rfd’s set_directory, and only that: rfd has no SetClientGuid, and how far a system honours a suggested folder is up to it. egui-pop has not run one to see it.
  • A FilePicker drawn on its own has no store and starts in the request’s directory; its caller remembers.

The in-app picker

  • The field filters the folder with the fuzzy filter the choice dialog uses; with a / (or starting with ~) it is a path, and Tab completes it.
  • The folder reads as breadcrumbs, beside the row’s controls (under them when they leave too little room). A segment opens its folder; the chevron after it lists its subfolders, by name, hidden ones only when the list shows them. A segment on the folder shown reads that folder again. When the path does not fit, its start collapses behind a … button listing those folders, the nearest first: the deepest segments stay, and the deepest alone is cut only when it does not fit by itself.
    • Every segment, chevron and … is a named stop (Open folder photos, Subfolders of photos, Folders above). Enter or Space on a chevron opens its menu with the focus on the folder on the path, else on the first; Up and Down go round it, Enter chooses, Tab or Escape close it and the focus goes back to the chevron. A folder without subfolders or that cannot be read says so, in the menu and to a screen reader.
    • Choosing a folder this way hands the keyboard to the field, as a click on a row does.
  • Ctrl+L (the file.edit_path command, rebindable, for agents too) puts the folder into the field as a path to edit, the cursor at its end, in place of a filter; a path being typed stays. Typing / or ~ while an entry has the focus starts a path there, as in GTK and macOS. They are what is typed, whichever keys make them on the layout. There is no second field: the one that filters takes the path, and completes it with Tab. Saving, Ctrl+L keeps the name at the path’s end with its stem selected, and a path that leads to another folder brings that name back there.
  • A click on Up, the bookmark button, List or Grid gives the keyboard back to the field, where a press would otherwise leave nothing focused; with Enter or Space the focus stays on the button. A typed .. is resolved in the folder’s path: go takes it out by its name, without asking the file system, so a/link/.. is a, even if link is a link elsewhere.
  • A click selects; a double click or Enter opens: Enter on a folder goes into it, on a file chooses it. A click no longer enters a folder, so a mis-click navigates nowhere. Ctrl is Cmd on macOS, here as in the keymap.
  • Arrows move the highlight (what the preview is of, and what Enter acts on); Backspace in an empty field or Alt+Up goes to the parent folder; Ctrl+Enter chooses the folder (choosing a folder) or the selection; Ctrl+D bookmarks the folder; Escape cancels (from the field, the first Escape lets go of the focus, as everywhere in egui-pop).
  • Alt+Left and Alt+Right go back and forward through the folders shown (as Windows and Blender), Ctrl+H shows or hides hidden files (as GTK and KDE), F5 reads the folder again, Alt+P shows or hides the preview. They are commands of the keymap (file.back, file.forward, file.toggle_hidden, file.reload, file.toggle_preview), so they can be rebound, and the check boxes’ tips say their keys as bound. A FilePicker drawn on its own reads the default keys itself (go_back, go_forward, reload).
  • The field keeps the keyboard: a click on a row gives it back, so typing goes on filtering. Tab goes on to the rows: a row holding the focus moves the highlight there, Space clicks it, and Enter and the arrows work from it as from the field.
  • Several files (FileRequest::open_many only). A click selects that file alone; Ctrl+click adds or takes one away; Shift+click and Shift+arrows select from the last one clicked or moved to, as a range; Ctrl+Space selects or unselects the highlighted file; Ctrl+A selects every file shown. Plain arrows leave the selection as it is, for Ctrl+Space further on. Selected rows are filled and a ring marks the highlight, which is a separate thing here. A line under the list counts the selection (Selected: 3, or Selected: 3 (2 not shown) when the filter hides some, which stay selected), and each change is announced to screen readers. With nothing selected, it says that Enter or the button acts on the highlighted entry.
    • Enter or the button then takes the selection, wherever the highlight is among files. On a folder Enter goes into it, and going to another folder leaves the selection behind, so nothing is chosen unseen. A double click opens that file alone.
    • A folder is not selected with the files: Ctrl+click or Ctrl+Space on one says so in the picker, and a range leaves folders out. Ctrl+A with no file shown says that too. In a typed path, Ctrl+A is the field’s.
    • file.select_all (Ctrl+A) and file.toggle_selection (Ctrl+Space) are commands: rebindable, and only bound while a picker offers them (filePickerSelectAll, filePickerSelects), so Ctrl+A selects the field’s text in any other request.
    • In the grid, a rubber band drawn from the room around the cells selects the files it crosses as it goes (folders left out), the highlight on its last file once it is let go: the file browser’s band.
  • One file. Modifiers add nothing: any click or arrow moves the single highlight, which is the selection.
  • Choosing a folder. Nothing is selected at first and the line under the list says what the button takes: the folder shown. A click or an arrow selects a folder in the list, and the line says the button now chooses it and Enter goes into it; Ctrl+click or Ctrl+Space unselects it. The change is announced. Typing a filter drops the selection for the filter’s first match.
  • Beside the list, a preview pane: the highlighted entry’s preview (below) and its facts: a file’s size and modification time (in UTC), a folder’s items, dimensions, pages, and the provider’s own. Alt+P (as in the Windows file explorer) or the Preview box shows or hides it; the files.preview setting remembers. The dialog keeps its size either way: the pane takes its width from the list’s, the list keeps at least LIST_MIN_WIDTH (240), and with less room the pane shrinks first, down to PANE_MIN_WIDTH (120), under which it is not drawn.
  • The dialog is yours to size: drag its edges and corners, down to PICKER_MIN_SIZE (640 by 280 points) and within the window. Its bottom right corner is a handle for the keyboard too: Tab reaches it, the arrows resize (with Shift, by bigger steps). The size starts at PICKER_WIDTH by PICKER_HEIGHT (960 by 398 points) and is kept in the host’s store (settings/files.dialog_size, read with files::dialog_size). A size that no longer fits the window when the picker opens (a smaller screen) goes back to the default; one the window comes to hold smaller while the picker is open stays as it was asked, and comes back when the window grows.
  • Between the list and the pane, a splitter sets the pane’s width: drag it, or Tab to it (from the field, past the places; in a typed path Tab completes instead) and use the left and right arrows, with Shift for bigger steps. It stays within the limits above; a double click or Enter gives the default width back (preview::PANE_WIDTH, 240). The width is kept in settings/files.pane_width (files::pane_width). The places column keeps its fixed 150 points.
  • With previews, the file browser’s mode switcher beside the folder shows the entries in its details mode (a list with columns) or its thumbnails mode (a grid of thumbnails from the same providers), also with Ctrl+1 and Ctrl+2 (the file.view.mode1 to file.view.mode9 commands, active while a file browser holds the keyboard). Each dialog reopens in the mode it was last shown in: by its request’s purpose, else its kind (open, open_many, save, folder), kept in the host’s store (settings/files.views, read with files::view_for); a dialog never shown opens in the mode last used (settings/files.view, files::view; list and grid, kept before the modes, read as details and thumbnails). A picker without previews keeps its list.
  • Choosing a folder, the switcher also offers the columns mode, Finder’s column view (FilePicker::views lists what a picker offers): the path’s folders side by side from the root, the folder shown’s subfolders, then the highlighted folder’s. Up and Down move in the folder shown’s column and select, Right goes into the highlighted folder (the selection left behind, so the folder entered is the choice), Left goes back to the parent with the folder left selected, and a click in another column goes to that folder with the folder clicked selected. The button chooses the folder selected, else the folder shown, as in the list. Columns last used by a folder chooser are not a file dialog’s: it opens in details. The grid’s zoom is a count of thumbnails per row (browser::ThumbZoom, the library grid’s Zoom): five at first, one across at most, and no more than cells of THUMBNAIL_MIN_SIZE (64 points) fit. The cells share the grid’s width, so the zoom survives a resize: a wider dialog shows the same count, larger. The slider beside the switch (fewer, larger to the right), Ctrl and the wheel over the grid, or Ctrl and + or - step it; it is kept in settings/files.thumbnails_per_row (files::thumbnail_zoom, files::want_thumbnails_per_row). A size in points an older version kept in settings/files.thumbnail_size is read until then, and converted to the count it gives at the grid’s width when the grid is next drawn. Only the cells in view ask for a thumbnail, so a folder of thousands of raws costs what a dialog’s worth does: what leaves the view leaves the worker’s queue (see Previews); the row after the last in view is asked next, as the file browser does. A placeholder stands in until a thumbnail is made; a folder shows its sign and asks for nothing, a file without an image the file’s sign, a failure a warning with its reason in a tip.
  • In the grid, the four arrows move the highlight in two dimensions, Home and End go to the first and the last entry, and Shift with any of them extends a selection of several files; Enter, a click and a double click are the list’s. While the field holds text and the focus, Left, Right, Home and End move its cursor, and only Up and Down the highlight: Tab to a cell gives all of them to the grid, and the focus then follows the highlight.
  • The list has columns: the name, when it last changed (in UTC, as in the pane), the size, and the type (a file’s extension; a file without one says File, a folder Folder). A folder has no size, so choosing a folder shows the name and the time alone. When the list is too narrow for them and at least NAME_MIN_WIDTH (140) of name, they go: the type first, the modification time last; a name cut short shows whole in a tip.
  • Only the rows in view are drawn, so a folder of thousands of files costs what a dialog’s worth does. Tab walks the rows drawn, then leaves the list; the arrows go on through the whole folder, scrolling.
  • A click on a header sorts by that column, and another turns it. The name and the type start upwards, the size and the time with the largest and the newest first, as Finder and Nautilus do. There is always an order: unlike the data table’s headers, these do not go back to none. The headers stay above the grid, whose cells follow the same order, and Tab reaches them. The order is kept in settings/files.sort (name, -name for downwards, and size, modified, type the same way; files::sort_order), and the highlighted entry stays highlighted, wherever it lands.
  • Names sort as people read them (files::sort::natural_cmp): IMG_9 before IMG_10, whatever the case. It compares characters rather than following a language’s collation, so é comes after z. What has no value in a column (a folder’s size and type, a time the file system does not give) goes last in both directions, and the name settles ties, upwards.
  • Folders stay first in every order, in the same direction among themselves. The Folders first box and the files.folders_first setting (files::folders_first), as GTK’s sort-directories-first, sort them among the files instead.
  • While the field filters, its best matches come first, the order settling only what ties: the headers are disabled then, their tip says why, and the arrow goes until the field is empty. A typed path, and the name when saving, do not rank.
  • The size and the time are read off the file system once per listing, for the rows in view; sorting by either reads them all then, on the interface thread, as listing the folder does. Sorting by name or type reads nothing more.
  • Beside the folder, a side bar that scrolls: home, the system’s folders (Desktop, Documents, Downloads, Pictures, Music, Videos, those that exist), the volumes mounted under Devices (a camera card is the first place of a photo import), the recent places and the bookmarks. See Places.
  • Below: the request’s filters (and all files), hidden files.
  • For assistive technology, the entries, in the list or the grid, are a list box named by the folder (Files in Photos; several selectable when choosing several files), each entry an option, selected as its row shows, and the highlighted entry its current one (active descendant). The preview pane is a group named Preview. Another folder is announced with how many entries it shows (2026, entries: 12). The grid’s thumbnails are never smaller than 64 points.
  • Files that go together can be one entry, by the application’s rules: see Grouped files.

Places

  • The system’s folders come from the XDG user directories on Linux and the BSDs (user-dirs.dirs, so a French desktop’s Images is Pictures), and from the folders of the same names in home on macOS and Windows (a folder Windows moved elsewhere, to OneDrive for instance, is not found). One that does not exist, or is home itself, is not listed.
  • Devices are the volumes mounted: on Linux the mount points under /run/media/<user>, /media/<user>, /media and /mnt (a folder on another device than its parent’s), on macOS /Volumes without the system’s own, on Windows the drives from C:. They are read when a picker opens, not each frame.
  • An application’s own. Files::set_system_places gives them instead of the system’s (files::places::SystemPlaces): a demo, a sandbox, tests. The gallery gives its demo folder’s. The web build has none.
  • Bookmarks. Ctrl+D or the button bookmarks the folder. A bookmark’s menu (a secondary click) renames it, moves it up or down, or removes it. A name is typed over the old one: Enter, or leaving the field, keeps it; Escape keeps the old one; an empty name gives back the folder’s. The functions files::rename_bookmark, files::move_bookmark and files::set_bookmark do the same for an application.
  • An application’s sections. A files::places::PlaceProvider registered on Files::place_providers (or with FilesPlugin::places) adds PlaceSections of PlaceItems: a photo import’s cards, services and history. An item has a name, an icon of the icon registry, a detail (its tip), a badge said with its name (“EOS_DIGITAL, 214”) and, for a folder, its path. The picker lists the folders of each section under its bookmarks, each title a heading. A provider answers from what it holds: it is asked each time a picker or a panel is drawn. egui-pop knows nothing more of an item: an account of a service is an item without a path, the application’s to act on.
  • A panel of places on its own. files::places::PlacesPanel draws sections anywhere (an import window’s sources column): one Tab stop, Up and Down from item to item across the sections, Enter, Space or a click chooses (PlacesOutput::chosen, with the section’s id), the item shown selected by id, a context menu per item (PlacesPanel::menu). Files::places and Places::sections give every place the picker lists as sections (files.places, files.devices, files.recent, files.bookmarks, then the application’s). The gallery’s file browser page shows one beside the browser.
  • An import window’s sources column, each part opt-in (a panel without them looks as before): a section folds under its band (PlaceSection::foldable; PlaceSection::open when the application keeps the state, the user’s clicks in PlacesOutput::folded), says what it lacks when empty (PlaceSection::empty, “No cards”) or stays for the application’s content (PlaceSection::keep). An untitled section (PlaceSection::untitled, a library’s “All photos” above its titled sections) draws no heading and no fold band, its rows shown directly; it stays a group for screen readers, named by the name it was given. An item shows a line under its name, said as its description (PlaceItem::line: why in a word, never in a tip only), a badge in a tone (PlaceItem::badge_tone, a warning ▲), and a toggle at its end (PlaceToggle, a pin), reported in PlacesOutput::toggled: the application flips its state. PlacesPanel::under_item and PlacesPanel::under_section hand the application the room under an item (an account’s albums) or a section’s items (a history’s past imports with “Import again”); their widgets join the panel’s keyboard order. The gallery’s places page shows them all.
  • A library’s sources, each part opt-in too: an item’s children (PlaceItem::children) make its section a tree, rows indented by depth under a toggle named after the item (“Show or hide Animals”), open at first (PlaceItem::open_at_first) or kept by the application (PlaceItem::open, the user’s clicks and arrows in PlacesOutput::expanded); Right opens and Left folds a branch from its row, each row is said at its level. A dimmed item (PlaceItem::dimmed, a folder of an offline volume) is drawn muted and said unavailable, still choosable. PlacesPanel::on_row hands the application each row’s Response (a drop target or a drag source through bus::drag, a menu of its own), and PlacesPanel::selected_set selects one item in each of several sections (a folder, an album and a keyword together). A tree draws VS Code’s indent guides when asked (PlacesPanel::indent_guides: IndentGuides::Never by default, OnHover while the pointer is over the panel, Always), in the kit’s list-guide, the hovered row’s parent’s guide lit with PlacesPanel::indent_guide_highlight (list-guide.hover.border-color). An item’s name can be a compacted chain, a / b / c (PlaceItem::segments of PlaceSegments, the separator drawn by the panel): each segment is underlined under the pointer, its own click target and its own node named by the chain up to it (or its PlaceSegment::name, a full path), and a click on it comes back in PlacesOutput::segment (its index and id) instead of chosen: the application decides. The row keeps its selection, hover, keyboard and tip. The gallery’s places page shows a Library’s sources beside the import column.
  • Kept in the host’s store with the settings: settings/files.recent, settings/files.bookmarks, and the names given in settings/files.bookmark_names.

Saving

  • A folder in the list. A click or an arrow selects it: Enter, and the button, which reads Open then, go into it, the name kept. Typing in the field takes the selection back, and Enter saves. A click on a file puts its name in the field; an arrow onto a file leaves the name alone.
  • The name. The field proposes the request’s name with its stem selected, whenever the field gets the focus: typing replaces the name and keeps the extension. A click in the field places the cursor as usual.
  • The extension. Enter or Save appends the active filter’s first extension to a name that has none (dawn gives dawn.png). When the filter changes, a name whose extension one of the request’s filters names takes the new filter’s first (dawn.png gives dawn.jpg), as Windows’ dialog does, unless the new filter accepts it too. An extension no filter names is the person’s and is never touched (dawn.tiff stays under PNG), and all files, or a filter without extensions, leaves the name as it is. A hidden file’s name (.config) gets no extension; what follows a dot in Mr. Smith holds a space and is not one, so that name gets one.
  • Replacing a file. When the name exists, the picker asks first through the dialogs plugin, with a Confirm in the danger style: “Replace a.png?”, the focus on Cancel. No key accepts it from there: Enter and Space press the focused button whatever the modifiers (egui’s rule), so Ctrl+Enter or Space cancels; replacing takes a click on Replace, or Tab to it first. Cancel or Escape gives the picker back, the keyboard in its field and the stem selected for another name; Replace ends the choice (file.replace). The picker is inert meanwhile. An application that asks itself turns this off with FileRequest::confirm_overwrite(false).
    • It is the in-app picker’s question only, so egui-pop adds no second one to a system chooser: a choice answered by the system goes straight to file.chosen. egui-pop relies on the system’s own question there and has not run one to see it. rfd asks for it in its GTK and zenity backends and leaves Windows’ default (FOS_OVERWRITEPROMPT) alone; with the desktop portal and macOS’s save panel, the question is up to them. rfd has no way to turn it off, so the opt-out does not reach them. A run-hook on file.choose, Files::deliver and the bridge’s answer answer for themselves.
    • Without the dialogs plugin nobody can ask: nothing is replaced, and the picker says so and wants another name.
    • A FilePicker drawn on its own answers PickerAnswer::Replace(path): its caller asks.
    • Inside a dialog (Files::show_inline), the question comes up in that dialog’s place, and the dialog comes back after the answer, as it was. Its overlay closes and opens again, so it is drawn anew.
  • A new folder, saving or choosing a folder: the New folder button, or the file.new_folder command (Ctrl+Shift+N, rebindable, working through the picker’s modal and while typing). A row under the folder asks the name: Enter or Create makes it through the file system (FileSystem::create_dir) and goes into it, the name to save under still in the field; Escape closes the row and leaves the picker open. A name that is empty, holds a path or exists, or an error from the system, shows in the picker, and the row stays to fix the name. The name comes first, as in GTK and macOS, so nothing needs renaming. The journal says file.folder_created. An agent gives { "name" } to the command and the folder is made at once.

FilePicker is usable on its own, in any Ui: its list and headers are LIST_HEIGHT (280) high, or take the height left with fill. Its order is FilePicker::sort and FilePicker::folders_first (set_sort, set_folders_first keep the highlight on its entry); its caller remembers them. With no keymap to go through, it reads Ctrl+A, Ctrl+Space and Ctrl+L itself, and they do not rebind. A modal of your own that the person resizes is OverlaySpec::resizable (overlay module).

How other dialogs do it, and what the picker should take from them: the file dialogs survey.

Grouped files

An application declares which files go together, and they are one entry: a RAW with its sidecars, as Lightroom shows a RAW and its JPEG, and darktable and digiKam treat an XMP. egui-pop has the mechanism and no rule: nothing groups until a grouping is declared, and it has no list of photo extensions of its own.

use std::sync::Arc;
use egui_pop::api::files::groups::SidecarRule;
use egui_pop::api::files::FilesPlugin;

// x.xmp, x.cr3.xmp and x.jpg belong to x.cr3; the badge says +XMP, +JPEG.
let photos = SidecarRule::new("my_app.photos", &["cr3", "nef", "arw"], &["xmp", "jpg"])
    .badge("jpg", "JPEG");
let files = FilesPlugin::default().grouping(Arc::new(photos));
let _ = files;

A plugin registers on the service instead, Files::groupings().register(...), and takes it back in its disconnect (Groupings::unregister). A SidecarRule goes by extension, whatever its case, and an exact stem; the main extensions come in the order they win, so &["cr3", "jpg"] makes x.jpg a member beside x.cr3 and a main file of its own otherwise. Anything else, such as darktable’s duplicates (x_01.cr3.xmp), is a FileGrouping of your own: it is given a folder’s file names, without folders or hidden files, and gives groups of names. It is asked once per listing, on the interface thread, as the folder is read, and reads no file. What makes no sense in its answer is ignored and the file stays an entry of its own (a name not there, a file an earlier group or grouping took); one that panics counts for nothing, and the log says so.

  • The entry. It stands for the main file: its name, its size, its time and its type in the columns, in the grid’s cell and in every order. It says the others with badges (+XMP, +JPEG) at the end of the name’s column or in the cell’s corner, +2 when they do not fit, and its description and the badges’ tip name them. The pane lists them under the facts. Arrows, ranges and Ctrl+A go by entries, and Selected: 2 counts groups.
  • What a choice gives. paths holds the main file, as files::chosen reads it, so a caller who does not care changes nothing. The result’s groups, which files::chosen_groups reads, holds FileGroup { main, members, badges } for each path that heads a group, and file.chosen’s arguments hold them too for a before-hook. A redirected choice gives the groups of where it leads. They come from the paths at the end of the choice, so a run-hook, Files::deliver, the bridge’s answer and the system’s chooser give them as well; the system’s window shows each file apart, and a member chosen there is only that file. A FilePicker drawn on its own takes with_grouping, answers with the main file, and tells its caller the rest with group_of.
  • Filters. The group forms over the whole folder, and the filter judges its main file: under Raws (*.cr3) an entry still has its +XMP, and under Sidecars (*.xmp), which refuses the RAW, each XMP is an entry of its own.
  • The field. A group answers to its members’ names too, and choosing it still gives the main file. A typed path is a path: /shoot/x.jpg chooses that file alone, and its completions list every file.
  • Previews. Only the main file is asked for a preview, in the pane and in the grid’s queue. Where no provider gives it one (Nothing, or a failure), its members are asked in turn, and the first image stands in, with Preview from x.jpg under it in the pane; the facts stay the main file’s, but for what the provider said of the image, such as its dimensions. A sidecar’s text does not stand in for a photo. The files collector says it as stand_in.
  • Each file its own entry. The Group files switch beside the view shows every file, to reach a member with the pointer, and a choice then gives no groups. It shows only with a grouping declared, and is kept in settings/files.grouped (files::grouped), outside the settings window where it would mean nothing without a grouping. Switching back moves the highlight to the group that takes its file in, and a member selected leaves the selection.
  • Not grouped. Saving and choosing a folder never group, as a name to save under must see every file it could replace. A hidden file joins no group, even shown. FileRequest::ungrouped() turns groups off for a choice that wants a sidecar as much as a RAW.

The application’s options

A choice can carry options of the application’s, shown above the picker’s buttons and given back with the paths: an import’s “Only new photos”, an export’s format. Their shape is the desktop portal’s choices (Windows’ customize interface and macOS’s accessory view do the same): a combo box of values, or a check box.

use egui_pop::api::files::{self, FileRequest};

let request = FileRequest::open_many("Import")
    .check("only_new", "Only new photos", true)
    .choice("copy", "Files", &[("add", "Add in place"), ("copy", "Copy")], "add");
let _ = request;
// When the choice ends:
let result: Result<serde_json::Value, String> = Ok(serde_json::json!({ "paths": [], "choices": { "only_new": "true", "copy": "add" } }));
let choices = files::chosen_choices(&result);
let only_new = choices.get("only_new").map(String::as_str) == Some("true");
assert!(only_new);
  • Values. Each choice ends with a value: an option’s id, or "true" or "false" for a check box. files::chosen_choices gives every id with its value, the defaults included; a cancelled choice and a request without choices give none, and the result then has no choices.
  • The labels are the application’s, translated by it; each combo box takes its label as its name for a screen reader.
  • Whoever answers. The picker’s values, unless a run-hook on file.choose answers choices with its paths, or calls Files::set_choices before Files::deliver, or the bridge’s answer gives choices. Each value is checked against the request: an id it does not have or a value its choice cannot take is refused. file.chosen carries them in its arguments, and a before-hook may change them as it may redirect the paths. A FilePicker drawn on its own gives them with choices, and set_choice sets one.
  • The system’s chooser cannot show them. rfd has no way to: a request with choices opens the in-app picker even where the system’s chooser is used (files.native), so that the options are seen, not silently left at their defaults.

Where it reads

The picker reads through a files::fs::FileSystem: the system’s (StdFs, the default), or a folder held in memory (MemoryFs: files with their bytes and modification times, and folders). The web build has no file system: an application gives the picker a MemoryFs there (FilesPlugin::file_system, or Files::set_file_system later), as the gallery does for its demo folder. FilePicker::new_in makes a picker on any file system.

It writes one thing, a new folder, and only on a file system that says it can (FileSystem::can_create_dirs, create_dir). StdFs can. A MemoryFs is read-only, and a FileSystem of your own is too unless it says otherwise: the New folder button is disabled with the reason as its tip, and the key shows the reason in the picker. So on the web, whose picker reads from memory, no folder can be made, and it says so; saving still chooses a path and still asks before replacing a file held there.

The file browser

files::browser is the component the choosers are moving onto (the design): a FileBrowser shows the entries of a place from a FileSource in a ViewMode chosen in its toolbar. The in-app picker shares its modes’ ids, its switcher and its mode keys; it still draws its own list and grid (columns to sort by, groups) for its two modes.

  • Sources. FsSource lists a FileSystem in pages (on a thread of its own for the system’s, at once for a MemoryFs); a source of your own streams Pages through a Listing, errors included.
  • Modes. details (rows: the name, the size, the date) and thumbnails (a virtualised grid, its size from 64 to 256 points) are built in; ViewModes::register adds others. A mode draws and reports clicks; the browser keeps the selection (one or several, Ctrl and Shift as in the picker) and the focus, which a change of mode keeps.
  • Rubber band. In thumbnails, a drag from the room around the cells draws a band. The selection follows it as it is drawn: its cells alone, or added to the selection with Ctrl or Shift held. When it is let go, the focus goes to its last cell. The band comes from ThumbnailGrid::rubber_band, which tells the cells it touches (show_with_band), scrolled away or not.
  • Filmstrip. filmstrip is one virtualised row of thumbnails (64 to 128 points) under a large view of the focused entry (Lightroom’s Loupe and Filmstrip). Left and Right move along the strip, Page Up and Page Down by a strip’s width. The large view asks the provider first (Visible), then the strip’s cells in view, then the next screen of them (Near).
  • Carousel. carousel shows the focused entry large in the middle, its neighbours smaller and smaller on each side as far as the width goes (Finder’s Gallery). Left and Right bring the previous or next entry to the middle, Page Up and Page Down the neighbours of one side; a click on a neighbour does too. The middle one asks for its thumbnail first, then the neighbours outwards, then the next one beyond each side (Near). Each entry is an option named by its name for screen readers.
  • Order. Entries come folders first, then by name as people read them (IMG_9 before IMG_10). The toolbar’s sort menu, or FileBrowser::set_sort with a sort::PickerSort, orders them by name, by when they last changed, by when they were taken (SortColumn::Taken: SourceEntry::taken, else when they last changed), by size or by type, up or down. What has no value in that order goes last either way, and names settle ties. “Folders first” can be turned off (set_folders_first). The selection and the focus stay on their entries. A mode that orders by time on its own (ModeNeeds::time, the agenda) shows no menu.
  • Groups. With the application’s groupings (FileBrowser::with_grouping, over files::groups, as the picker’s), files that go together are one entry: a RAW with its sidecars and its JPEG shows as the RAW, its members’ badges on it (+XMP +JPEG, or how many past two), said to screen readers with its members (“Grouped with a.cr3.xmp, a.jpg”), and with its first member’s thumbnail when it has none of its own. The members leave FileBrowser::entries, and FileBrowser::group_of gives an entry’s group. The groups are found as the listing’s pages come, a place past 2,048 files on a thread of its own (FileBrowser::groups_pending while it works). The sort menu turns grouping off and on (set_grouped); a member selected or focused then leaves it for its group’s entry. egui-pop declares no grouping: what goes together is the application’s rule.
  • Agenda. agenda files the entries by day, the newest first: one heading per day (a screen reader’s heading, 2026-11-08), its entries under it in a grid, the newest of the day first, and the entries without a time last, under “No date”. The day is the one an entry was taken (SourceEntry::taken, which an application’s source gives, a photo’s capture time), else the one it last changed, in UTC. Left and Right go in that order, across days; Up and Down go a row up or down, into the previous or next day, in the same column as near as it goes; Home and End go to the newest and the oldest entry.
  • Quick look. Ctrl+Y, or Space while the entries hold the keyboard (and no type-ahead prefix is being typed), opens a large view of the focused entry over the entries, in every mode; the arrows move to the previous or next entry behind it, and Escape, Space or Ctrl+Y closes it (FileBrowser::set_quick_look, quick_look).
  • Columns. columns is Finder’s column view: one column per folder of the path, from the browser’s root (with_root, else the file system’s) down to the place, then the focused entry looked into (a folder’s entries, a file’s thumbnail and size). Up and Down move in the place’s column, Right enters the focused folder (its first entry focused), Left goes back to the parent (the folder left focused); a click in another column goes to that folder. ViewModes::folders() is the folder chooser’s set, details and columns; ViewModes::built_in() has every built-in mode (details, thumbnails, filmstrip, columns, carousel, agenda). A mode that needs the path says so (ModeNeeds::hierarchy): the browser then lists the ancestors and the focused folder too and hands them over in ModeContext::ancestors and ModeContext::peek; the mode answers a Reach (a place and the entry to focus) and names the keys that leave the place with ViewMode::travel.
  • Keys, while the entries hold the focus: the arrows, Page Up and Page Down, Home and End as the mode’s layout says; Enter opens; Ctrl+A and Ctrl+Space select; typed letters jump to the first name that starts with them, one letter again goes round them, and a pause of a second starts again. Ctrl+1 to Ctrl+9 show the switcher’s modes in order (browser::request_mode is what the keymap’s commands do).
  • The switcher is a segmented control up to four modes (SEGMENTED_MAX), a menu beyond; each mode’s label is translated under egui-pop-files-mode-<id> (mode_label), its icon drawn from the icon registry when the name resolves.
  • The mode is kept per dialog in the host’s store when the browser is drawn with FileBrowser::show_in(ui, app, dialog); with show, it lasts as long as the browser.
  • Thumbnails come from a ThumbnailProvider: each frame, the mode asks for what it shows (Visible) and the next row (Near), and what is not asked again is cancelled. PreviewThumbnails makes them with the preview providers below.

Previews

Previews come from providers (files::preview::PreviewProvider) that plugins register on the files service:

use std::sync::Arc;
use egui_pop::api::files::preview::{Body, Handles, Preview, PreviewProvider, PreviewRequest};

#[derive(Debug)]
struct Notes;

impl PreviewProvider for Notes {
    fn id(&self) -> &str {
        "my_app.notes"
    }
    fn handles(&self) -> Handles {
        Handles::new().extensions(&["note"]).magic(b"NOTE1")
    }
    fn priority(&self) -> i32 {
        10
    }
    fn preview(&self, request: &PreviewRequest) -> Result<Option<Preview>, String> {
        let bytes = request.read()?;
        let text = String::from_utf8_lossy(&bytes[5.min(bytes.len())..]).into_owned();
        Ok(Some(Preview::new(Body::Text { text, truncated: false }).fact("Format", "Note 1")))
    }
}

// In a plugin's `connect`, after the files plugin's:
// ctx.app().service(&FILES).unwrap().previews().register(Arc::new(Notes));
let _ = Arc::new(Notes);
  • Which provider. A provider’s Handles name file extensions, MIME types (from the extension: image/png, a family text/*, any file */*), magic bytes a file starts with, and folders. The providers that handle a path are tried from the highest priority down; accepts may refuse a path its handles match. The first to give a preview wins; one may pass (Ok(None)) to the next.
  • A failure is a reason. An error, or a panic in the provider, shows as “no preview” with its reason; nothing crashes.
  • Off the interface thread. Previews::get answers from the cache, else hands the path to a worker thread and says Loading; the frame never waits, and the context is woken when the preview is ready. Asking for another path cancels the one asked before (a long provider checks PreviewRequest::cancelled). On the web, which has no threads, previews are made in the frame. Previews::compute makes one at once (agents, tests).
  • Cached and capped. Previews are kept by path, size and modification time, up to 64 MiB (Previews::set_cache_bytes; the oldest go first); a provider reads at most 64 MiB of a file (PreviewRequest::read refuses more, set_max_bytes) and draws images at most 256 pixels long (set_max_side).
  • Built in (files::providers, registered by the files plugin unless FilesPlugin::without_builtin_previews):
    • images: PNG and JPEG decoded with the image crate and scaled down, with their dimensions (feature image-previews of the facade, on by default; image is MIT OR Apache-2.0 and eframe already uses it);
    • Markdown, drawn simply: headings, paragraphs, items, quotes, code and rules, emphasis and links as plain text. No Markdown renderer is in the tree; this small one is egui-pop’s own, until the renderer the in-app viewer will use is chosen;
    • text and code: the first 40 lines in a monospace font (any file that reads as UTF-8 text, at the lowest priority);
    • folders: how many items, and the first images as the providers preview them (four at most, among the first sixteen files that are images or of no known type).
  • The system’s thumbnails (feature platform-thumbnails of the facade, part of platform; egui_pop::platform::thumbnails, an opt-in ThumbnailsPlugin): for what egui-pop’s providers do not preview (PDF, office documents, videos, fonts…), at the lowest priority and on the system’s file system only. On Linux and the BSDs it reads the freedesktop thumbnail cache (a thumbnail whose Thumb::MTime is the file’s), else runs the installed thumbnailer for the file’s MIME type (the shared MIME database’s globs) into a temporary file, stopped after 10 s (ThumbnailsPlugin::timeout) or when the selection moves; it reads the cache and does not write it. The Windows shell’s thumbnails and macOS’s QuickLook are not done yet: the provider gives that as its reason. The web has none.
  • What a preview holds. A body (an image, a text’s first lines, a document drawn simply, a folder’s counts and first thumbnails, or nothing) and facts: dimensions, pages, a photo’s facts, and labelled facts of the provider’s own.
  • A photo’s facts (PhotoFacts, given with Preview::photo): when it was taken, the camera, the lens, the exposure, the focal length and the rating. The pane shows them in that order whichever provider read them, as Dolphin’s information panel and a photo application’s loupe do, after the dimensions and before the file’s time: the exposure on one line (1/250 s f/5.6 ISO 200), the focal length in millimetres, the rating as five stars (read as “3 of 5” by a screen reader). The time taken is the camera’s, without a zone; EXIF’s 2026:01:15 10:04:00 reads as a date. egui-pop reads no EXIF itself: an application’s provider of raws fills them, and agents read them as photo in the preview’s metadata.
use egui_pop::api::files::preview::{Body, PhotoFacts, Preview};

let preview = Preview::new(Body::Empty).dimensions(6000, 4000).photo(
    PhotoFacts::default()
        .taken("2026:01:15 10:04:00")
        .camera("Canon EOS R6")
        .shutter(1.0 / 250.0)
        .aperture(5.6)
        .iso(200)
        .rating(3),
);
let _ = preview;

A grid asks differently from the pane: Previews::want says each frame which paths it has in view, in order and with their facts, and Previews::thumbnail reads what is made, neither touching the file system in the frame. The worker makes them one at a time, behind the preview asked with get, which a thumbnail in the making gives way to; a path that left the view leaves the queue, and is cancelled in the making. They share the cache and its key with the pane, so the highlighted cell’s preview is there at once; what is in view is kept over the cache’s cap, rather than made again for ever.

Steps

StepArgumentsDefault
file.choose{ "id", "request" }opens the system’s chooser or the in-app picker
file.chosen{ "id", "request", "paths", "origin" }, and "groups" when some areremembers the places and the purpose’s last folder, gives the paths and their groups

For agents, the file.preview command ({ "path" }, kept out of the palette) gives a path’s preview metadata as the pane shows it, made at once if it is not in the cache: whether it is a folder, its size and modification time, the provider, the kind of preview, dimensions, pages, a folder’s counts, the provider’s facts, or the state and the reason when there is none. No pixels and no text. The files collector shows the providers, the cache, and the highlighted entry’s preview state in each open picker.

A run-hook on file.choose replaces the whole chooser: it answers { "paths": [...] } or { "cancelled": true } at once, or later through Files::deliver. A before-hook on file.chosen refuses a choice (the Pending gives the reason as an error) or redirects it to other paths. The journal says file.cancelled. The debug bridge’s files collector shows the choices open, the in-app picker’s folder, field and entries, and answers a choice (answer: the user’s, unless the application offers it to agents, see Agents). Who answered goes with the choice: files::chosen_origin on its result (Origin::User for the picker, the system’s chooser or a plugin’s Files::deliver; the agent’s for files.answer or Files::deliver_as), origin in the file.chosen step’s arguments and by in the collector’s last choices. A consumer that should act only on a person’s choice checks it, or vetoes file.chosen for others.

The commands file.new_folder ({ "name" }, optional) and file.replace ({ "id", "path" }, hidden) are the picker’s new folder and the yes to its question. The when key filePickerNewFolder says that an open picker offers a new folder. file.select_all and file.toggle_selection answer { "selected": n }, and the files collector lists the picker’s selected, its sort and folders_first, its grouped and groups, and the groupings declared.

The gallery’s files page opens each kind of choice in a demo folder whose files are made by code at start (the repository holds no binary file): PNG and JPEG images drawn with the image crate, a text file, a Markdown document and a CSV table, written to the temporary folder on the desktop and given to the picker as a MemoryFs on the web, so the previews show there too. Open an image and Save as each have a purpose: each comes back to its own last folder, the others stay where they were. Photos/2026 holds a pretend RAW and a JPEG with sidecars, grouped by a rule the page declares for itself.