A group of crates that aims to provide complete GTK 4 bindings. This repository contains all the "core" crates of GTK 4.
- GTK
- GDK: An intermediate layer which isolates GTK from the details of the windowing system.
- GDK Macos: Macos backend specific functions.
- GDK Wayland: Wayland backend specific functions.
- GDK Win32: Windows backend specific functions.
- GDK X11: X backend specific functions.
- GSK: An intermediate layer which isolates GTK from the details of the OpenGL or Vulkan implementation.
The GTK 4 crates also depends on other libraries part of the platform like:
Those are common with the GTK 3 and GStreamer bindings and are part of the gtk-rs-core repository.
For more information about each crate, please refer to their README.md file in their directory.
Currently, the minimum supported Rust version is 1.83.
- Examples
- Book Stable
- The Rust API Stable / Development
- Website
- Discourse
- Matrix: #rust:gnome.org
The gtk4-rs repository contains Rust crates for GTK 4. However there is a large ecosystem of GObject libraries and many of these
libraries have Rust bindings based on the tooling included in gtk-rs.
Of particular note:
- gtk-rs-core - bindings for some of the core libraries such as
glib,gio,pango,graphene - gstreamer-rs - bindings for the GStreamer media framework
Additionally, Rust bindings for various libraries are hosted on GNOME's GitLab instance and can be found at https://gitlab.gnome.org/World/Rust.
When using crates that are not part of the gtk4-rs repository, you will
need to be careful and ensure that they do not pull in incompatible versions of core
crates like glib-rs.
A small list of applications built with gtk4-rs:
- Solanum: A pomodoro timer
- Shortwave: An internet radio player
- Authenticator: A two-factor code generator
- Health: A health tracking app
- Video Trimmer: A fast video trimmer
Libraries built with gtk4-rs:
- Relm4: An idiomatic GUI library inspired by Elm
gtk-rs is a project by humans for humans. We prefer contributions that are produced by human creativity, we expect a human to take full responsibility for each contribution, and we will take more joy in reviewing contributions when there's people at the other end of the line to stand by their changes.
If you use LLM/GenAI tools for your contributions, here are the rules you must follow:
- Use AI as a tool. Verify behavior, correctness, and compatibility yourself prior to submitting your contribution. Do not ask the maintainers to do this for you.
- Keep changes narrow and limited. Do NOT use LLM/GenAI tools to generate broad rewrites, large refactorings, or style changes.
- Do NOT submit generated code, documentation, or tests that you don’t understand.
- Do NOT fabricate benchmarks, bug reports, test results, code samples, or reproducers.
- Do NOT include private code, credentials, tokens, or any other confidential material.
- Respect the licensing and attribution requirements.
Always disclose the use of LLM/GenAI tools when creating an issue or a merge request. Do not include trailers like “Co-authored-by:” or “Assisted-by:” in commit messages, since they serve as free advertising for AI companies.
- Describe your changes, and the verification steps.
- Be prepared to explain all the changes yourself.
- Do NOT feed the review feedback to an LLM/GenAI tool.
- Review LLM/GenAI-assisted contributions more strictly than any other contribution.
- Require reproducibility in fixes and tests.
- Reject changes that appear to be unverified LLM/GenAI output.
- Reject comments and feedback that appear to be LLM/GenAI output.
A COMPUTER CAN NEVER BE HELD ACCOUNTABLE. THEREFORE A COMPUTER MUST NEVER MAKE A MAINTENANCE DECISION.
The bindings are composed of two parts:
- Automatically generated ones using gir
- Manual parts
The automatic ones can be generated using the generator.py script
python3 ./generator.pyIf you didn't do so yet, please check out all the submodules before via
$ git submodule update --checkoutAll the crates except gtk4-macros follow this structure
./crate
├── Gir.toml
├── README.md
├── src
│ ╰── auto
├── sys
╰── tests
README.md: Explanations about the crate itself and eventually some details.Gir.toml: Used by gir to generate most of the code.src: Contains the source code of the crate.src/auto: Contains the automatically generated part of the source code.sys: Contains the 1:1 bindings of the C API.