fix: improve scope handling (#1189)
* fix: first attempt at fixing scopes for widgets with children * fix: new scope for every child * chore: remove debug print
This commit is contained in:
parent
2c81b3fbc7
commit
81398d6d28
1 changed files with 14 additions and 7 deletions
|
@ -306,13 +306,14 @@ fn build_children_special_widget(
|
||||||
.children
|
.children
|
||||||
.get(nth_value as usize)
|
.get(nth_value as usize)
|
||||||
.with_context(|| format!("No child at index {}", nth_value))?;
|
.with_context(|| format!("No child at index {}", nth_value))?;
|
||||||
let new_child_widget = build_gtk_widget(
|
let scope = tree.register_new_scope(
|
||||||
tree,
|
format!("child {nth_value}"),
|
||||||
widget_defs.clone(),
|
Some(custom_widget_invocation.scope),
|
||||||
custom_widget_invocation.scope,
|
calling_scope,
|
||||||
nth_child_widget_use.clone(),
|
HashMap::new(),
|
||||||
None,
|
|
||||||
)?;
|
)?;
|
||||||
|
let new_child_widget =
|
||||||
|
build_gtk_widget(tree, widget_defs.clone(), scope, nth_child_widget_use.clone(), None)?;
|
||||||
child_container.children().iter().for_each(|f| child_container.remove(f));
|
child_container.children().iter().for_each(|f| child_container.remove(f));
|
||||||
child_container.set_child(Some(&new_child_widget));
|
child_container.set_child(Some(&new_child_widget));
|
||||||
new_child_widget.show();
|
new_child_widget.show();
|
||||||
|
@ -323,7 +324,13 @@ fn build_children_special_widget(
|
||||||
)?;
|
)?;
|
||||||
} else {
|
} else {
|
||||||
for child in &custom_widget_invocation.children {
|
for child in &custom_widget_invocation.children {
|
||||||
let child_widget = build_gtk_widget(tree, widget_defs.clone(), custom_widget_invocation.scope, child.clone(), None)?;
|
let scope = tree.register_new_scope(
|
||||||
|
String::from("child"),
|
||||||
|
Some(custom_widget_invocation.scope),
|
||||||
|
calling_scope,
|
||||||
|
HashMap::new(),
|
||||||
|
)?;
|
||||||
|
let child_widget = build_gtk_widget(tree, widget_defs.clone(), scope, child.clone(), None)?;
|
||||||
gtk_container.add(&child_widget);
|
gtk_container.add(&child_widget);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue