An open API service indexing awesome lists of open source software.

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

Awesome Lists containing this project

README

          





Elementary Rust Example


Rust application template for elementary OS.


Screenshot
Screenshot Dark

## ❓ 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)