I have successfully migrated my TreeView to a ColumnView up to the stage where all the data is bound and shows as required, but the TreeExpander is not showing at all.
The factory set up is below
pub(crate) fn build_tree_column_factory<T: IsA<Object>>(f: fn(Label, &T)) -> SignalListItemFactory {
let factory = SignalListItemFactory::new();
factory.connect_setup(move |_, list_item| {
let label = Label::new(None);
let expander = TreeExpander::new();
expander.set_child(Some(&label));
expander.set_indent_for_icon(true);
list_item
.downcast_ref::<ListItem>()
.expect("Needs to be ListItem")
.set_child(Some(&expander));
});
factory.connect_bind(move |_, list_item| {
// Get `StringObject` from `ListItem`
let obj = list_item
.downcast_ref::<ListItem>()
.expect("Needs to be ListItem")
.item()
.and_downcast::<T>()
.expect("The item has to be an <T>.");
// Get `Label` from `ListItem`
if let Some(widget) = list_item
.downcast_ref::<ListItem>()
.expect("Needs to be ListItem")
.child() {
let expander = widget.downcast::<TreeExpander>()
.expect("The child has to be a `Expander`.");
let widget = expander.child()
.expect("The child has to be a `Widget`.");
let label = widget.downcast::<Label>()
.expect("The child has to be a `Label`.");
// Set "label" to "value"
f(label, &obj);
// get the item from the tree list row
if list_item.is::<TreeListRow>() {
let row = list_item.downcast_ref::<TreeListRow>().unwrap();
expander.set_list_row(Some(row));
}
}
});
factory
}
The data is exactly as I want, but no expander icons