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

macro gladis_proc_macro

Easily import Glade-generated UI files into Rust code (proc macro)

8 unstable releases (3 breaking)

0.4.1 Aug 8, 2020
0.4.0 Jul 30, 2020
0.3.1 Jul 30, 2020
0.2.1 Jul 19, 2020
0.1.1 Jul 14, 2020

#4 in #glade

Download history 64/week @ 2021-01-01 129/week @ 2021-01-08 105/week @ 2021-01-15 93/week @ 2021-01-22 88/week @ 2021-01-29 92/week @ 2021-02-05 300/week @ 2021-02-12 501/week @ 2021-02-19 341/week @ 2021-02-26 170/week @ 2021-03-05 358/week @ 2021-03-12 273/week @ 2021-03-19 165/week @ 2021-03-26 158/week @ 2021-04-02 198/week @ 2021-04-09 113/week @ 2021-04-16

705 downloads per month
Used in 3 crates

MIT/Apache

7KB

gladis

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 = "0.4.*"

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 like described in the official Gtk-rs Glade tutorial:

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
            .get_object("window")
            .expect("Failed to find the window object");

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

        Self { window, label }
    }
}

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

~350–780KB
~19K SLoC