MCPcopy Index your code
hub / github.com/Relm4/Relm4

github.com/Relm4/Relm4 @v0.11.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.11.0 ↗ · + Follow
1,473 symbols 2,980 edges 225 files 389 documented · 26%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Relm4

CI Matrix Relm4 on crates.io Relm4 docs Relm4 book Minimum Rust version 1.93 dependency status

An idiomatic GUI library inspired by Elm and based on gtk4-rs. Relm4 is a new version of relm that's built from scratch and is compatible with GTK4 and libadwaita.

Why Relm4

We believe that GUI development should be easy, productive and delightful. The gtk4-rs crate already provides everything you need to write modern, beautiful and cross-platform applications. Built on top of this foundation, Relm4 makes developing more idiomatic, simpler and faster and enables you to become productive in just a few hours.

Our goals

  • ⏱️ Productivity
  • Simplicity
  • 📎 Outstanding documentation
  • 🔧 Maintainability

Documentation

Dependencies

Relm4 depends on GTK4: How to install GTK4 and Rust

Ecosystem

Use this in to your Cargo.toml:

# Core library
relm4 = "0.10"
# Optional: reusable components
relm4-components = "0.10"
# Optional: icons (more info at https://github.com/Relm4/icons)
relm4-icons = "0.10"

Features

The relm4 crate has four feature flags:

Flag Purpose Default
macros Enable macros by re-exporting relm4-macros
libadwaita Improved support for libadwaita -
libpanel Improved support for libpanel -
gnome_50 Enable all version feature flags of all dependencies to match the GNOME 50 SDK -
gnome_49 Enable all version feature flags of all dependencies to match the GNOME 49 SDK -
gnome_48 Enable all version feature flags of all dependencies to match the GNOME 48 SDK -
gnome_47 Enable all version feature flags of all dependencies to match the GNOME 47 SDK -
gnome_46 Enable all version feature flags of all dependencies to match the GNOME 46 SDK -
gnome_45 Enable all version feature flags of all dependencies to match the GNOME 45 SDK -
gnome_44 Enable all version feature flags of all dependencies to match the GNOME 44 SDK -
gnome_43 Enable all version feature flags of all dependencies to match the GNOME 43 SDK -
gnome_42 Enable all version feature flags of all dependencies to match the GNOME 42 SDK

The macros feature is a default feature.

Examples

Several example applications are available at examples/.

📸 Screenshots from the example apps

A simple counter app

Simple app screenshot light Simple app screenshot dark

use gtk::prelude::*;
use relm4::prelude::*;

struct App {
    counter: u8,
}

#[derive(Debug)]
enum Msg {
    Increment,
    Decrement,
}

#[relm4::component]
impl SimpleComponent for App {
    type Init = u8;
    type Input = Msg;
    type Output = ();

    view! {
        gtk::Window {
            set_title: Some("Simple app"),
            set_default_size: (300, 100),

            gtk::Box {
                set_orientation: gtk::Orientation::Vertical,
                set_spacing: 5,
                set_margin_all: 5,

                gtk::Button {
                    set_label: "Increment",
                    connect_clicked => Msg::Increment,
                },

                gtk::Button {
                    set_label: "Decrement",
                    connect_clicked => Msg::Decrement,
                },

                gtk::Label {
                    #[watch]
                    set_label: &format!("Counter: {}", model.counter),
                    set_margin_all: 5,
                }
            }
        }
    }

    // Initialize the component.
    fn init(
        counter: Self::Init,
        root: Self::Root,
        sender: ComponentSender<Self>,
    ) -> ComponentParts<Self> {
        let model = App { counter };

        // Insert the code generation of the view! macro here
        let widgets = view_output!();

        ComponentParts { model, widgets }
    }

    fn update(&mut self, msg: Self::Input, _sender: ComponentSender<Self>) {
        match msg {
            Msg::Increment => {
                self.counter = self.counter.wrapping_add(1);
            }
            Msg::Decrement => {
                self.counter = self.counter.wrapping_sub(1);
            }
        }
    }
}

