diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..c14a22e --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,57 @@ +# 146 tests and, until this file, nothing that ran them on a push. +# +# Fedora rather than the runner's own Ubuntu because the app's floors are +# GTK 4.16 / libadwaita 1.7 (see Cargo.toml) and ubuntu-latest trails them; +# Fedora tracks the stack the app is actually written against. +# +# Tests run under Xvfb deliberately: `testing::gtk_test` skips silently on a +# headless machine, and the tests it guards are the CSS parse checks - the +# ones that catch a stylesheet quietly dropping the glass. A CI without a +# display would go green while asserting nothing about them. +# +# No `cargo fmt --check`: the codebase is hand-formatted where it reads +# better than rustfmt's answer (string continuations, aligned tables), and a +# gate that fights 50-odd deliberate sites is a gate that gets deleted. +# Clippy runs with warnings denied instead - the tree is clean and staying so. +name: CI + +on: + push: + branches: [master] + pull_request: + +jobs: + test: + runs-on: ubuntu-latest + container: fedora:latest + steps: + - uses: actions/checkout@v4 + + - name: Install the toolchain and the GTK stack + run: | + dnf install -y gcc git rust cargo clippy \ + gtk4-devel libadwaita-devel vte291-gtk4-devel gtksourceview5-devel \ + xorg-x11-server-Xvfb dejavu-sans-fonts dejavu-sans-mono-fonts + + # The update tests build real throwaway git repos, which needs an + # identity; the checkout is owned by a different uid than the container + # user, which needs the safe.directory waiver. + - name: Give git an identity + run: | + git config --global user.name "ci" + git config --global user.email "ci@localhost" + git config --global --add safe.directory '*' + + - uses: actions/cache@v4 + with: + path: | + ~/.cargo/registry + ~/.cargo/git + target + key: ${{ runner.os }}-cargo-${{ hashFiles('Cargo.lock') }} + + - name: Clippy, warnings denied + run: cargo clippy --all-targets -- -D warnings + + - name: Tests, with a display so the CSS guards actually run + run: xvfb-run -a cargo test diff --git a/Cargo.lock b/Cargo.lock index c78781e..c26a3e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -12,7 +12,7 @@ dependencies = [ "serde", "serde_json", "sourceview5", - "toml 0.9.12+spec-1.1.0", + "toml", "vte4", ] @@ -24,9 +24,9 @@ checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53" [[package]] name = "bitflags" -version = "2.13.0" +version = "2.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4388bee8683e3d04af747c73422af53102d2bd24d9eadb6cbc100baef4b43f8" +checksum = "b588b76d00fde79687d7646a9b5bdf3cc0f655e0bbd080335a95d7e96f3587da" [[package]] name = "cairo-rs" @@ -79,24 +79,24 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07bbe89c50d7a535e539b8c17bc0b49bdb77747034daa8087407d655f3f7cc1d" +checksum = "262590f4fe6afeb0bc83be1daa64e52657fe185690a958af7f3ad0e92085c5ae" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e3450815272ef58cec6d564423f6e755e25379b217b0bc688e295ba24df6b1d" +checksum = "2cd50c473c80f6d7c3670a752354b8e569b1a7cbfdc0419ec88e5edad85e0dc7" [[package]] name = "futures-executor" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf29c38818342a3b26b5b923639e7b1f4a61fc5e76102d4b1981c6dc7a7579d" +checksum = "6754879cc9f2c66f88c6e5c35344bb0bdb0708b0352b1201815667c7eabc7458" dependencies = [ "futures-core", "futures-task", @@ -105,32 +105,32 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cecba35d7ad927e23624b22ad55235f2239cfa44fd10428eecbeba6d6a717718" +checksum = "4577ecaa3c4f96589d473f679a71b596316f6641bc350038b962a5daf0085d7a" [[package]] name = "futures-macro" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e835b70203e41293343137df5c0664546da5745f82ec9b84d40be8336958447b" +checksum = "2d6d3cde68c518367be28956066ddfef33813991b77a55005a69dae04bf3b10b" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] name = "futures-task" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "037711b3d59c33004d3856fbdc83b99d4ff37a24768fa1be9ce3538a1cde4393" +checksum = "b231ed28831efb4a61a08580c4bc233ec56bc009f4cd8f52da2c3cb97df0c109" [[package]] name = "futures-util" -version = "0.3.32" +version = "0.3.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "389ca41296e6190b48053de0321d02a77f32f8a5d2461dd38762c0593805c6d6" +checksum = "a77a90a256fce34da66415271e30f94ee91c57b04b8a2c042d9cf3220179deaa" dependencies = [ "futures-core", "futures-macro", @@ -256,7 +256,7 @@ dependencies = [ "heck", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -362,7 +362,7 @@ dependencies = [ "proc-macro-crate", "proc-macro2", "quote", - "syn", + "syn 2.0.119", ] [[package]] @@ -450,9 +450,9 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.186" +version = "0.2.189" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68ab91017fe16c622486840e4c83c9a37afeff978bd239b5293d61ece587de66" +checksum = "3eaf3ede3fee6db1a4c2ee091bf8a8b4dccdc6d17f656fb07896ee72867612f2" [[package]] name = "memchr" @@ -515,18 +515,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.106" +version = "1.0.107" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8fd00f0bb2e90d81d1044c2b32617f68fcb9fa3bb7640c23e9c748e53fb30934" +checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.46" +version = "1.0.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfbc457d0c7a0759a614551b11a6409e5951f6c7537be1f1b7682b9ae9230368" +checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001" dependencies = [ "proc-macro2", ] @@ -548,9 +548,9 @@ checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd" [[package]] name = "serde" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" +checksum = "4148590afebada386688f18773da617792bf2ef03ffc1e4cbd2b1d45b023e0ba" dependencies = [ "serde_core", "serde_derive", @@ -558,22 +558,22 @@ dependencies = [ [[package]] name = "serde_core" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" +checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.228" +version = "1.0.229" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" +checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 3.0.3", ] [[package]] @@ -647,9 +647,20 @@ dependencies = [ [[package]] name = "syn" -version = "2.0.118" +version = "2.0.119" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1b9ae57f904213ebb649ce6895b8a66c66f0203b9319718f69a5612a065b1422" +checksum = "872831b642d1a07999a962a351ed35b955ea2cfc8f3862091e2a240a84f17297" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "3.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "53e9bae58849f64dfa4f5d5ae372c8341f7305f82a3868709269343628b659a3" dependencies = [ "proc-macro2", "quote", @@ -665,7 +676,7 @@ dependencies = [ "cfg-expr", "heck", "pkg-config", - "toml 1.1.2+spec-1.1.0", + "toml", "version-compare", ] @@ -677,41 +688,17 @@ checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca" [[package]] name = "toml" -version = "0.9.12+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf92845e79fc2e2def6a5d828f0801e29a2f8acc037becc5ab08595c7d5e9863" -dependencies = [ - "indexmap", - "serde_core", - "serde_spanned", - "toml_datetime 0.7.5+spec-1.1.0", - "toml_parser", - "toml_writer", - "winnow 0.7.15", -] - -[[package]] -name = "toml" -version = "1.1.2+spec-1.1.0" +version = "1.1.4+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81f3d15e84cbcd896376e6730314d59fb5a87f31e4b038454184435cd57defee" +checksum = "3aace63f4bbcdfc2c965b059de67119c89c4017a70d633be6c104910f67056f5" dependencies = [ "indexmap", "serde_core", "serde_spanned", - "toml_datetime 1.1.1+spec-1.1.0", + "toml_datetime", "toml_parser", "toml_writer", - "winnow 1.0.3", -] - -[[package]] -name = "toml_datetime" -version = "0.7.5+spec-1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "92e1cfed4a3038bc5a127e35a2d360f145e1f4b971b551a2ba5fd7aedf7e1347" -dependencies = [ - "serde_core", + "winnow", ] [[package]] @@ -725,30 +712,30 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.25.12+spec-1.1.0" +version = "0.25.13+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2153edc6955a6c354fad8f5efd38b6a8769bdccf9fe50f8e1329f81b0baa5d7" +checksum = "6975367e4d2ef766d86af01ffad14b622fecc8d4357a998fbc4deb6e9bacaf9b" dependencies = [ "indexmap", - "toml_datetime 1.1.1+spec-1.1.0", + "toml_datetime", "toml_parser", - "winnow 1.0.3", + "winnow", ] [[package]] name = "toml_parser" -version = "1.1.2+spec-1.1.0" +version = "1.1.3+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a2abe9b86193656635d2411dc43050282ca48aa31c2451210f4202550afb7526" +checksum = "1d38ac1cf9b95face32296c0a3ede1fdc270627c9d9c02a7274dd6d960dc4d56" dependencies = [ - "winnow 1.0.3", + "winnow", ] [[package]] name = "toml_writer" -version = "1.1.1+spec-1.1.0" +version = "1.1.2+spec-1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "756daf9b1013ebe47a8776667b466417e2d4c5679d441c26230efd9ef78692db" +checksum = "7d56353a2a665ad0f41a421187180aab746c8c325620617ad883a99a1cbe66d2" [[package]] name = "unicode-ident" @@ -813,15 +800,9 @@ dependencies = [ [[package]] name = "winnow" -version = "0.7.15" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df79d97927682d2fd8adb29682d1140b343be4ac0f08fd68b7765d9c059d3945" - -[[package]] -name = "winnow" -version = "1.0.3" +version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0592e1c9d151f854e6fd382574c3a0855250e1d9b2f99d9281c6e6391af352f1" +checksum = "23b97319f7b8343df12cc98938e5c3eb436064524c8d2b4e30a1d3a36eecdf81" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index 92fdd60..9f3b555 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,15 +4,19 @@ version = "1.0.0" edition = "2024" [dependencies] -gtk4 = { version = "0.11", features = ["v4_12"] } -# Pinned to the 1.5 API rather than the newest available. Everything this app -# uses landed at or before 1.5 (OverlaySplitView 1.4, ToastOverlay and Banner -# 1.0, PreferencesDialog / AlertDialog / AboutDialog 1.5), and asking for a -# later one would raise the libadwaita floor on every distro in the README's -# install table for widgets there are perfectly good 1.5 answers to - a linked -# ToggleButton row instead of AdwToggleGroup (1.7), GtkShortcutsWindow instead -# of AdwShortcutsDialog (1.8). -adw = { package = "libadwaita", version = "0.9", features = ["v1_5"] } +# `v4_16` buys CSS custom properties and `:root` - which the accent colours +# already needed at runtime (see `main::standalone_colour_css`), previously +# behind a version check because the floor was 4.12. Every distro in the +# README's install table ships 4.16 or later now; the one release the raise +# actually drops is Ubuntu 24.10, which is past EOL. +gtk4 = { version = "0.11", features = ["v4_16"] } +# Pinned to the 1.7 API rather than the newest available. 1.7 is where +# AdwToggleGroup landed, which the header's mode switcher wants to be instead +# of a linked ToggleButton row - and it is also where Debian trixie, the +# oldest distro in the README's table, froze. 1.8's additions +# (AdwShortcutsDialog) stay declined for exactly that reason: the shortcuts +# sheet has a perfectly good 1.7 answer and trixie does not have a 1.8. +adw = { package = "libadwaita", version = "0.9", features = ["v1_7"] } # `v0_70` is for `check_match_at`, which is the only way this binding offers to # ask "is there a link under this pointer" - and without it, clickable URLs # would be limited to OSC 8 hyperlinks, which is a small fraction of the links @@ -33,4 +37,4 @@ sourceview5 = "0.11" libc = "0.2" serde = { version = "1", features = ["derive"] } serde_json = "1" -toml = "0.9" +toml = "1" diff --git a/README.md b/README.md index ec53247..23d1a31 100644 --- a/README.md +++ b/README.md @@ -255,7 +255,7 @@ by name, and Preferences. ## Requirements -- `git`, `pkg-config`, GTK4 (>= 4.12), libadwaita (>= 1.5), the GTK4-flavored +- `git`, `pkg-config`, GTK4 (>= 4.16), libadwaita (>= 1.7), the GTK4-flavored VTE terminal widget (>= 0.70), and GtkSourceView 5 (the sidebar's file editor), including their dev files: @@ -263,15 +263,16 @@ by name, and Preferences. |---|---| | Arch / CachyOS / Manjaro | `sudo pacman -S git pkgconf gtk4 vte4 libadwaita gtksourceview5` | | Fedora | `sudo dnf install git pkg-config gtk4-devel vte291-gtk4-devel libadwaita-devel gtksourceview5-devel` | - | Debian / Ubuntu (trixie/24.10+ or newer) | `sudo apt install git pkg-config libgtk-4-dev libvte-2.91-gtk4-dev libadwaita-1-dev libgtksourceview-5-dev` | + | Debian / Ubuntu (trixie/25.04+ or newer) | `sudo apt install git pkg-config libgtk-4-dev libvte-2.91-gtk4-dev libadwaita-1-dev libgtksourceview-5-dev` | - The libadwaita floor is 1.5, which is older than every release in the table - above — the app deliberately builds against the 1.5 API rather than the - newest one so that requiring it costs no distro its place here. + The libadwaita floor is 1.7, which is what Debian trixie — the oldest + release in the table — ships; the app deliberately builds against the 1.7 + API rather than the newest one so that requiring it costs no distro its + place here. Debian's GTK4-flavored VTE package didn't land until fairly recently, so older releases (e.g. Debian 12 "bookworm", which also ships a GTK4 below - the 4.12 floor above) won't have it — use a newer release, backports, or + the 4.16 floor above) won't have it — use a newer release, backports, or build VTE from source. - Rust 1.85 or newer (needed for the 2024 edition) — already met by current Debian, Fedora, and Arch packages: diff --git a/install.sh b/install.sh index 889d2c7..790c21e 100755 --- a/install.sh +++ b/install.sh @@ -26,8 +26,8 @@ if ! have pkg-config; then exit 1 fi -if ! pkg-config --atleast-version=4.12 gtk4 2>/dev/null; then - echo "error: GTK4 >= 4.12 development files not found (pkg-config gtk4)." >&2 +if ! pkg-config --atleast-version=4.16 gtk4 2>/dev/null; then + echo "error: GTK4 >= 4.16 development files not found (pkg-config gtk4)." >&2 echo " Install your distro's GTK4 dev package and try again, e.g.:" >&2 echo "$PKG_HINT" >&2 exit 1 @@ -51,11 +51,11 @@ if ! pkg-config --exists gtksourceview-5 2>/dev/null; then fi # The app's chrome (header bar, split view, toasts, dialogs) is libadwaita's. -# 1.5 is the floor the code is written against deliberately - see the comment on +# 1.7 is the floor the code is written against deliberately - see the comment on # the `adw` dependency in Cargo.toml - and every distro in the README's table # ships at least that. -if ! pkg-config --atleast-version=1.5 libadwaita-1 2>/dev/null; then - echo "error: libadwaita >= 1.5 development files not found (pkg-config libadwaita-1)." >&2 +if ! pkg-config --atleast-version=1.7 libadwaita-1 2>/dev/null; then + echo "error: libadwaita >= 1.7 development files not found (pkg-config libadwaita-1)." >&2 echo " Install your distro's libadwaita dev package and try again, e.g.:" >&2 echo "$PKG_HINT" >&2 exit 1 diff --git a/src/adwaita-colors.css b/src/adwaita-colors.css index 2ab8a12..d742c68 100644 --- a/src/adwaita-colors.css +++ b/src/adwaita-colors.css @@ -78,27 +78,21 @@ Its foreground is the floor, not white: @filament is a near-white, and white text on it would be unreadable. - The five `*_color` names below - the *standalone* accent, destructive, success, - warning and error, the ones libadwaita paints text and check marks with rather - than fills - only reach libadwaita 1.5, which is this crate's floor. From 1.6 - it derives them from the matching `*_bg_color` instead and reads these lines - not at all, so they are inert on a modern install and have to stay anyway for - the floor. What covers 1.6+ is `main::standalone_colour_css`, which emits them - as CSS custom properties at runtime - not here, because a custom property needs - GTK 4.16 and stating one in this file would be a parse error for everyone on - 4.12, including in `the_adwaita_colours_parse_without_errors`. */ + Only the fill pairs are stated. The *standalone* accent, destructive, + success, warning and error - the ones libadwaita paints text and check + marks with rather than fills - stopped being `@define-color` names at 1.6, + which the 1.7 floor (see Cargo.toml) is safely past: libadwaita derives + them from the matching `*_bg_color` unless told otherwise, and what tells + it otherwise is `main::standalone_colour_css`, which emits them as CSS + custom properties generated from `palette` so the values cannot drift from + the ramp. This file's job is the names, not copies of the numbers. */ @define-color accent_bg_color @filament; @define-color accent_fg_color @field; -@define-color accent_color @filament; @define-color destructive_bg_color @hangup; @define-color destructive_fg_color @field; -@define-color destructive_color @hangup; @define-color success_bg_color @fresh; @define-color success_fg_color @field; -@define-color success_color @fresh; @define-color warning_bg_color @tally; @define-color warning_fg_color @field; -@define-color warning_color @tally; @define-color error_bg_color @hangup; @define-color error_fg_color @field; -@define-color error_color @hangup; diff --git a/src/main.rs b/src/main.rs index 02b0536..ce6caf6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -164,23 +164,17 @@ fn load_css() { /// instead is a lightened @filament rather than @filament, which is close enough /// to have gone unnoticed and is still not what the palette says. /// -/// They cannot be stated in `style.css`, because a custom property is a GTK 4.16 -/// feature and this crate's floor is 4.12 (see Cargo.toml): on the floor, the -/// declarations would be parse errors - reported to a terminal a GUI app hasn't -/// got, and failing `the_stylesheet_parses_without_errors` for anyone building -/// there. Hence a runtime check, and hence this being generated rather than -/// written down: it is built from `palette`, which reads the ramp out of the -/// stylesheet, so there is no second copy of these values to drift. +/// Generated rather than written down: it is built from `palette`, which reads +/// the ramp out of the stylesheet, so there is no second copy of these values +/// to drift. (It used to be runtime-gated as well, when the GTK floor was 4.12 +/// and a custom property in a stylesheet was a parse error there; the floor is +/// 4.16 now - see Cargo.toml - and the gate went with it.) /// -/// The five `@define-color *_color` aliases stay where they are regardless. They -/// are what libadwaita 1.5 reads, and 1.5 is the floor. +/// The five `@define-color *_color` aliases stay in `adwaita-colors.css` +/// regardless. They are what a libadwaita older than 1.6 reads, they cost +/// nothing on a newer one, and they keep that file the complete statement of +/// what Adwaita is told. fn standalone_colour_css() -> String { - // Custom properties and `:root` both arrived in GTK 4.16. Below that the - // aliases in `style.css` are what libadwaita is reading anyway. - if (gtk4::major_version(), gtk4::minor_version()) < (4, 16) { - return String::new(); - } - // Property name, and the ramp rung it is meant to be. const STANDALONE: [(&str, &str); 5] = [ ("--accent-color", "filament"), @@ -423,14 +417,8 @@ mod tests { /// by mistake would leave libadwaita deriving its own accent again and nothing /// would look obviously wrong. /// - /// Skipped rather than failed below GTK 4.16, where the properties are not a - /// thing and the `@define-color` aliases are what libadwaita is reading. #[test] fn the_standalone_colours_are_the_ramp() { - if (gtk4::major_version(), gtk4::minor_version()) < (4, 16) { - return; - } - let css = standalone_colour_css(); for (property, name) in [ ("--accent-color", "filament"), diff --git a/src/shortcuts.rs b/src/shortcuts.rs index 68937e0..effda4f 100644 --- a/src/shortcuts.rs +++ b/src/shortcuts.rs @@ -19,7 +19,7 @@ //! //! Built from `AdwPreferencesDialog` rather than `GtkShortcutsWindow`, which is //! deprecated as of GTK 4.18, or `AdwShortcutsDialog`, which would raise this -//! app's libadwaita floor to 1.8 for no gain over what 1.5 already draws well. +//! app's libadwaita floor to 1.8 for no gain over what 1.7 already draws well. use adw::prelude::*;