Crates.io | gladis4_proc_macro |
lib.rs | gladis4_proc_macro |
version | 0.1.0 |
source | src |
created_at | 2022-02-08 07:46:41.691264 |
updated_at | 2022-02-08 07:46:41.691264 |
description | Easily import Glade-generated UI files into Rust code (proc macro). |
homepage | |
repository | https://github.com/MicroJoe/gladis |
max_upload_size | |
id | 528933 |
size | 16,607 |
Forked from Gladis.
A Rust crate to easily import Glade-generated UI files into Rust code.
In order to use Gladis4, you have to add the following dependencies into your
project's Cargo.toml
file:
[dependencies]
gladis4 = "0.1.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 }
}
}
This crate is compatible with Relm4, a
popular framework for writing UIs with GTK+. See the examples/relm
directory,
and give it a shot!
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.