#gui #gtk #gnome #glade #gtk-rs

gladis

Easily import Glade-generated UI files into Rust code

11 releases (2 stable)

1.0.1 Sep 20, 2021
1.0.0 Jul 5, 2021
0.4.1 Aug 8, 2020
0.4.0 Jul 30, 2020
0.1.2 Jul 14, 2020

#26 in GUI

Download history 403/week @ 2021-06-29 385/week @ 2021-07-06 534/week @ 2021-07-13 457/week @ 2021-07-20 344/week @ 2021-07-27 143/week @ 2021-08-03 183/week @ 2021-08-10 280/week @ 2021-08-17 126/week @ 2021-08-24 82/week @ 2021-08-31 40/week @ 2021-09-07 25/week @ 2021-09-14 24/week @ 2021-09-21 28/week @ 2021-09-28 14/week @ 2021-10-05 26/week @ 2021-10-12

1,032 downloads per month
Used in 3 crates

MIT/Apache

18KB
98 lines

gladis

Build Latest version Documentation License

A Rust crate to easily import Glade-generated UI files into Rust code.

Usage

In order to use Gladis, you have to add the following dependencies into your project's Cargo.toml file:

[dependencies]
gladis = "1.0.1"

After this is done, you can enjoy the Gladis derive!

#[derive(Gladis, Clone)]
pub struct Window {
    pub window: gtk::ApplicationWindow,
    pub label: gtk::Label,
}

impl Window {
    pub fn new() -> Self {
        Self::from_resource("/dev/null/hello_builder/window.ui").unwrap()
    }
}

Without Gladis, you would have to manually parse each of the Glade entries.

pub struct Window {
    pub window: gtk::ApplicationWindow,
    pub label: gtk::Label,
}

impl Window {
    pub fn new() -> Self {
        let builder = gtk::Builder::from_resource("/dev/null/hello_builder/window.ui");
        let window: gtk::ApplicationWindow = builder
            .object("window")
            .expect("Failed to find the window object");

        let label: gtk::Label = builder
            .object("label")
            .expect("Failed to find the label object");

        Self { window, label }
    }
}

Relm support

This crate is compatible with Relm, a popular framework for writing UIs with GTK+. See the examples/relm directory, and give it a shot!

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.

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

Dependencies

~16MB
~382K SLoC