Add application skeleton
Window, GSettings-backed config, Blueprint UI in a GResource, and the packaging metadata (desktop entry, AppStream metainfo, schema, icons). Built with gtk4-rs and libadwaita against the host toolchain; Meson drives cargo and installs the GResource under $datadir/org.kosmos.raucao.Regent.
This commit is contained in:
22 files changed
+1288
No files matched your search
@@ -0,0 +1,4 @@
|
||||
/_build/
|
||||
/dist/
|
||||
/target/
|
||||
*.gresource
|
||||
@@ -0,0 +1,92 @@
|
||||
# Regent — notes for agents and contributors
|
||||
|
||||
A Nostr remote signer (NIP‑46) for GNOME. Rust + `gtk4`/`libadwaita`, Meson,
|
||||
Blueprint, GResource, GSettings. Development happens on **nuc** in
|
||||
`~/src/regent`; repo `https://gitea.kosmos.org/raucao/regent` (private).
|
||||
The full plan lives at `~/.opencode/plan/regent.md`.
|
||||
|
||||
## Hard rules
|
||||
|
||||
- **Unlicense** (public domain). No copyright headers needed. Don't add a license
|
||||
header to new files.
|
||||
- **The NIP‑46 responder is ours.** Do not add a NIP‑46 signer/bunker dependency,
|
||||
and do not shell out to `nak`. `nak` is a *test instrument* only.
|
||||
- **No Flatpak.** Distribution is AUR + Gitea releases + Nostr events.
|
||||
- **Never write the nsec to disk in the clear.** Keys go in the Secret Service
|
||||
(oo7), one item per key.
|
||||
- **Split keys**: `device` (NIP‑46 transport + response signing, rotatable) and
|
||||
`user` (the nsec — signs events, nip04/44 only). The user key must never be
|
||||
used for relay traffic.
|
||||
|
||||
## Layout
|
||||
|
||||
```
|
||||
src/main.rs resource registration, entry point
|
||||
src/application.rs AdwApplication, actions, CSS
|
||||
src/window.rs main window (GtkBuilder from the GResource)
|
||||
src/config.rs GSettings wrapper
|
||||
data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, style.css)
|
||||
```
|
||||
|
||||
UI lives in `data/resources/ui/*.blp` (Blueprint) and is compiled to `.ui` by
|
||||
`blueprint-compiler`, bundled into the GResource, and loaded with
|
||||
`gtk::Builder` + `builder.object::<T>("id")`.
|
||||
|
||||
## Conventions
|
||||
|
||||
- App ID everywhere: `org.kosmos.raucao.Regent`; GResource prefix
|
||||
`/org/kosmos/raucao/Regent`; GSettings path `/org/kosmos/raucao/Regent/`;
|
||||
dev builds may use the `.Devel` suffix.
|
||||
- Cargo is driven by Meson (`custom_target`). **Every source file must be listed
|
||||
as an input** in `meson.build`, otherwise edits don't trigger a rebuild.
|
||||
- `Cargo.lock` is committed; builds use `--locked`.
|
||||
- All GTK calls happen on the main context. Anything arriving from a tokio task
|
||||
(relay, signer) must be marshalled with `glib::MainContext::invoke`.
|
||||
- Approval prompts must **time out to Deny**, never to allow.
|
||||
|
||||
## Verified API traps (do not rediscover these)
|
||||
|
||||
1. The crate is `gtk4` but must be aliased: `gtk = { package = "gtk4", … }`.
|
||||
2. `EventBuilder` has no finalize method in `nostr` 0.45; build
|
||||
`UnsignedEvent::new(pk, ts, kind, tags, content)` and call
|
||||
`signer.sign_event(unsigned)`.
|
||||
3. rust-nostr's typed `NostrConnectMessage`/`NostrConnectRequest` cannot parse a
|
||||
spec-shaped *unsigned* `sign_event` (it wants a full event with
|
||||
`pubkey`/`id`/`sig`). Hand-parse the `{id, method, params}` envelope.
|
||||
4. Clients send `switch_relays` *before* `connect`, sometimes with
|
||||
`params: null` (not `[]`). Handle it, and tolerate null params.
|
||||
5. `NostrConnectUri::parse()` handles both `bunker://` and `nostrconnect://`
|
||||
(`is_bunker()`, `relays()`, `secret()`) — use it.
|
||||
6. Requests arrive NIP‑44 encrypted; fall back to NIP‑04 for legacy clients.
|
||||
Respond NIP‑44.
|
||||
|
||||
## Testing
|
||||
|
||||
- Loopback with no public relays and no display:
|
||||
- `nak serve --port 10547` = writable in-memory relay.
|
||||
- `nak --sec 'bunker://…' …` = independent NIP‑46 *client*.
|
||||
- Headless GUI: see the recipe in `README.md` (`gtk4-broadwayd` +
|
||||
`dbus-run-session`).
|
||||
- Do **not** test against the host's `strfry` — it is a read-only mirror by
|
||||
design and rejects client writes.
|
||||
- Spikes that established the above: `/tmp/opencode/spike{1,2,5}/` (throwaway).
|
||||
|
||||
## Validation commands
|
||||
|
||||
```sh
|
||||
appstreamcli validate --no-net data/org.kosmos.raucao.Regent.metainfo.xml
|
||||
desktop-file-validate data/org.kosmos.raucao.Regent.desktop
|
||||
glib-compile-schemas --strict --dry-run data/
|
||||
```
|
||||
|
||||
`--no-net` is deliberate: the project URLs point at a **private** Gitea repo, so
|
||||
the URL-reachability check fails for everyone except logged-in maintainers.
|
||||
`desktop-file-validate` prints one hint about the `Security` category that we
|
||||
accept.
|
||||
|
||||
Dev runs need the schema and resource from the build tree, otherwise the app
|
||||
aborts with `Settings schema 'org.kosmos.raucao.Regent' is not installed`:
|
||||
|
||||
```sh
|
||||
GSETTINGS_SCHEMA_DIR=_build/data REGENT_GRESOURCE=… ./_build/regent
|
||||
```
|
||||
Generated
+701
@@ -0,0 +1,701 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.5.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2032f911046de80f0a198e0901378627c33f59ea0ac00e363d481118bd70a53"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.13.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3ded4057c258ba199e2d26386d3af3780957ecaee6c4ef4041c6b4b8b97c0b06"
|
||||
|
||||
[[package]]
|
||||
name = "cairo-rs"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df683f1d30b457964673a5541a4603208ef95ab6873d2a55871895cf310f3b56"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"cairo-sys-rs",
|
||||
"glib",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cairo-sys-rs"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ee548131103ad8f698c6725669647b9c757b3b66992dd6a026037596417bee21"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-expr"
|
||||
version = "0.20.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9ba9e9ec16c447027685b1f897b720e18e9a8afd00bd7332c483537e38086c9f"
|
||||
dependencies = [
|
||||
"smallvec",
|
||||
"target-lexicon",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "equivalent"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
|
||||
|
||||
[[package]]
|
||||
name = "field-offset"
|
||||
version = "0.3.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38e2275cc4e4fc009b0669731a1e5ab7ebf11f469eaede2bab9309a5b4d6057f"
|
||||
dependencies = [
|
||||
"memoffset",
|
||||
"rustc_version",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-channel"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-executor"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-io"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
|
||||
|
||||
[[package]]
|
||||
name = "futures-macro"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fb9654ba8355388abeb8dcb4fc62f511300867002afc858860463bdd9fe0c44"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd417de3d1d015fc3bfd2b1ea46dfc7bab72ef86f1cc7cc9c78e728b34a6d1fd"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-macro",
|
||||
"futures-task",
|
||||
"pin-project-lite",
|
||||
"slab",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gdk-pixbuf"
|
||||
version = "0.22.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "25f420376dbee041b2db374ce4573892a36222bb3f6c0c43e24f0d67eae9b646"
|
||||
dependencies = [
|
||||
"gdk-pixbuf-sys",
|
||||
"gio",
|
||||
"glib",
|
||||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gdk-pixbuf-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d5209294ba3775f9b650bf78bfadeba4332089f2329b3e2f6ce0a4957a45bff"
|
||||
dependencies = [
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gdk4"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e77c579bac9eff8b84c0625d5f533da6d69988c063062fe92c2e955ede8f28eb"
|
||||
dependencies = [
|
||||
"cairo-rs",
|
||||
"gdk-pixbuf",
|
||||
"gdk4-sys",
|
||||
"gio",
|
||||
"glib",
|
||||
"libc",
|
||||
"pango",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gdk4-sys"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3eff6238a30c1f198fb3c8d3d445fa7faf211d11d9075af0772e6e0ca32ae001"
|
||||
dependencies = [
|
||||
"cairo-sys-rs",
|
||||
"gdk-pixbuf-sys",
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"pango-sys",
|
||||
"pkg-config",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio"
|
||||
version = "0.22.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4620fbafdf19dba814473e19f18e75290cb3338662f6ae35f0402affd3b2b699"
|
||||
dependencies = [
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib",
|
||||
"libc",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gio-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6c28739f914c15b87a9856000bed9cbd5b3a8afbca5e982d9a299e1601422cb5"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib"
|
||||
version = "0.22.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e4cf9e5bd8713f1990a92c422998826e0fb34824277b46bc59757373483c6694"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-executor",
|
||||
"futures-task",
|
||||
"futures-util",
|
||||
"gio-sys",
|
||||
"glib-macros",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"memchr",
|
||||
"smallvec",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-macros"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c9597c68fa7bdf4154a3079642cd21c4dccac0b0bdd2897d82861523bf91e7b9"
|
||||
dependencies = [
|
||||
"heck",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glib-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "99b38907e67e40dec9b60f858bcada952598719cb512a13eb13d6cdcd16f8295"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gobject-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "07595c9ba696bd9819cb6a8df39f08078f3dd679508fe052dd558492c2053834"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphene-rs"
|
||||
version = "0.22.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb856b9c558971c3f13ab692358926da710b046932a4e087aedcc35b040d7dff"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"graphene-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "graphene-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "97842c7543828f98aa5583aa54fcda28aa84fa2b0f8c556142177f7bbb638057"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gsk4"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eee23d7425c5281ec5a2f40f7b69384aac66c15861d990d248e9d9c9368be464"
|
||||
dependencies = [
|
||||
"cairo-rs",
|
||||
"gdk4",
|
||||
"glib",
|
||||
"graphene-rs",
|
||||
"gsk4-sys",
|
||||
"libc",
|
||||
"pango",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gsk4-sys"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "27900c92e47df410bbe43b51818104051e3409da43fb88547a41c0bafddfd39c"
|
||||
dependencies = [
|
||||
"cairo-sys-rs",
|
||||
"gdk4-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"graphene-sys",
|
||||
"libc",
|
||||
"pango-sys",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gtk4"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0f8226c94dd0b65ba2e8fcd8ff402d380e890f6e5a6488e652a0158e827b9bf"
|
||||
dependencies = [
|
||||
"cairo-rs",
|
||||
"field-offset",
|
||||
"futures-channel",
|
||||
"gdk-pixbuf",
|
||||
"gdk4",
|
||||
"gio",
|
||||
"glib",
|
||||
"graphene-rs",
|
||||
"gsk4",
|
||||
"gtk4-macros",
|
||||
"gtk4-sys",
|
||||
"libc",
|
||||
"pango",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gtk4-macros"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "eb906c98f0b4cc9002594e337e83f40492aa6dca22c97242f13be5b046c5f338"
|
||||
dependencies = [
|
||||
"proc-macro-crate",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gtk4-sys"
|
||||
version = "0.11.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bd14af0137f269bdecee73404157d2a852f9651af7d68bd1023d3b8b914a14c3"
|
||||
dependencies = [
|
||||
"cairo-sys-rs",
|
||||
"gdk-pixbuf-sys",
|
||||
"gdk4-sys",
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"graphene-sys",
|
||||
"gsk4-sys",
|
||||
"libc",
|
||||
"pango-sys",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hashbrown"
|
||||
version = "0.17.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||
|
||||
[[package]]
|
||||
name = "indexmap"
|
||||
version = "2.14.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
|
||||
dependencies = [
|
||||
"equivalent",
|
||||
"hashbrown",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libadwaita"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "85b9900e67182a4b5b1f157b448d94f0715c8b9770cce21cf000801917f53bfa"
|
||||
dependencies = [
|
||||
"gdk4",
|
||||
"gio",
|
||||
"glib",
|
||||
"gtk4",
|
||||
"libadwaita-sys",
|
||||
"pango",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libadwaita-sys"
|
||||
version = "0.9.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "28d3c27642b389852aa99341bd4a4c19ec6f8a2b63ebdd7f5ba1952198079ccd"
|
||||
dependencies = [
|
||||
"gdk4-sys",
|
||||
"gio-sys",
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"gtk4-sys",
|
||||
"libc",
|
||||
"pango-sys",
|
||||
"system-deps 7.0.8",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.191"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "65cd87c9a6d60536580b316ad985726104730a5151c99845f2490428ef91240a"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
version = "2.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
|
||||
|
||||
[[package]]
|
||||
name = "memoffset"
|
||||
version = "0.9.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "488016bfae457b036d996092f6cb448677611ce4449e970ceaf42695203f218a"
|
||||
dependencies = [
|
||||
"autocfg",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pango"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b2022dbbd82e1c42bd950a6f1df9b98c796e725dce5ec275e03cbf9772e4efa"
|
||||
dependencies = [
|
||||
"gio",
|
||||
"glib",
|
||||
"pango-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pango-sys"
|
||||
version = "0.22.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca02d64761b74d56cdd4b437db6d73dc95e6c0d40f27e1c707952c0f09052948"
|
||||
dependencies = [
|
||||
"glib-sys",
|
||||
"gobject-sys",
|
||||
"libc",
|
||||
"system-deps 9.0.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.17"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
|
||||
|
||||
[[package]]
|
||||
name = "pkg-config"
|
||||
version = "0.3.34"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f6b464fbc74e149a392436b17d523f769e057cb6877f6a5c4618bc6f11800548"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro-crate"
|
||||
version = "3.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e67ba7e9b2b56446f1d419b1d807906278ffa1a658a8a5d8a39dcb1f5a78614f"
|
||||
dependencies = [
|
||||
"toml_edit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "985e7ec9bb745e6ce6535b544d84d6cd6f7ad8bd711c398938ae983b91a766d9"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.47"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fbf4db142a473a8d80c26bbf18454ed458bf8d26c8219c331daecfdbd079001"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regent"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"glib",
|
||||
"gtk4",
|
||||
"libadwaita",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc_version"
|
||||
version = "0.4.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92"
|
||||
dependencies = [
|
||||
"semver",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "semver"
|
||||
version = "1.0.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8a7852d02fc848982e0c167ef163aaff9cd91dc640ba85e263cb1ce46fae51cd"
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "67dca2c9c51e58a4791a4b1ed58308b39c64224d349a935ab5039aa360942a48"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.229"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_spanned"
|
||||
version = "1.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9c187e0a369471c550af028cba56d4f4fa2a489ad28151ae95a4d340a2a8b782"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "slab"
|
||||
version = "0.4.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
|
||||
|
||||
[[package]]
|
||||
name = "smallvec"
|
||||
version = "1.16.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "149309498a5f7334b12ddae0cad8aba81ce785fe91755068867e017cf98fee46"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "3.0.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "7.0.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "396a35feb67335377e0251fcbc1092fc85c484bd4e3a7a54319399da127796e7"
|
||||
dependencies = [
|
||||
"cfg-expr",
|
||||
"heck",
|
||||
"pkg-config",
|
||||
"toml",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-deps"
|
||||
version = "9.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "db551ad38aac61d5e0343e0eeeb0163be3115c4e23b6a025959570ee0c03c67d"
|
||||
dependencies = [
|
||||
"cfg-expr",
|
||||
"heck",
|
||||
"pkg-config",
|
||||
"toml",
|
||||
"version-compare",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.13.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
|
||||
|
||||
[[package]]
|
||||
name = "toml"
|
||||
version = "1.2.1+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d5755c51863cdac711f1956baf8eb9588e060755f7d3c4c979e70ea1e1f32cd7"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"serde_core",
|
||||
"serde_spanned",
|
||||
"toml_datetime",
|
||||
"toml_parser",
|
||||
"toml_writer",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_datetime"
|
||||
version = "1.1.3+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "173f25c883cd2176a2d8212155638c0a60d484a9d84546d270866f40f56b6e49"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_edit"
|
||||
version = "0.25.19+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd43688c4858d7264ae1cf9a9f874a67c3feb74a883b1cd7bebd6a4ea8307218"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"toml_datetime",
|
||||
"toml_parser",
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_parser"
|
||||
version = "1.1.5+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "baa693a8032d7e1cada7d0041e96126df243179ff061456783ac7f12bda4744c"
|
||||
dependencies = [
|
||||
"winnow",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "toml_writer"
|
||||
version = "1.2.0+spec-1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "009dbb7700f11c55ef83aebbe4c0e9cf1f1ac0844bd8d6f00dc38f302026e13a"
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.27"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
|
||||
|
||||
[[package]]
|
||||
name = "version-compare"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03c2856837ef78f57382f06b2b8563a2f512f7185d732608fd9176cb3b8edf0e"
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "winnow"
|
||||
version = "1.0.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8c3b93199df0ab874cdf0c6a94f0a0dc3423fe41f1cafb62b8bd7b1deb277aef"
|
||||
dependencies = [
|
||||
"memchr",
|
||||
]
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
[package]
|
||||
name = "regent"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
rust-version = "1.92"
|
||||
description = "Nostr remote signer (NIP-46) for GNOME"
|
||||
license = "Unlicense"
|
||||
repository = "https://gitea.kosmos.org/raucao/regent"
|
||||
publish = false
|
||||
|
||||
[dependencies]
|
||||
gtk = { package = "gtk4", version = "0.11", features = ["v4_24"] }
|
||||
libadwaita = { version = "0.9", features = ["v1_10"] }
|
||||
glib = "0.22"
|
||||
|
||||
[profile.release]
|
||||
opt-level = 3
|
||||
lto = true
|
||||
@@ -0,0 +1,24 @@
|
||||
This is free and unencumbered software released into the public domain.
|
||||
|
||||
Anyone is free to copy, modify, publish, use, compile, sell, or
|
||||
distribute this software, either in source code form or as a compiled
|
||||
binary, for any purpose, commercial or non-commercial, and by any
|
||||
means.
|
||||
|
||||
In jurisdictions that recognize copyright laws, the author or authors
|
||||
of this software dedicate any and all copyright interest in the
|
||||
software to the public domain. We make this dedication for the benefit
|
||||
of the public at large and to the detriment of our heirs and
|
||||
successors. We intend this dedication to be an overt act of
|
||||
relinquishment in perpetuity of all present and future rights to this
|
||||
software under copyright law.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
||||
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
||||
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
For more information, please refer to <https://unlicense.org>
|
||||
@@ -0,0 +1,44 @@
|
||||
# Regent
|
||||
|
||||
A Nostr remote signer for GNOME. Applications ask Regent to sign events or to
|
||||
encrypt/decrypt messages over [NIP-46](https://github.com/nostr-protocol/nips/blob/master/46.md);
|
||||
the private key stays on your machine, and every request is shown to you before
|
||||
it is answered.
|
||||
|
||||
## Status
|
||||
|
||||
Early development. M0 (skeleton) is in place; there is no signer yet.
|
||||
|
||||
## Building
|
||||
|
||||
```sh
|
||||
cargo generate-lockfile # once, so --locked builds work
|
||||
meson setup _build
|
||||
meson compile -C _build
|
||||
meson install -C _build # optional; needs to write to /usr/local
|
||||
```
|
||||
|
||||
Run it from the build directory (`GSETTINGS_SCHEMA_DIR` is needed because the
|
||||
schema is not installed system-wide yet; `REGENT_GRESOURCE` points at the
|
||||
generated GResource):
|
||||
|
||||
```sh
|
||||
GSETTINGS_SCHEMA_DIR=_build/data \
|
||||
REGENT_GRESOURCE=_build/data/resources/org.kosmos.raucao.Regent.gresource \
|
||||
./_build/regent
|
||||
```
|
||||
|
||||
Headless check (no display needed — useful on servers and in CI):
|
||||
|
||||
```sh
|
||||
dbus-run-session -- sh -c \
|
||||
'gtk4-broadwayd :5 & sleep 1; \
|
||||
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 \
|
||||
GSETTINGS_SCHEMA_DIR=_build/data \
|
||||
REGENT_GRESOURCE=_build/data/resources/org.kosmos.raucao.Regent.gresource \
|
||||
./_build/regent'
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[Unlicense](LICENSE) — public domain.
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Placeholder icon: a crown ("regent"), cream on violet.
|
||||
To be replaced by a designed icon before the first release. -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="128" height="128" viewBox="0 0 128 128">
|
||||
<defs>
|
||||
<linearGradient id="bg" x1="24" y1="8" x2="104" y2="120" gradientUnits="userSpaceOnUse">
|
||||
<stop offset="0" stop-color="#6a55b0"/>
|
||||
<stop offset="1" stop-color="#3b2d68"/>
|
||||
</linearGradient>
|
||||
</defs>
|
||||
<rect x="6" y="6" width="116" height="116" rx="27" fill="url(#bg)"/>
|
||||
<path d="M32 86 27 45l19 13 18-24 18 24 19-13-5 41z" fill="#f6f5f4"/>
|
||||
<rect x="32" y="90" width="64" height="11" rx="5.5" fill="#f6f5f4"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 703 B |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- Placeholder symbolic icon: crown. -->
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
|
||||
<path fill="#2e3436" d="M2 12.4 1.4 5.5l2.8 2L8 3l3.8 4.5 2.8-2-.6 6.9z"/>
|
||||
<rect x="2" y="13" width="12" height="1.6" rx="0.8" fill="#2e3436"/>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 321 B |
@@ -0,0 +1,11 @@
|
||||
icon_dir = get_option('datadir') / 'icons' / 'hicolor'
|
||||
|
||||
install_data(
|
||||
'hicolor/scalable/apps/' + app_id + '.svg',
|
||||
install_dir: icon_dir / 'scalable' / 'apps',
|
||||
)
|
||||
|
||||
install_data(
|
||||
'hicolor/symbolic/apps/' + app_id + '-symbolic.svg',
|
||||
install_dir: icon_dir / 'symbolic' / 'apps',
|
||||
)
|
||||
@@ -0,0 +1,25 @@
|
||||
subdir('resources')
|
||||
subdir('icons')
|
||||
|
||||
install_data(
|
||||
app_id + '.desktop',
|
||||
install_dir: get_option('datadir') / 'applications',
|
||||
)
|
||||
|
||||
install_data(
|
||||
app_id + '.metainfo.xml',
|
||||
install_dir: get_option('datadir') / 'metainfo',
|
||||
)
|
||||
|
||||
install_data(
|
||||
app_id + '.gschema.xml',
|
||||
install_dir: get_option('datadir') / 'glib-2.0' / 'schemas',
|
||||
)
|
||||
|
||||
gnome.compile_schemas(depend_files: files(app_id + '.gschema.xml'))
|
||||
|
||||
gnome.post_install(
|
||||
glib_compile_schemas: true,
|
||||
gtk_update_icon_cache: true,
|
||||
update_desktop_database: true,
|
||||
)
|
||||
@@ -0,0 +1,11 @@
|
||||
[Desktop Entry]
|
||||
Type=Application
|
||||
Name=Regent
|
||||
GenericName=Nostr Remote Signer
|
||||
Comment=Sign Nostr events without sharing your private key
|
||||
Exec=regent
|
||||
Icon=org.kosmos.raucao.Regent
|
||||
Terminal=false
|
||||
Categories=Utility;Security;
|
||||
Keywords=nostr;signer;keys;nip46;nip-46;
|
||||
StartupNotify=true
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<schemalist gettext-domain="regent">
|
||||
<schema id="org.kosmos.raucao.Regent" path="/org/kosmos/raucao/Regent/">
|
||||
<key name="window-width" type="i">
|
||||
<default>420</default>
|
||||
<summary>Window width</summary>
|
||||
<description>Width of the main window, in pixels.</description>
|
||||
</key>
|
||||
<key name="window-height" type="i">
|
||||
<default>640</default>
|
||||
<summary>Window height</summary>
|
||||
<description>Height of the main window, in pixels.</description>
|
||||
</key>
|
||||
<key name="relays" type="as">
|
||||
<default>['wss://relay.damus.io', 'wss://nos.lol']</default>
|
||||
<summary>Relays</summary>
|
||||
<description>Relays Regent connects to for NIP-46 requests and responses.</description>
|
||||
</key>
|
||||
</schema>
|
||||
</schemalist>
|
||||
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<component type="desktop-application">
|
||||
<id>org.kosmos.raucao.Regent</id>
|
||||
|
||||
<name>Regent</name>
|
||||
<summary>Remote signer for Nostr</summary>
|
||||
|
||||
<metadata_license>CC0-1.0</metadata_license>
|
||||
<project_license>Unlicense</project_license>
|
||||
|
||||
<description>
|
||||
<p>
|
||||
Regent signs Nostr events and encrypts or decrypts messages on your behalf,
|
||||
without ever handing your private key to the applications that ask for it.
|
||||
</p>
|
||||
<p>
|
||||
Applications connect to Regent over NIP-46 (Nostr Connect). Regent shows each
|
||||
request — the event that would be signed, the message that would be
|
||||
decrypted — and lets you approve or deny it, so you decide exactly what
|
||||
happens with your key.
|
||||
</p>
|
||||
</description>
|
||||
|
||||
<launchable type="desktop-id">org.kosmos.raucao.Regent.desktop</launchable>
|
||||
|
||||
<developer id="org.kosmos">
|
||||
<name>Râu Cao</name>
|
||||
</developer>
|
||||
|
||||
<url type="homepage">https://gitea.kosmos.org/raucao/regent</url>
|
||||
<url type="bugtracker">https://gitea.kosmos.org/raucao/regent/issues</url>
|
||||
<url type="vcs-browser">https://gitea.kosmos.org/raucao/regent</url>
|
||||
|
||||
<categories>
|
||||
<category>Utility</category>
|
||||
<category>Security</category>
|
||||
</categories>
|
||||
|
||||
<keywords>
|
||||
<keyword>nostr</keyword>
|
||||
<keyword>signer</keyword>
|
||||
<keyword>keys</keyword>
|
||||
<keyword>nip46</keyword>
|
||||
</keywords>
|
||||
|
||||
<content_rating type="oars-1.1"/>
|
||||
|
||||
<releases>
|
||||
<release version="0.1.0" date="2026-11-13">
|
||||
<description>
|
||||
<p>Initial development snapshot.</p>
|
||||
</description>
|
||||
</release>
|
||||
</releases>
|
||||
</component>
|
||||
@@ -0,0 +1,19 @@
|
||||
blueprints = custom_target('blueprints',
|
||||
input: files('ui/window.blp'),
|
||||
# `batch-compile` preserves paths relative to the source dir, so the output
|
||||
# must be this directory itself (a named output would nest another level).
|
||||
output: '.',
|
||||
command: [
|
||||
blueprint_compiler, 'batch-compile',
|
||||
'@OUTPUT@', '@CURRENT_SOURCE_DIR@', '@INPUT@',
|
||||
],
|
||||
)
|
||||
|
||||
gnome.compile_resources(app_id,
|
||||
'resources.gresource.xml',
|
||||
dependencies: blueprints,
|
||||
source_dir: [meson.current_build_dir(), meson.current_source_dir()],
|
||||
gresource_bundle: true,
|
||||
install: true,
|
||||
install_dir: pkgdatadir,
|
||||
)
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<gresources>
|
||||
<gresource prefix="/org/kosmos/raucao/Regent">
|
||||
<file preprocess="xml-stripblanks">ui/window.ui</file>
|
||||
<file>style.css</file>
|
||||
</gresource>
|
||||
</gresources>
|
||||
@@ -0,0 +1,8 @@
|
||||
/* Regent — stylesheet.
|
||||
Everything should be achievable with libadwaita's built-in styles; add rules
|
||||
here only when there is no standard class for what is needed. */
|
||||
|
||||
/* Requests that are waiting for the user's decision. */
|
||||
.request-pending {
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
Adw.ApplicationWindow window {
|
||||
title: "Regent";
|
||||
default-width: 420;
|
||||
default-height: 640;
|
||||
|
||||
content: Adw.ToolbarView {
|
||||
[top]
|
||||
Adw.HeaderBar {}
|
||||
|
||||
content: Adw.StatusPage {
|
||||
icon-name: "security-high-symbolic";
|
||||
title: "Regent";
|
||||
description: "Nostr remote signer — no key configured yet";
|
||||
};
|
||||
|
||||
[bottom]
|
||||
Adw.Banner {
|
||||
title: "The signer is not running";
|
||||
revealed: true;
|
||||
}
|
||||
};
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
project('regent', 'rust',
|
||||
version: '0.1.0',
|
||||
license: 'Unlicense',
|
||||
meson_version: '>= 1.1',
|
||||
)
|
||||
|
||||
gnome = import('gnome')
|
||||
|
||||
cargo = find_program('cargo')
|
||||
blueprint_compiler = find_program('blueprint-compiler')
|
||||
|
||||
app_id = 'org.kosmos.raucao.Regent'
|
||||
binary_name = 'regent'
|
||||
pkgdatadir = get_option('datadir') / app_id
|
||||
|
||||
subdir('data')
|
||||
|
||||
# Meson has no native cargo integration, so cargo is driven through a sh -c
|
||||
# wrapper that also copies the binary to the location Meson expects. Every
|
||||
# source file is listed as an input so edits trigger a rebuild.
|
||||
cargo_build = custom_target(binary_name,
|
||||
output: binary_name,
|
||||
input: files(
|
||||
'Cargo.toml',
|
||||
'src/main.rs',
|
||||
'src/application.rs',
|
||||
'src/window.rs',
|
||||
'src/config.rs',
|
||||
),
|
||||
command: [
|
||||
find_program('sh'), '-c',
|
||||
'cargo build --release --locked --manifest-path "$1" --target-dir "$2" && cp "$2/release/@0@" "$3"'.format(binary_name),
|
||||
'sh',
|
||||
meson.current_source_dir() / 'Cargo.toml',
|
||||
meson.current_build_dir() / 'cargo-target',
|
||||
'@OUTPUT@',
|
||||
],
|
||||
build_by_default: true,
|
||||
install: true,
|
||||
install_dir: get_option('bindir'),
|
||||
)
|
||||
@@ -0,0 +1,40 @@
|
||||
//! Application object, actions and global setup.
|
||||
|
||||
use gtk::gio;
|
||||
use gtk::prelude::*;
|
||||
use libadwaita as adw;
|
||||
|
||||
use crate::window::Window;
|
||||
use crate::{APP_ID, RESOURCE_PATH};
|
||||
|
||||
pub fn run() -> glib::ExitCode {
|
||||
let app = adw::Application::builder().application_id(APP_ID).build();
|
||||
|
||||
let quit = gio::SimpleAction::new("quit", None);
|
||||
{
|
||||
let app = app.clone();
|
||||
quit.connect_activate(move |_, _| app.quit());
|
||||
}
|
||||
app.add_action(&quit);
|
||||
app.set_accels_for_action("app.quit", &["<primary>q"]);
|
||||
|
||||
app.connect_startup(|_| load_css());
|
||||
app.connect_activate(|app| Window::new(app).present());
|
||||
|
||||
// The resource file is passed through the environment, not argv, so that
|
||||
// GApplication does not try to interpret it.
|
||||
app.run_with_args::<&str>(&[])
|
||||
}
|
||||
|
||||
fn load_css() {
|
||||
let provider = gtk::CssProvider::new();
|
||||
provider.load_from_resource(&format!("{RESOURCE_PATH}/style.css"));
|
||||
|
||||
if let Some(display) = gtk::gdk::Display::default() {
|
||||
gtk::style_context_add_provider_for_display(
|
||||
&display,
|
||||
&provider,
|
||||
gtk::STYLE_PROVIDER_PRIORITY_APPLICATION,
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
//! Preferences, backed by GSettings. The schema lives in
|
||||
//! `data/org.kosmos.raucao.Regent.gschema.xml`.
|
||||
|
||||
use gtk::gio;
|
||||
use gtk::prelude::*;
|
||||
|
||||
use crate::APP_ID;
|
||||
|
||||
pub struct Config {
|
||||
settings: gio::Settings,
|
||||
}
|
||||
|
||||
impl Config {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
settings: gio::Settings::new(APP_ID),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn window_width(&self) -> i32 {
|
||||
self.settings.int("window-width")
|
||||
}
|
||||
|
||||
pub fn window_height(&self) -> i32 {
|
||||
self.settings.int("window-height")
|
||||
}
|
||||
|
||||
/// Relays Regent talks to. Used from M2 onwards.
|
||||
#[allow(dead_code)]
|
||||
pub fn relays(&self) -> Vec<String> {
|
||||
self.settings
|
||||
.strv("relays")
|
||||
.iter()
|
||||
.map(|relay| relay.to_string())
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Config {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
//! Regent — a Nostr remote signer (NIP-46) for GNOME.
|
||||
//!
|
||||
//! Applications ask Regent to sign events or to encrypt/decrypt messages. The
|
||||
//! private key stays here, and every request is shown to the user first.
|
||||
|
||||
mod application;
|
||||
mod config;
|
||||
mod window;
|
||||
|
||||
pub const APP_ID: &str = "org.kosmos.raucao.Regent";
|
||||
pub const RESOURCE_PATH: &str = "/org/kosmos/raucao/Regent";
|
||||
|
||||
fn main() -> glib::ExitCode {
|
||||
register_resources();
|
||||
application::run()
|
||||
}
|
||||
|
||||
/// Register the UI GResource. Meson installs it as
|
||||
/// `<datadir>/<app-id>/<app-id>.gresource`; `REGENT_GRESOURCE` overrides the
|
||||
/// lookup, which is what development and tests use.
|
||||
fn register_resources() {
|
||||
let file_name = format!("{APP_ID}.gresource");
|
||||
|
||||
let path = std::env::var_os("REGENT_GRESOURCE")
|
||||
.map(std::path::PathBuf::from)
|
||||
.or_else(|| {
|
||||
let data_dirs =
|
||||
std::env::var("XDG_DATA_DIRS").unwrap_or_else(|_| "/usr/local/share:/usr/share".to_string());
|
||||
data_dirs
|
||||
.split(':')
|
||||
.map(|dir| std::path::Path::new(dir).join(APP_ID).join(&file_name))
|
||||
.find(|path| path.exists())
|
||||
});
|
||||
|
||||
match path {
|
||||
Some(path) => {
|
||||
let resource = gtk::gio::Resource::load(&path)
|
||||
.unwrap_or_else(|e| panic!("failed to load {}: {e}", path.display()));
|
||||
gtk::gio::resources_register(&resource);
|
||||
}
|
||||
None => {
|
||||
eprintln!(
|
||||
"warning: {file_name} not found. Build and install the project, or set \
|
||||
REGENT_GRESOURCE to the file generated by Meson."
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
//! The main window. Built from Blueprint via `GtkBuilder` (see `AGENTS.md` for
|
||||
//! why this is not a `CompositeTemplate` subclass yet).
|
||||
|
||||
use gtk::prelude::*;
|
||||
use libadwaita as adw;
|
||||
|
||||
use crate::config::Config;
|
||||
use crate::RESOURCE_PATH;
|
||||
|
||||
pub struct Window {
|
||||
window: adw::ApplicationWindow,
|
||||
}
|
||||
|
||||
impl Window {
|
||||
pub fn new(app: &adw::Application) -> Self {
|
||||
let config = Config::new();
|
||||
|
||||
let builder = gtk::Builder::from_resource(&format!("{RESOURCE_PATH}/ui/window.ui"));
|
||||
let window: adw::ApplicationWindow = builder
|
||||
.object("window")
|
||||
.expect("ui/window.blp must contain an object with id \"window\"");
|
||||
|
||||
window.set_application(Some(app));
|
||||
window.set_default_size(config.window_width(), config.window_height());
|
||||
|
||||
Self { window }
|
||||
}
|
||||
|
||||
pub fn present(&self) {
|
||||
self.window.present();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user