[][src]Derive Macro woab::Factories

#[derive(Factories)]
{
    // Attributes available to this derive:
    #[factory]
}

Dissect a single Glade XML file to multiple builder factories.

The motivation is to design nested repeated hierarchies (like GtkListBoxRows inside GtkListBox) and see how they look together inside Glade, and then split the XML to multiple factories that create them separately during runtime.

Typically the fields of the struct will be of type woab::Factory, but anything From<String> is allowed so woab::BuilderFactory or even just Strings are also okay, if they are needed.

If a widget needs to be accompanied by some root level resource (like GtkTextBuffer or GtkListStore) these resources should be listed inside a #[factory(extra(...))] attribute.

#[derive(woab::Factories)]
struct Factories {
    main_window: woab::Factory<MainWindowActor, MainWindowWidgets, MainWindowSignal>,
    #[factory(extra(some_text_buffer_used_by_a_text_box_in_sub_window))]
    sub_window: woab::Factory<SubWindowActor, SubWindowWidgets, SubWindowSignal>,
    some_list_box_row: woab::Factory<(), SomeListBoxRowWidgets, SomeListBoxRowSignal>, // doesn't have its own actor
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let factories = Factories::read(read_builder_xml())?;
}