Automatic gtk::ListStore
struct derive for Rust.
In order to use this crate, you have to add the following dependencies into
your project's Cargo.toml
file:
toml
[dependencies]
gtk_liststore_item = "1.2.0"
After the crate is installed, you can enjoy the ListStoreItem
derive!
By defining the following structure:
```rust
struct Item { name: String, value: u32, progress: u32, is_cool: bool, } ```
You can directly create and add items to the gtk::ListStore
model:
```rust let mut liststore: gtk::ListStore = Item::newliststore();
for i in 0..10 {
let item = Item {
name: format!("foobar{}", i),
value: rand::random(),
progress: rand::random::
And directly see the result inside a GtkTreeView
widget:
Without this crate, you would have to manually serialize each of the entries in your struct with their type and position:
```rust fn newliststore() -> gtk::ListStore { gtk::ListStore::new(&[ String::statictype(), u32::statictype(), u32::statictype(), bool::static_type(), ]) }
fn getitem(liststore: >k::ListStore, iter: >k::TreeIter) -> Item {
Some(Item {
name: liststore.value(&iter, 0).get::
fn insertitem(item: &Item, liststore: &mut gtk::ListStore) -> gtk::TreeIter { liststore.insertwithvalues( None, &[ (0, &self.name), (1, &self.value), (2, &self.progress), (3, &self.iscool) ] ) } ```
This can become pretty tedious, hence this crate to ease the process.
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.