diff options
| author | Paul Buetow <paul@buetow.org> | 2026-07-13 20:57:16 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-07-13 20:57:16 +0300 |
| commit | 0795d3cf926d0d937f25fcc699f5f674bf618c72 (patch) | |
| tree | 48e3fcf44a7c5213c11c63c1f69eb8b336edb325 /src/trash.h | |
| parent | 48aa1b3cdbf27be2e016e8b532687226f9249043 (diff) | |
gridcull: thumbnail TMS cache, grid view, trash, window d/D/u/t (jt0)
M7 (task jt0): thumbnail cache + grid view + trash.
- src/trash.{c,h}: ./Trash bin (lazy create, collision suffix -1/-2, restore_last
for u undo, permanent delete for D). Plain-C, unit-tested.
- src/thumbnail.{c,h}: freedesktop TMS cache (normal/large/x-large buckets,
md5(URI) key, Thumb::URI/MTime/Size, mtime verify). Async GTask worker with
GCancellable so the grid can cancel pending requests on dispose.
- src/gridview.{c,h}: GgazeGrid (GtkWidget wrapping GtkFlowBox): one cell per
navigator file, lazy thumbnail decode on realize, +/- resize 64-512, dim
removed cells, mark badges, Enter/double-click → 'activate' signal, cursor
sync. ggaze_grid_detach() breaks the nav ref before dispose.
- src/navigator.{c,h}: removed set (mark_removed/is_removed/unmark_removed);
_relist preserves removed items (stay dimmed even if absent from disk);
get_remaining = count - removed_count.
- src/window.c: d (trash+mark_removed+advance), D (permanent delete, confirm
dialog if >1 marked), u (restore_last+rescan), t (toggle grid/large),
+/- (viewer zoom in large / grid resize). Header counter uses remaining.
- src/shortcuts.c: d/D/u/t/+/= bindings added.
- tests: unit test_trash + test_thumbnail, integration test_grid_cull
(grid count + trash/undo + ./sample-images 613-cell grid). 13/13 green,
ASan clean.
Fixed: grid dispose UAF (detach before nav freed), g_file_get_basename leak,
test p_plain lifetime, thumbnail async-cancellable for clean dispose, test
grid-toggle avoiding async-thumbnail drain issues.
Diffstat (limited to 'src/trash.h')
| -rw-r--r-- | src/trash.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/trash.h b/src/trash.h new file mode 100644 index 0000000..e190263 --- /dev/null +++ b/src/trash.h @@ -0,0 +1,43 @@ +#ifndef GGAZE_TRASH_H +#define GGAZE_TRASH_H + +/*:* + * ggaze — local ./Trash bin + * + * Moves files into <shoot_dir>/.Trash/ (created lazily, collision-suffixed + * -1/-2/...) and tracks the last binned item for `u` restore. `D` permanently + * unlinks. Never touches the system trash. Plain-C, no GtkWidget, + * unit-testable. See docs/architecture.md "trash" + docs/PLAN.md decisions + * #5/#6. + * + * Copyright (c) 2026 ggaze contributors + * SPDX-License-Identifier: GPL-3.0-or-later + *:*/ + +#include <gio/gio.h> +#include <glib.h> + +G_BEGIN_DECLS + +typedef struct Trash Trash; + +/* .Trash lives at <p_shoot_dir>/.Trash. Refs p_shoot_dir. */ +Trash *trash_new(GFile *p_shoot_dir); +void trash_delete(Trash *p_t); /* g_object_unref-style destructor */ + +/* Move p_file into .Trash (lazy create, collision suffix -1/-2). Records the + * move so trash_restore_last() can undo it. Returns TRUE on success. */ +gboolean trash_bin(Trash *p_t, GFile *p_file, GError **p_err); + +/* Permanently delete p_file (unlink). Not undoable. */ +gboolean trash_permanently_delete(Trash *p_t, GFile *p_file, GError **p_err); + +/* Move the last binned file back to its original path. Returns FALSE if there + * is nothing to undo. */ +gboolean trash_restore_last(Trash *p_t, GError **p_err); + +gboolean trash_can_undo(Trash *p_t); + +G_END_DECLS + +#endif /* GGAZE_TRASH_H */
\ No newline at end of file |
