Modern GTK4 + Libadwaita foundation library for Rust applications.
AtlBase is a modular Rust library that simplifies the development of Linux desktop applications with GTK4 and Libadwaita. It provides ready-made dialogs and widgets, multi-page guides, helper functions for files, commands and settings, gettext translations and logging — and it works the same in deb, rpm, Flatpak, Snap and AppImage packages.
crates.io · API documentation · Changelog · Packaging guide · User guide · Workflows · Security audits
- Quick start
- Features
- Installation
- Overview of the modules
- Localization
- Packaging
- Building the library
- Example applications
- Tests
- Documentation
- Changelog
- License
[dependencies]
atlbase = "0.2"
adw = { version = "0.9", package = "libadwaita", features = ["v1_8"] }use adw::prelude::*;
use atlbase::{gettext, prelude::*, ui_prelude::*};
fn main() -> glib::ExitCode {
let app = adw::Application::builder()
.application_id("org.example.Demo")
.build();
app.connect_activate(|app| {
init_language("demo", "/usr/share/locale", false); // translations
use_adw_provider("button { border-radius: 12px; }"); // your own CSS
let button = create_button(&gettext!("Say hello"), |button| {
show_info_dialog(button, &gettext!("Hello from AtlBase"));
});
let window = adw::ApplicationWindow::builder()
.application(app)
.content(&button)
.build();
window.present();
});
app.run()
}- GTK 4.20 + Libadwaita 1.8 integration
- Dialogs: information, success, warning and error (each with its own color and mark), alert, text input, about, image, custom content, spinner and progress bar for commands or Rust functions
- Multi-page guides (
carousel): swipeable instructions built in code or loaded from TOML - File and folder choosers, widget factories (buttons, entries, icon labels), CSS provider that follows light/dark
- Commands: run and capture, with a time limit,
pkexecwith a progress dialog, terminals, URLs - Building blocks for programs with many pages: a window with a stack, lazy pages, button grids,
forms, a confirm dialog,
CommandTask(a chain of commands with feedback), background work - Archives (feature
archive): recognize and unpack tar, xz, gz, bz2, zip and 7z - The shared command line (
-debug,--version) and system information - Files and file system: append lines once, read
KEY=VALUEfiles, temporary file, safe deletion helpers, path expansion - Settings in a TOML file (
get_config,set_config), detection of Flatpak / Snap / AppImage / PPA - Internationalization with gettext; the texts of the library are translated out of the box
- Logging to a file and to syslog, and a log viewer window
- Examples and tests for everything
[dependencies]
atlbase = "0.2"| Cargo feature | Default | Description |
|---|---|---|
carousel-toml |
yes | Load multi-page guides from TOML files (GuideLoader) |
log-viewer |
yes | Log viewer window and header bar menu (needs VTE) |
archive |
no | Recognize and unpack tar, xz, gz, bz2, zip and 7z (helper::archive) |
download |
no | Download a file over HTTP(S) without curl (helper::download) |
format-flatpak, format-snap, format-appimage, format-native |
all yes | The package formats that are compiled in; at least one is needed, see below |
experimental-api |
no | Unfinished system module (does not compile yet) |
Without VTE (for example for a Flatpak that uses the GNOME runtime), and compiled for one package
format only (the code of the others is left out; at least one format-* feature is needed):
# a Flatpak: no VTE, nothing of Snap, AppImage or another operating system
atlbase = { version = "0.2", default-features = false, features = ["carousel-toml", "format-flatpak"] }The formats are format-flatpak, format-snap, format-appimage and format-native (a deb, an
RPM, cargo install); the default has all of them and finds out at run time which one the program
is in.
Rust 1.93 or newer, GTK 4.20 or newer and Libadwaita 1.8 or newer (development packages).
gettext provides msgfmt, which compiles the translations of the library (optional, but without
it the texts of the library stay English).
# Ubuntu / Debian
sudo apt install build-essential pkg-config gettext \
libgtk-4-dev libadwaita-1-dev libvte-2.91-gtk4-dev
# Fedora
sudo dnf install gcc pkgconf gettext gtk4-devel libadwaita-devel vte291-gtk4-devel
# Arch Linux
sudo pacman -S base-devel gettext gtk4 libadwaita vte4libvte is only needed with the feature log-viewer. The packages need to be new enough: Ubuntu
25.10, Fedora 43, the GNOME 49 runtime and Arch qualify; older distributions have to use a newer
runtime (Flatpak) or build the libraries themselves.
atlbase
├── prelude Everything without a window use atlbase::prelude::*;
├── ui_prelude Everything with a window use atlbase::ui_prelude::*;
├── macros gettext!
├── helper archive, cli, commands, configuration, file, filesystem, language, log,
│ platform, sysinfo
├── design carousel, chooser, dialogs, form, theme, utils
└── system (feature experimental-api) unfinished
examples/ complete programs
tests/ integration tests
po/ translations of the library
docs/ guides and the changelog page
| Module | Purpose |
|---|---|
helper::commands |
run_command, capture_command_output, command_output_timeout, command_line, shell_line, command_pkexec, open_terminal_by_desktop, open_terminal_command, open_url, command_exists_native |
helper::cli |
read_common_options, apply_debug_options, version_text |
helper::platform |
The layer between a program and the operating system: OsProfile (one file per system), PackageFormat (one file per package format: Flatpak, Snap, AppImage, native), Target, AppDirs, find_program, host_command, elevation_command, supports, PackageManager, init_logging |
helper::download |
download_file, download_file_verified (SHA-256) over HTTPS without curl (feature download) |
helper::sysinfo |
SystemInfo, package_version |
helper::archive |
detect_format, decompress, decompress_file, decompress_limited (feature archive) |
helper::configuration |
get_config, set_config, get_execution_environment, check_application_environment |
helper::file |
add_line_file, get_config_value, write_file, trim_and_clean, temporary file |
helper::filesystem |
create, check, search, expand and delete paths |
helper::language |
init_language, translate, LIB_DOMAIN |
helper::log |
init_syslog (syslog only), show_log_viewer (shows the log file), create_custom_headerbar; init_logging of helper::platform writes the file and syslog |
design::dialogs |
all dialogs, CommandTask |
design::form |
FormDialog, PickRow, combo and switch rows |
design::carousel |
Guide, Page, GuideView, GuideLoader |
design::chooser |
show_file_chooser, show_folder_chooser |
design::theme |
use_adw_provider |
design::utils |
create_button*, create_entry, create_label_icon*, commands_pkexec_*, StackWindow, show_stack_page, create_button_grid, run_background |
Every function is listed in docs/DEVELOPER_DOCS.md and, with examples, in the API documentation.
let guide = GuideLoader::new().load_resource("/org/example/App/guides/intro.toml")?;
GuideView::present_in_stack(&stack, "intro", &guide, "home");Blocks: paragraph, heading, bullet list, numbered steps, code with a copy button, images with caption and alternative text, and notes (info, tip, warning, danger).
Call init_language(domain, locale_dir, false) once at start-up and wrap your texts in gettext!.
The library finds the translations of your application in the usual places (your locale_dir,
/usr/share/locale, /app/share/locale in a Flatpak, $SNAP/… in a Snap, $APPDIR/… in an
AppImage, $XDG_DATA_DIRS). The texts of the library itself are compiled into the crate (German is
included), so dialogs are translated without installing anything. Text of your application
overrides the text of the library. ATL_LOCALEDIR=/path forces a directory.
AtlBase is a normal crate, so it works in every package format. How to build deb, rpm, Flatpak, Snap and AppImage packages (versions, VTE, translations, what works inside a sandbox) is described in docs/PACKAGING.md.
git clone https://github.com/AtlantisOS-Project/atlantis-UI-base.git
cd atlantis-UI-base
cargo build # debug build
cargo build --release # release build (optimized for size)
cargo build --no-default-features --features format-native # one package format, without the TOML loader and the log viewerThe [profile.release] settings of this repository only apply when you build this repository;
applications that use AtlBase choose their own profile.
The programs in examples/ show how the pieces fit together in a complete application. Every
example builds with cargo build --examples.
| Example | What it shows | Needs a window |
|---|---|---|
helper_tools |
The helper functions in a command line program; works in a temporary directory | no |
dialogs |
Every dialog, language, syslog, CSS and the header bar menu | yes |
guide |
Multi-page guides from a TOML file and from code | yes |
pages |
A program with several pages: window with a stack, button grid, form, task and confirm dialogs | yes |
test_app |
Nearly every function in one big window | yes |
cargo run --example helper_tools
cargo run --example dialogs
cargo run --example guide # content from examples/assets/guide.toml
cargo run --example guide -- builder # the same guide, built in code
cargo run --example guide -- embedded # embedded text, images from the data directories
cargo run --example pages
cargo run --example test_app
cargo build --release --example dialogs # optimized build of one exampleThe window examples need a running desktop session (Wayland or X11). Because the build script sets
COMPILED_LOCALE_DIR, they find the translations of the library without installing anything:
LANGUAGE=de cargo run --example dialogs # German texts (needs the locale de_DE.UTF-8)dialogs, guide and test_app need the default features (they are skipped by
--no-default-features, which needs a format-* feature).
GTK can draw into a web browser with the Broadway backend. This works on a server or in a container, and the window shows up in a browser tab:
gtk4-broadwayd :5 & # the display ":5" is served on http://127.0.0.1:8085
GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 cargo run --example dialogs
# open http://127.0.0.1:8085 in a browser (the port is 8080 plus the display number)cargo test # everything: unit tests, tests/ and the examples in the documentation| Command | What it runs |
|---|---|
cargo test --lib |
Unit tests inside src/ (locale directory lookup, TOML guides, pkexec commands, terminals) |
cargo test --tests |
Everything in tests/ |
cargo test --doc |
The code examples of the API documentation (all are compiled, many run) |
cargo test --test helper_files |
One file of tests/; replace the name with another file |
cargo test --test helper_files add_line |
Only the tests whose name contains add_line |
cargo test --features archive |
Everything including the archive module (its unit tests need the feature) |
cargo test --no-default-features --features format-native --lib --tests |
The same without the optional features |
What tests/ covers:
| File | Tests |
|---|---|
helper_filesystem.rs, helper_home_protection.rs |
create, search, expand and delete paths; the home directory is protected |
helper_files.rs, helper_temp_file.rs |
appending lines, KEY=VALUE files, the temporary file |
helper_config.rs |
settings in $XDG_CONFIG_HOME (also how Flatpak and Snap redirect them) |
helper_commands.rs, helper_environment.rs, helper_cli.rs |
running commands, command lines, detection of Flatpak / Snap / AppImage / deb, the shared command line options |
language_library.rs, language_application.rs |
translations of the library and of an application |
helper_platform.rs |
the platform layer: operating systems, folders, programs, package formats, logging |
changelog.rs |
the changelog folder and the page that shows it fit together |
carousel_toml.rs, design_gtk.rs, preludes.rs |
guides, GTK widgets, the exported names |
Good to know:
-
Tests never touch your real files: they work in temporary directories and point
$HOMEand$XDG_*there. Tests that change the environment live in files of their own. -
language_*use the German locale if it is installed and skip the translation checks otherwise;language_applicationalso needsmsgfmt. -
design_gtkhas its ownmainbecause GTK must run on the main thread. It printsskipped, there is no displayand succeeds when there is no display. To run it for real in a session without a desktop, use Broadway (see above):gtk4-broadwayd :5 & GDK_BACKEND=broadway BROADWAY_DISPLAY=:5 cargo test --test design_gtk
Before you send a change, these should be quiet:
cargo clippy --all-targets
RUSTDOCFLAGS="-D warnings" cargo doc --no-deps
cargo +nightly doc --no-deps # with RUSTDOCFLAGS="--cfg docsrs": how docs.rs builds it
cargo package --allow-dirty # does the crate build from the packaged files?- API documentation on docs.rs; locally with
cargo doc --open - docs/USER_GUIDE.md — using the library in your own project
- docs/DEVELOPER_DOCS.md — all functions and the conventions of the code
- docs/MODULES_OVERVIEW.md — what each module is for
- docs/PACKAGING.md — deb, rpm, Flatpak, Snap, AppImage
- docs/WORKFLOWS.md — everyday work, adding things, the changelog, what runs automatically, publishing, and the mechanisms behind the code
- docs/SECURITY_AUDIT.md — the security audits: the scale, what is open, what was fixed
All changes — new functions, changed calls and behavior, removed items with their replacements —
are listed in the folder CHANGELOG/, one file per version series
(v.0.2.x.md, …). The same text is available as a web page: docs/index.html
builds it from those files (it reads CHANGELOG/README.md and every file listed there). For GitHub
Pages choose Settings → Pages → Deploy from a branch → main / docs; the page then loads the
files from raw.githubusercontent.com. Locally it can be viewed with python3 -m http.server in
the repository root and http://127.0.0.1:8000/docs/.
GPL-3.0. See the LICENSE file for more information.
- Repository: https://github.com/AtlantisOS-Project/atlantis-UI-base
- Crate: https://crates.io/crates/atlbase
- The AtlantisOS Project — primary developer: @NachtsternBuild