10 kB 160 lines
505b80b7
⋯
apps/files/CLAUDE.md
download raw history
at main Markdown

c8-files #

Files: the file manager (archives too: looked into, extracted, made), and the system file picker (portal backend). Depends on: c8ui, gio, libarchive, bwrap (run time, to extract).

Files, org.cont8nuum.Files (one copy, c8ui_app_main). folder.c (a folder's entries, read async in batches; 250 ms after its monitor fires only the files it named are asked about and swapped in, keeping unchanged thumbnails (reload_now/apply_answers), and more than CHANGES_MAX (64), the folder itself or a read under way reads it all again; sort folders first, names with their case folded so capitals and small letters mix (Photos' folder.c the same); icons from Adwaita by GIcon name, thumbnails via c8ui_thumbnail_load when drawn), places.c (home and XDG folders, Trash, Pinned, drives from GVolumeMonitor: mounts and mountable volumes, eject; pinned folders are GTK's bookmarks, shared with other file managers, pinned files are ours, [pins] files in files.ini, since a bookmark can't be a file: places_pin/_unpin, from the app bar's Pin (the selection) and Pin this folder, Ctrl+D, a place's menu; a pinned file opens, or in a picker is shown in its folder), view.c (a window: places list, then tabs, each one pane or two (split view); a struct pane is a folder shown: header with back and clickable crumbs, list as tiles or details with columns, its history, search and selection kept by name across reloads (keep, restoring); struct tab holds pane[2] (a c8ui_split when there are two, one over the other when narrow) and which is active; the window (struct browser) has the tabs (b->stack, the strip strip_impl over it once there are two: click, cross or middle click to close, +, the wheel), the app bar, the places and the band of operations. cur(b) is the pane the commands, keys and places act on: the one clicked or focused last (activate, follow_focus), its title dark, the other's grey; tabs_changed brings the window title, the place and the bar after it. Ctrl+T new tab, Ctrl+W closes it (the last: the window), Ctrl+Tab/Ctrl+PgUp/PgDn step, F3 split view (off keeps the pane in use), F6 the other pane; dragging goes from pane to pane. Letters typed over the list (type_ahead, from the root's key handler, so only what no entry took) select the first item whose name starts with them, adding up within TYPE_MS (1 s); the same letter again goes to the next. Async answers hold a pane and check pane_alive. Items have check boxes (c8ui_list_set_checks: rows' first C8UI_LIST_CHECK_WIDTH px, which draw_row leaves free) so several can be picked in details without Ctrl; pickers are the same window in MODE_OPEN/MODE_SAVE with a band: name box, filter combo, Open/Save, Cancel; answered once, then closed from an idle), ops.c (copy/move/trash/delete/restore on GTask threads, after 600 ms shown in a band under the folder (b->ops): "Copying 12 items to Pictures", Cancel, a bar, and the file in hand, bytes and files done, speed and time left (tick, speed smoothed from tick to tick; a same-drive move counts what measure made of it); a window closing hands its operations to the newest other one (browser_any_window), clashes asked on the main thread (Replace/Keep both/Skip, then for the rest), a window closing answers Skip; untrashable files offer delete for good; the app is held while any runs; Copy/Cut put files on the system clipboard as x-special/gnome-copied-files, text/uri-list + KDE's application/x-kde-cutselection and paths as text; Paste reads the first two, so it works with Nautilus/Dolphin; a pasted cut of ours empties the clipboard), portal.c (org.freedesktop.impl.portal.FileChooser on org.freedesktop.impl.portal.desktop.c8: filters' globs are shell patterns matched with fnmatch and FNM_CASEFOLD, as GTK apps and Firefox send *.[jJ][pP][gG], which GPatternSpec never matched; OpenFile, SaveFile, SaveFiles (the names are the asking app's: plain visible ones only, shown in the title, and one already in the folder becomes "name (2)", never replaced); Request.Close closes the picker; D-Bus starts c8-files --portal, which lingers 120 s after the last picker), filemanager.c (org.freedesktop.FileManager1, also D-Bus activated: ShowItems opens a window per folder with the items selected, which is browsers' "Open containing folder"; ShowFolders; ShowItemProperties acts as ShowItems; the startup id is used as the activation token through the now public c8ui_app_set_launch_token). cont8nuum-portals.conf says FileChooser=c8;gtk; xdg-desktop-portal only finds c8.portal in /usr/share. Narrow (c8ui_root_is_narrow, per window: resized → arrange in view.c): the folder fills the window, a places button in the header shows the places instead (picking one, back or Escape returns), crumbs keep the last two after "…", tiles are 136×150, details are two-line rows without headers (draw_narrow_row), the picker band stacks (arrange_band). A split tab's panes stack by themselves (c8ui's split; arrange only shows and hides panes), halves by c8ui_split_set_share(0.5), so they stay halves as the window changes (a pixel position stayed put: made at 1060 wide, the first pane was still 390 px in a 1600 px window). Tested 2026-12-01: split view at full width, beside a snapped app, snapped (stacked halves) and back. Untested: dragging the divider, then resizing. The Search charm filters the folder in front; the Settings charm's Options page (main.c) edits prefs.c: tiles/details, sort, reverse, hidden items, thumbnails, the same in every window, saved in ~/.config/cont8nuum/files.ini [view]; the Details button, Ctrl+H and column headers change them too (prefs_changed saves, applies, and tells the charm). Drag and drop (view.c): items drag out as text/uri-list + text; drops on a folder item, a place or the folder shown move within one filesystem (or out of the Trash), copy across, trash into the Trash. Archives (archive.c, unpack.c, ops.h): Enter on one (arc_can_browse: an exact list of types, so a .docx or .jar still opens in its app; needs gvfs's archive backend) shows archive:// + its URI escaped twice (arc_root, arc_file back), mounted by mount.c like a server and let go when the last pane leaves it (archive_left); an archive opened from elsewhere (main.c's open: Files is the default app for the ones it looks into, by the desktop entry's MimeType, less disk images and packages, and cont8nuum-mimeapps.list makes it so in our sessions beside Ark or File Roller; the user's own mimeapps.list still wins) opens the same way, instead of being shown in its folder; read only (no Paste, Cut, Rename, Delete, New folder, drops), crumbs and Alt+Up carry on to the folder the archive is in, such mounts aren't listed as drives. gvfsd-archive reads it, not in a sandbox. Extract (the selection, all archives) and Extract all (from inside one) are OP_EXTRACT in the band: the reading is c8-files-unpack's (libexec, plain C + libarchive), run inside bwrap like the thumbnailers (/usr read-only, the archive on stdin as an fd so it can seek, or a pipe pumped from a GInputStream for one without a path; one hidden folder .STEM.RANDOM beside the target to write to; no network; no bwrap, no extracting). It reports on stdout a line each (D bytes read, C file in hand, F failure, W wants a password, answered on fd 3 from op_ask_password's dialog); paths are cleaned there too (no .., nothing absolute, no devices, nothing through a link the archive made, no set-id bits or owners). Then one thing in the folder comes out as itself, several as a folder with the archive's name (move_in: renameat2 NOREPLACE, "name (2)" when taken). Never read an archive in the app itself. Compress (the selection; a dialog with name and kind: zip, 7z, tar.gz, tar.xz, tar.zst; OP_COMPRESS) writes with libarchive in the app (the user's own files), as .NAME.RANDOM.part until whole, owners zeroed. Both select what they made (archive_made). Glyphs archive-extract/archive-insert are in c8-theme. Tested headless, wide and at 480: looking into a zip and a tar.zst, Extract on zip, tar.gz, tar.xz, 7z, a lone .gz, a zip with a password (wrong, then right), archives with ../, absolute paths, a link to /tmp written through and a set-uid file (all kept in), Extract all, every kind compressed and read back by tar/unzip/7z. Untested: Cancel mid-way, an archive on a share (the pipe), rar, copying single files out of an archive, the picker beside archives. openwith.c (Open with flyout: default, recommended, More apps, "Use this app for all … files"), props.c (Properties flyout, Alt+Enter; folders counted on a thread). Tested headless (wide, and 480 for tabs and split): tabs by keys and mouse, split view, pinning files and a folder and a pin's menu, row check boxes, Ctrl+click and Shift+click, the progress band on 30,000 files, a picker filtered by *.[pP][nN][gG]. Untested: the band selection and dragging between panes (wlrctl can't hold a button), Unpin, an operation handed to another window, touch. Network: places has network:/// (gvfs shortcuts have e->target), mount.c mounts a folder that says NOT_MOUNTED when shown and asks GMountOperation's questions in dialogs (its handlers must g_signal_stop_emission_by_name, or GIO's default answers "unhandled" from an idle before the dialog does); Connect to a server (app bar, in Network) takes smb/sftp/ftp/dav URIs, \\server\share or a bare host (smb), https:// as davs://, and can bookmark it. Stealth mode (stealth.h, c8-base): folder_title is what's shown (stand-ins for the login, real name, PC name, home folder), folder_title_real what's kept (places store real names, ops' where); places, items' names (tiles, details, narrow rows, so a folder in /home named after the login), crumbs, pane and tab titles, the window title, Properties (title, Location, Owner), the operations band, its failures and error dialogs, mount questions and a few confirmations go through c8_stealth_text/_show as they're drawn or made. stealth_changed (one watch per window) sets titles and crumbs again and redraws the lists. Rename, the picker's name box and search results show real names. Tested headless, wide and at 480: /home's folder, Properties in and of the home folder, flipping it off and on with a window open. Untested: drives named after the PC, the picker, mount questions.