#gtk #gtk4 #elm

relm4-icons

Icons for Relm4 or any application based on gtk-rs

10 releases

0.7.0-alpha.2 Sep 10, 2023
0.7.0-alpha.1 Aug 27, 2023
0.6.0 May 31, 2023
0.6.0-beta.6 Mar 24, 2023

#409 in GUI

Download history 306/week @ 2023-11-02 216/week @ 2023-11-09 213/week @ 2023-11-16 294/week @ 2023-11-23 234/week @ 2023-11-30 294/week @ 2023-12-07 330/week @ 2023-12-14 268/week @ 2023-12-21 236/week @ 2023-12-28 220/week @ 2024-01-04 188/week @ 2024-01-11 328/week @ 2024-01-18 252/week @ 2024-01-25 328/week @ 2024-02-01 504/week @ 2024-02-08 502/week @ 2024-02-15

1,640 downloads per month
Used in 2 crates

Apache-2.0 OR MIT

3MB
31K SLoC

Relm4 icons - Icons for your Relm4 and gtk-rs applications!

CI Matrix Relm4 icons on crates.io Relm4 icons docs Minimum Rust version 1.65 dependency status

More than 2500 icons, ready for use in your app!

Usage

1. Find your icons 🔍

Use one of the following methods:

For icons from the GNOME icon-development-kit:

For icons from Fluent UI System Icons:

For browsing all icons:

2. Get relm4-icons ✍

For each icon you want to use, you can add a feature flag. Only the icons you specify will be compiled into your application.

relm4-icons = { version = "0.7.0", features = ["<icon1>", "<icon2>", "<icon3>..."] }

Example

To enable the plus and minus icons use:

relm4-icons = { version = "0.6.1", features = ["plus", "minus"] }

The file ending -symbolic.svg isn't part of the icon name.

3. Load the icons 🛫

Add this somewhere in your initialization code (after initializing RelmApp or GTK).

relm4_icons::initialize_icons();

4. Use the icons 🎉

Use set_icon_name and similar methods to use your icons, for example with ButtonExt, StackPage, MenuButton or Image.

Example

let button = gtk::Button::default();
button.set_icon_name("plus");

You can also use the icon_name module for extra compile-time checking of icon names.

use relm4_icons::icon_name;

let button = gtk::Button::default();
button.set_icon_name(icon_name::PLUS);

How it works

Codegen

  1. Find all icons in the icons folder
  2. Generate a feature flag and a conditional constant for each icon

Crate

  1. Include only the selected icons in a gresource file
  2. Include the gresource file in the compiled binary
  3. On initialization, add the gresource file to the default icon theme

Add new icons

To add new icons, move them into the icons folder and make sure their file name ends with -symbolic.svg. Then run the following commands:

cd update_icons
cargo run

Credit

  • GNOME contributors for providing so many outstanding icons
  • gvdb-rs for providing a great crate for interacting with gresources in pure Rust
  • gtk-rs for outstanding Rust bindings for GTK4

The source code of Relm4 icons is licensed under the terms of both the MIT license and the Apache License (Version 2.0).

Icons

  • The icons in the icons/icon-development-kit folder are licensed under the terms of the CC0 license and therefore public domain.
  • The icons in the icons/fluentui-system-icons folder are licensed under the terms of the MIT license.

Both licenses should work for both open source and proprietary applications (without warranty).

Dependencies

~18MB
~421K SLoC