No description
  • Rust 34%
  • Python 23.2%
  • Meson 21.7%
  • Nix 12.1%
  • Shell 8.8%
  • Other 0.2%
Find a file
Zeke Fast 478ea64846
Merge pull request #49 from bahrom04/update-deps
update: deps and use new adw shortcut modal
2025-12-24 23:04:59 +01:00
.flatpak-builder/ccache/disabled Merge branch 'master' of https://gitlab.gnome.org/World/Rust/gtk-rust-template 2023-02-16 15:02:53 +01:00
.github fix: build pruduction manifest on CI & update install versions inREADME 2025-12-23 22:51:39 +05:00
build-aux fix: build pruduction manifest on CI & update install versions inREADME 2025-12-23 22:51:39 +05:00
data Merge branch 'master' of https://gitlab.gnome.org/World/Rust/gtk-rust-template 2024-07-11 20:45:52 +02:00
hooks Make pre-commit hook portable 2022-08-25 09:57:00 +00:00
po Add explanation for how to do translations and use correct paths in the po/POTFILES.in file. 2024-11-10 19:53:49 +01:00
src chore: fix format 2025-12-21 21:53:12 +05:00
.editorconfig editorconfig: Add more file types 2021-05-07 07:55:43 +02:00
.envrc chore: reorder packets 2025-12-20 11:09:46 +05:00
.gitignore chore: added nix caches to .gitignore 2025-12-20 11:10:36 +05:00
.gitlab-ci.yml Update runtime to 46 2024-04-07 16:40:53 +02:00
Cargo.lock chore: update all deps to latest version 2025-12-21 21:36:35 +05:00
Cargo.toml chore: update all deps to latest version 2025-12-21 21:36:35 +05:00
create-project.py fix: build pruduction manifest on CI & update install versions inREADME 2025-12-23 22:51:39 +05:00
default.nix fix: build pruduction manifest on CI & update install versions inREADME 2025-12-23 22:51:39 +05:00
flake.lock chore: reorder packets 2025-12-20 11:09:46 +05:00
flake.nix chore: reorder packets 2025-12-20 11:09:46 +05:00
LICENSE.md Init 2019-07-12 18:01:55 +02:00
meson.build build: Mark required programs as such 2024-04-07 16:53:10 +02:00
meson_options.txt Fix whitespace 2020-09-03 16:28:46 +03:00
README.md fix: build pruduction manifest on CI & update install versions inREADME 2025-12-23 22:51:39 +05:00
shell.nix fix: build pruduction manifest on CI & update install versions inREADME 2025-12-23 22:51:39 +05:00

GTK + Rust + Relm4 + Meson + Flatpak = <3

This is a fork of gtk-rust-template that adapts the code for Relm4 while trying to change as little as possible.

A boilerplate template to get started with GTK, Rust, Meson, Flatpak made for GNOME. It can be adapted for other desktop environments like elementary.

Main window

What does it contains?

  • A simple window with a headerbar
  • Bunch of useful files that you SHOULD ship with your application on Linux:
    • Metainfo: describe your application for the different application stores out there;
    • Desktop: the application launcher;
    • Icons: This repo contains three icons, a normal, a nightly & monochromatic icon (symbolic) per the GNOME HIG, exported using App Icon Preview.
  • Flatpak Manifest for nightly builds
  • Dual installation support
  • Uses Meson for building the application
  • Bundles the UI files & the CSS using gresources
  • A pre-commit hook to run rustfmt on your code
  • Tests to validate your Metainfo, Schemas & Desktop files
  • Gsettings to store the window state, more settings could be added
  • Gitlab CI to produce flatpak nightlies
  • i18n support

How to init a project ?

The template ships a simple python script to init a project easily. It asks you a few questions and replaces & renames all the necessary files.

The script requires having git installed on your system.

If you clone this repository, you can run it with:

python3 create-project.py

If you don't want to clone the repository, you can run it with:

python3 -c "$(wget -q -O - https://raw.githubusercontent.com/Relm4/relm4-template/main/create-project.py)" --online
➜ python3 create-project.py
Welcome to GTK Rust Template
Name: Contrast
Project Name: contrast
Application ID (e.g. org.domain.MyAwesomeApp, see: https://developer.gnome.org/ChooseApplicationID/): org.gnome.design.Contrast
Author: Bilal Elmoussaoui
Email: bil.elmoussaoui@gmail.com

A new directory named contrast containing the generated project

Building the project

Make sure you have flatpak and flatpak-builder installed. Then run the commands below. Replace <application_id> with the value you entered during project creation. Please note that these commands are just for demonstration purposes. Normally this would be handled by your IDE, such as GNOME Builder or VS Code with the Flatpak extension.

flatpak install --user org.gnome.Sdk//49 org.gnome.Platform//49  org.freedesktop.Sdk.Extension.rust-stable//25.08 org.freedesktop.Sdk.Extension.llvm21//25.08
flatpak-builder --user flatpak_app build-aux/<application_id>.Devel.json

NixOS

nix build . --show-trace

Running the project

Once the project is build, run the command below. Replace <application_id> and <project_name> with the values you entered during project creation. Please note that these commands are just for demonstration purposes. Normally this would be handled by your IDE, such as GNOME Builder or VS Code with the Flatpak extension.

flatpak-builder --run flatpak_app build-aux/<application_id>.Devel.json <project_name>

NixOS

nix run 
# or
cd .. && ./relm4-template/result/bin/gtk-rust-template

Translations with Gettext

The template uses gettext as a framework for translations using gettext-rs. The basic files for this can be found in the po folder. While meson will take care of building the translations the extraction and translation itself has to be done manually.

Extracting translatable strings

First of all you have to have gettext installed on your system. With that you then are able to use xgettext as following to extract the translatable strings:

xgettext --package-name=<project_name> --package-version=main --msgid-bugs-address=https://github.com/<project_name>/<project_name>/issues --files-from=po/POTFILES.in --output=po/<project_name>.pot

Note that you might need to update the po/POTFILES.in file to reflect the files of your process. This describes where xgettext is going to search for strings to translate.

Translating the translatable strings

To translate the strings you need to use po files. Tools like Poedit allow you to generate these from the po/<project_name>.pot file. It also allows you to sync the po/<project_name>.pot when you rerun xgettext.

When adding a po file also make sure to add the language code to po/LINGUAS.

Community

Join the GNOME and gtk-rs community!

  • Matrix chat: chat with other developers using gtk-rs
  • Discourse forum: topics tagged with rust on the GNOME forum.
  • GNOME circle: take inspiration from applications and libraries already extending the GNOME ecosystem.

Credits