[][src]Crate gtk_liststore_item

Automatic gtk::ListStore struct derive for Rust.

Example

use gtk::prelude::*;

use gladis::Gladis;
use gladis_proc_macro::Gladis;
use gtk_liststore_item::ListStoreItem;
use gtk_liststore_item_derive::ListStoreItem;

const GLADE_SRC: &str = r#"
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.22.2 -->
<interface>
  <requires lib="gtk+" version="3.20"/>
  <object class="GtkListStore" id="list_store">
    <columns>
      <!-- column-name name -->
      <column type="gchararray"/>
      <!-- column-name value -->
      <column type="guint"/>
    </columns>
  </object>
</interface>
"#;

#[derive(Gladis)]
struct Glade {
    list_store: gtk::ListStore,
}

#[derive(ListStoreItem)]
struct Item {
    name: String,
    value: u32,
}

fn main() {
    gtk::init().unwrap();

    let glade = Glade::from_string(GLADE_SRC);

    let item = Item { name: "foobar".into(), value: 42 };
    item.insert_into_liststore(glade.list_store);
}

Traits

ListStoreItem

A trait to ease interraction with a ListStore using an intermediate struct.