https://github.com/davidmhewitt/elementary-rust-example
A sample of how to build an elementary OS application with Rust
https://github.com/davidmhewitt/elementary-rust-example
elementaryos granite gtk4 gtk4-rs
Last synced: 5 months ago
JSON representation
A sample of how to build an elementary OS application with Rust
- Host: GitHub
- URL: https://github.com/davidmhewitt/elementary-rust-example
- Owner: davidmhewitt
- License: mit
- Created: 2023-02-12T23:13:11.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2025-04-29T03:35:40.000Z (5 months ago)
- Last Synced: 2025-04-29T04:36:00.748Z (5 months ago)
- Topics: elementaryos, granite, gtk4, gtk4-rs
- Language: Rust
- Homepage:
- Size: 662 KB
- Stars: 18
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: COPYING
Awesome Lists containing this project
README
![]()
Elementary Rust Example
Rust application template for elementary OS.
![]()
![]()
## ❓ What is this?
This repository has all of the necessary boilerplate to build a GTK4 application against the elementary Flatpak Platform using the Granite 7 library.
The example code uses the `Granite.Placeholder` widget to show a welcome screen, supports the user's dark style preference, remembers the window size and state, uses a custom icon from a GResource file, sets up translations, and has some sample unit tests for the welcome view widget.
You are free to extend upon this template in any way you see fit.
## 🛠️ Requirements
* gettext
* meson
* libgranite-7-dev
* libgtk-4-dev
* rust >= 1.64 (Install from [rustup](https://rustup.rs/) as the version available on elementary OS 7.0 is not new enough)## 🚀 Getting started
```
git clone https://github.com/davidmhewitt/elementary-rust-example
cd elementary-rust-example
meson setup build
cd build
ninja
ninja install
src/elementary-rust-example
```To regenerate translation files (run inside the build directory):
```
ninja io.github.davidmhewitt.ElementaryRustExample-pot
ninja io.github.davidmhewitt.ElementaryRustExample-update-po
ninja extra-pot
ninja extra-update-po
```## 🤖 GitHub Actions
This repository is set up with a number of actions to help the development process.
* Dependabot is configured to update Rust dependencies in your Cargo files.
* There is an action to test building a Flatpak package against the elementary runtime.
* There is an action to test building the application outside of a Flatpak in an elementary Docker container.
* Finally, there is action to update `cargo-sources.json` when your Cargo manifests change. This file lists the Cargo crates that `flatpak-builder` has to download before attempting an offline build in a container.## 🐞 Problems/Feature Requests?
Please open [an issue](https://github.com/davidmhewitt/elementary-rust-example/issues) if you find any problems or want to get support.
## 📔 Other Resources
* [GUI development with Rust and GTK 4](https://gtk-rs.org/gtk4-rs/stable/latest/book/)
* [Granite Documentation](https://valadoc.org/granite-7/Granite.html) (for Vala, but still useful and relevant)
* [granite-rs examples](https://github.com/davidmhewitt/granite-rs/tree/main/examples/src) (Granite demo partially re-implemented in Rust)