GithubHelp home page GithubHelp logo

icons's Introduction

CI Matrix Relm4 on crates.io Relm4 docs Relm4 book Minimum Rust version 1.75 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.9"
# Optional: reusable components
relm4-components = "0.9"
# Optional: icons (more info at https://github.com/Relm4/icons)
relm4-icons = "0.9.0"

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_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/.

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

License

Licensed under either of

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!

icons's People

Contributors

aaronerhardt avatar dependabot[bot] avatar edfloreshz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

icons's Issues

[Feature Request] Add Material Icons to the mix

Hi! Thanks a lot for the work on this library and Relm4.

I'd love to suggest adding Material Icons support in this library, since it'll widen the available options for developers.

Are there any legal barriers to that?

Icons are not initialized if CARGO_TARGET_DIR is used

The way config file is searched doesn't account for CARGO_TARGET_DIR and results in errors like this:

error: failed to run custom build command for `relm4-icons v0.8.2`

Caused by:
  process didn't exit successfully: `/home/nazar-pc/.cache/cargo/target/debug/build/relm4-icons-7ebbb2f82f7cb94e/build-script-build` (exit status: 101)
  --- stderr
  Canonical manifest dir: "/home/nazar-pc/.cache/cargo/target/debug/build/relm4-icons-9b161a11a467e328/out"
  thread 'main' panicked at /home/nazar-pc/.cargo/registry/src/index.crates.io-6f17d22bba15001f/relm4-icons-0.8.2/build.rs:68:17:
  Couldn't find your manifest directory
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

/home/nazar-pc/.cache/cargo/target is my target shared across multiple projects, I don't have target local to each crate.

`cargo:rerun-if-changed={folder}` doesn't run recompiling after icons folder was changed

icons.toml

icon_folder = "src/res/icons"

When I put a new svg icon to the icon_folder (the folder modify property is changed) and cargo run an app doesn't display a new icon, because cargo doesn't rerun the icons building script.
I need save the icons.toml without any changes in order to update the modify property of the file to rerun compiling of relm4-icons crate build script.

I think a path to icon_folder should be a full path.

error: failed to run custom build command for `relm4-icons v0.8.2`

on cargo run return this error

error: failed to run custom build command for `relm4-icons v0.8.2`

Caused by:
  process didn't exit successfully: `/home/user/dev/program/target/debug/build/relm4-icons-b8881cef220bc5e9/build-script-build` (exit status:
 101)
  --- stderr
  Canonical manifest dir: "/home/user/dev/program/target/debug/build/relm4-icons-38946ca3132a2567/out"
  thread 'main' panicked at /home/user/.cargo/registry/src/index.crates.io-6f17d22bba15001f/relm4-icons-0.8.2/build.rs:75:36:
  called `Result::unwrap()` on an `Err` value: Os { code: 2, kind: NotFound, message: "No such file or directory" }
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
warning: build failed, waiting for other jobs to finish...

Wrong icon name

I have "network-workgroup" in the icons.toml file and use it in code:

gtk::Image {
    set_icon_name: Some(icon_names::NETWORK_WORKGROUP),
},

the generated file icon_names.rs contains these lines:

/// Icon name of the icon `network-workgroup`, found at `"icons/icon-development-kit/network-workgroup-symbolic.svg"`.
pub const NETWORK_WORKGROUP: &str = "network-workgroup";

the problem is the icon shown is not network-workgroup-symbolic but simple network-workgroup with colors.
If I set_icon_name: Some("network-workgroup-symbolic") I get a symbolic icon as expected.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.