docs/DEVELOPMENT.md
Development
Splotch & Blot is a GTK4 app for Linux, written in Go. The native app's entry
point is cmd/native. It uses the gotk4 bindings
(github.com/diamondburned/gotk4/pkg, pinned in go.mod) and talks to GTK4
directly, with no libadwaita.
The file map, state ownership and editing lifecycle are described in ARCHITECTURE.md.
Building
Current Arch Linux is the main development platform. You'll need:
- Go 1.27 or newer
- a C compiler and pkg-config
- GTK4 development libraries
- GObject introspection development headers
The generated gotk4 bindings need fairly recent headers, so older
distributions may fail to compile them. The packaging builds solve this with
their own Go module files, kept separate from the main go.mod on purpose.
From the repository root, build a local executable using the Go, C compiler and GTK4 libraries installed in your current distro:
| 1 | ./build.sh |
| 2 | ./splotch-blot |
./build.sh --clean removes only the local splotch-blot executable and
exits; ./build.sh --help shows its options. The shortcut does not install
dependencies or run tests. To test or build directly with Go:
| 1 | export CGO_CFLAGS="${CGO_CFLAGS:--O2 -g} -std=gnu17" |
| 2 | CGO_ENABLED=1 go test -tags gtk ./... |
| 3 | CGO_ENABLED=1 go build -tags gtk -o splotch-blot ./cmd/native |
Use GNU C17 for native cgo compilation: Go's generated link probes rely on
pre-C23 function declarations. This avoids compatibility warnings without
disabling compiler diagnostics. build.sh and the Arch recipe set the dialect
automatically; use the CGO_CFLAGS above for direct tests, vet and builds.
Always build and test the app with -tags gtk; the GTK-independent
subpackages listed in ARCHITECTURE.md also test without
it. Git ignores the built binary, packaging/build/ and dist/; do not add
generated artifacts to source commits.
Where to build
A compatible Linux development setup may be native or container-based. If you use Distrobox, run the build commands inside the box from your shared checkout, then run the binary on your actual desktop to try it out.
To run a test copy without disturbing other open Splotch & Blot windows (for
example, ones with unsaved drawings), start it with
SPLOTCH_BLOT_INDEPENDENT=1 ./splotch-blot. On immutable or shared machines,
follow the local rules rather than installing development or test packages
on the host.
Each kind of build has its own environment:
| Target | Built in | Details |
|---|---|---|
| Development builds / Arch package | Current Arch, directly or in a container | Arch packaging |
Mint 22.1 / Ubuntu 24.04 .deb | Rootless Podman, Ubuntu Noble | Debian-format packaging |
| Cross-distro AppImage | Rootless Podman, Ubuntu Jammy | AppImage packaging |
| AppImage compatibility testing | Jammy test environment; Distrobox with nested Weston is one option | Test setup and known issues |
The Noble and Jammy builds each pin a gotk4 version that works with their
older headers. Don't copy either of those pins into the main go.mod. The older
Jammy setup and a real, current desktop catch different problems, so test on
both.
Disposable packaging builds
Package helpers default to packaging/build/ for artifacts, staging trees,
logs and automatic source freezes. The release source helper defaults there too.
SPLOTCH_DIST_ROOT remains a compatible output-root override; when building from
a frozen tree, set it to an absolute scratch path in the checkout to keep builds
outside that input. See the release guide.
Tracked packaging/build/ files are rejected by source export, and scratch is
excluded from Git and container contexts.
Stop builds and retain anything needed before cleaning:
| 1 | ./packaging/clean-build.sh # dry-run; validates the deletion boundary |
| 2 | ./packaging/clean-build.sh --apply # remove only this checkout's packaging/build |
The cleaner requires Bash and Python 3.10+. It is anchored to its own location,
not the current directory or SPLOTCH_DIST_ROOT. It refuses unsafe paths,
symlinked parents or build root, and filesystem boundaries. Links inside scratch
are unlinked without following them, so AppDir links cannot delete outside data.
Concurrent builds/changes are not supported, and a deletion
failure can leave partially cleaned scratch. Override destinations are not
cleaned. Persistent package/catalog storage in dist/archive/, private offline
sources in dist/mirror/, and generated static site outputs are never touched.
Finding tests
Tests live beside the component they protect. These starting points locate
coverage by behavior within cmd/native and the component packages:
| Behavior | Starting points |
|---|---|
| Pixel capture, edit history and tools | canvas_test.go, document_test.go, tools_test.go, selection_test.go |
| Allocation admission and refusal boundaries | capacity*_test.go, document_admission_recovery_test.go, save_admission_test.go |
| Autosave, persistence faults and recovery ownership | lifecycle_test.go, recovery*_test.go |
| Window callbacks, clipboard and continuation ownership | lifecycle_gui_test.go, acceptance_ownership_test.go, clipboard_boundary_test.go, window_lifetime_gui_test.go |
| GTK-independent algorithms and storage contracts | Tests in raster/, imagefile/, sessionstore/ and the other component packages |
GUI opt-ins and their display requirements are described below.
GUI tests
A normal go test run skips opt-in desktop tests. Run these on a dedicated
Xvfb display with private HOME/XDG state and a private D-Bus session, never
against a desktop someone is using. Headless X11/Cairo tests do not establish
Wayland, GPU, accessibility or full desktop integration; test real behavior
manually as well.
TestResizeHandlesRepeatedDrags runs only with
SPLOTCH_BLOT_GESTURE_TEST=1 under a dedicated Xvfb display. It needs
xdotool, GDK_BACKEND=x11, GSK_RENDERER=cairo, GTK_A11Y=none and
G_DEBUG=fatal-criticals. The .deb build runs the compiled test binary
there with -test.run '^TestResizeHandlesRepeatedDrags$'. Do not set that
environment variable in a normal test run or on a user's live desktop.
TestSecondLaunchOpensFileInRunningInstance checks that a second launch
with a file (what the desktop entry's %f does) hands the file to the
instance already running. It runs only with SPLOTCH_BLOT_INSTANCE_TEST=1,
under dbus-run-session -- xvfb-run with GDK_BACKEND=x11 and xdotool.
It starts the test binary itself as both instances, under a private
application ID, and sends no input. The .deb build runs it in the clean
runtime next to the gesture test.
Dialog and asynchronous ownership tests use SPLOTCH_BLOT_LIFECYCLE_GUI=1.
They require dedicated Xvfb, GDK_BACKEND=x11, GSK_RENDERER=cairo,
GTK_A11Y=none, GSETTINGS_BACKEND=memory and G_DEBUG=fatal-criticals.
For example, inside an equipped development environment:
| 1 | dbus-run-session -- xvfb-run -a env SPLOTCH_BLOT_LIFECYCLE_GUI=1 \ |
| 2 | GDK_BACKEND=x11 GSK_RENDERER=cairo GTK_A11Y=none \ |
| 3 | GSETTINGS_BACKEND=memory G_DEBUG=fatal-criticals CGO_ENABLED=1 \ |
| 4 | go test -count=1 -tags gtk ./cmd/native |
Do not enable these switches in ordinary package tests. Package recipes have separate build-user, runtime and dedicated-display gates, described in their own guides.
Icon and desktop entry
The app ID is org.splotchblot.SplotchBlot. Its files are:
assets/org.splotchblot.SplotchBlot.desktop: the menu entryassets/org.splotchblot.SplotchBlot.svg: the iconcmd/native/icon.png: a 256px copy of the icon shown in the About dialog
If you change the SVG, regenerate the PNG with rsvg-convert and rebuild:
| 1 | rsvg-convert -w 256 -h 256 assets/org.splotchblot.SplotchBlot.svg -o cmd/native/icon.png |
To add a binary you built yourself to your application menu, without installing a package:
| 1 | install -Dm755 splotch-blot "$HOME/.local/bin/splotch-blot" |
| 2 | install -Dm644 assets/org.splotchblot.SplotchBlot.desktop "$HOME/.local/share/applications/org.splotchblot.SplotchBlot.desktop" |
| 3 | install -Dm644 assets/org.splotchblot.SplotchBlot.svg "$HOME/.local/share/icons/hicolor/scalable/apps/org.splotchblot.SplotchBlot.svg" |
For this to work, ~/.local/bin must be on your desktop session's PATH.
The AppImage installer sets up its own launcher and doesn't need that. Both
use the same app ID, and a menu entry in your home directory overrides the
system one. So if you switch to a system package, remove the files you
installed above first.
Versions and releases
The About dialog shows the version from cmd/native/version.go, plus the
first 12 characters of the Git commit that Go records at build time. Builds
with uncommitted changes are marked as modified. Builds from a frozen export with
no Git history show unknown in About; they do not invent VCS metadata. Their
artifact-contained source records give the exact base/commit and export hash,
plus the candidate patch or approved annotated tag. See the
source contract for standalone retrieval and
private archives, and the release guide
for validation of frozen inputs. A displayed version number alone does not
establish tagged-release provenance.
The v1.0.0 tag is the historical first-version baseline; v1.0.1 is the
first binary release. For each release, update appVersion in
cmd/native/version.go and pkgver in packaging/arch/PKGBUILD together.
The website selects its latest release from catalog metadata, not documentation.
Create release tags only after the code, version number and release checks are
ready. Release source archives are always made from the tagged commit, never
from a working copy. See
release provenance and source export for the
details.
Where documentation goes
The main README is for users. It should give an overview, not a manual. Detailed controls go in USAGE.md, development notes go here, and packaging details live next to each recipe. Explain current setup and lasting constraints, not task chronology or validation transcripts. Rules for AI coding assistants are in AGENTS.md.