fn main() {
    let app = RelmApp::new("relm4.example.simple");
    app.run::<App>(0);
}

Projects using Relm4

  • fm — A small, general-purpose file manager.
  • Done - A simple and versatile to do app.
  • Reovim - GUI frontend for neovim.
  • NixOS Configuration Editor - A graphical configuration editor for NixOS.
  • Rhino Setup - Setup wizard for Rolling Rhino
  • Lemoa - Desktop client for Lemmy
  • Score Tracker - App for tracking player scores in card and board games
  • Spidey - A seamless and distraction-free work and play environment on the web
  • Toolbox Tuner - An application to manage Toolbx containers
  • BitRitter - A bitwarden/vaultwarden client with mobile devices in mind
  • Space Acres - An opinionated GUI application for farming on Autonomys Network
  • Exercise Timer - An interval training app for the GNOME desktop
  • Words! - on Flathub - A word game similar to Wordle
  • LACT - A GPU configuration and info utility
  • xdg-mimer - A GUI tool for managing MIME associations using XDG standards
  • CoDLinux - A CoD & CoD:UO client helper for GNU/Linux
  • waypomo - endless pomodoro timer for wlroots compositors (uses gtk4-layer-shell)
  • Vinyl - A simple adwaita audio player
  • ratic - A fully-featured music player.

License

Licensed under either of

  • Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
  • MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Feedback and contributions are highly appreciated!

Extension points exported contracts — how you extend this code

FactoryView (Interface)
A trait implemented for GTK4 widgets that allows a factory to create and remove widgets. [13 implementers]
relm4/src/factory/widgets/traits.rs
Select (Interface)
Type of selection used for the open dialog. [2 implementers]
relm4-components/src/open_dialog.rs
TestType (Interface)
(no doc) [1 implementers]
relm4-macros/tests/complex_func_path.rs
FactoryComponent (Interface)
A component that's stored inside a factory. Similar to [`Component`](crate::Component) but adjusted to fit the life cycl [12 …
relm4/src/factory/sync/traits.rs
Component (Interface)
The fundamental building block of a Relm4 application. A `Component` is an element of an application that defines initi [13 …
relm4/src/component/sync/traits.rs
SimpleComponent (Interface)
Elm-style variant of a [`Component`] with view updates separated from input updates. [81 implementers]
relm4/src/component/sync/traits.rs
WidgetTemplate (Interface)
A trait that describes a widget template. Widget templates can be created manually by implementing this trait or by usi [9 …
relm4/src/extensions/mod.rs

Core symbols most depended-on inside this repo

clone
called by 125
relm4/src/actions/mod.rs
push
called by 70
relm4/src/loading_widgets.rs
span
called by 60
relm4-macros/src/widgets/span/attr.rs
clone
called by 58
relm4/src/factory/sync/collections/hashmap.rs
extend
called by 54
relm4/src/factory/sync/collections/vec_deque.rs
clone
called by 37
relm4/src/channel/mod.rs
append
called by 36
relm4/src/typed_view/grid.rs
input_sender
called by 35
relm4/src/channel/component.rs

Shape

Method 900
Class 255
Function 159
Enum 116
Interface 43

Languages

Rust100%

Modules by API surface

relm4/src/factory/sync/collections/vec_deque.rs46 symbols
relm4/src/factory/async/collections/vec_deque.rs40 symbols
relm4/src/typed_view/column.rs36 symbols
relm4/src/factory/sync/collections/hashmap.rs32 symbols
relm4/src/typed_view/list.rs29 symbols
relm4/src/typed_view/grid.rs29 symbols
relm4-macros/src/widgets/mod.rs25 symbols
relm4/src/component/async/traits.rs22 symbols
relm4/src/actions/mod.rs20 symbols
examples/state_management.rs20 symbols
relm4/src/shared_state/state.rs19 symbols
relm4/src/component/sync/traits.rs19 symbols

For agents

$ claude mcp add Relm4 \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact