#gtk #gnome #glade #macro-derive

deprecated macro glade_derive

Deprecated. Use gtk-rs's CompositeTemplate derive macro instead.

2 releases (1 stable)

2.2.0 Jul 21, 2023
0.1.0-alpha Jun 13, 2020

#9 in #glade

Download history 6/week @ 2024-02-19 27/week @ 2024-02-26 8/week @ 2024-03-04 9/week @ 2024-03-11 1/week @ 2024-03-18 13/week @ 2024-03-25 57/week @ 2024-04-01

82 downloads per month
Used in glade

MIT/Apache

8KB

gladis

Build Latest version Documentation License REUSE status

Easily import Glade-generated UI files into Rust code.

This crate is a fork of a DEPRECATED https://github.com/gagath/gladis maintained for backward compatibility

Usage

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

[dependencies]
glade = "2.2.0"

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

~1.5MB
~33K SLoC