Fix: the gtk stack
widget bugfix (#1119)
* Fixed the gtk stack widget * Add changelog entry for the stack widget bugfix * Small code style improvement Co-authored-by: Wölfchen <w-lfchen@posteo.net> --------- Co-authored-by: ElKowar <lkowarschick@gmail.com> Co-authored-by: Wölfchen <w-lfchen@posteo.net>
This commit is contained in:
parent
b62094fa5d
commit
367363975e
2 changed files with 23 additions and 22 deletions
|
@ -8,6 +8,7 @@ All notable changes to eww will be listed here, starting at changes since versio
|
|||
- Re-enable some scss features (By: w-lfchen)
|
||||
- Fix and refactor nix flake (By: w-lfchen)
|
||||
- Fix remove items from systray (By: vnva)
|
||||
- Fix the gtk `stack` widget (By: ovalkonia)
|
||||
|
||||
### Features
|
||||
- Update rust toolchain to 1.80.1 (By: w-lfchen)
|
||||
|
|
|
@ -1089,20 +1089,11 @@ const WIDGET_NAME_STACK: &str = "stack";
|
|||
/// @desc A widget that displays one of its children at a time
|
||||
fn build_gtk_stack(bargs: &mut BuilderArgs) -> Result<gtk::Stack> {
|
||||
let gtk_widget = gtk::Stack::new();
|
||||
def_widget!(bargs, _g, gtk_widget, {
|
||||
// @prop selected - index of child which should be shown
|
||||
prop(selected: as_i32) { gtk_widget.set_visible_child_name(&selected.to_string()); },
|
||||
// @prop transition - the name of the transition. Possible values: $transition
|
||||
prop(transition: as_string = "crossfade") { gtk_widget.set_transition_type(parse_stack_transition(&transition)?); },
|
||||
// @prop same-size - sets whether all children should be the same size
|
||||
prop(same_size: as_bool = false) { gtk_widget.set_homogeneous(same_size); }
|
||||
});
|
||||
|
||||
match bargs.widget_use.children.len().cmp(&1) {
|
||||
Ordering::Less => {
|
||||
Err(DiagError(gen_diagnostic!("stack must contain at least one element", bargs.widget_use.span)).into())
|
||||
if bargs.widget_use.children.len() < 1 {
|
||||
return Err(DiagError(gen_diagnostic!("stack must contain at least one element", bargs.widget_use.span)).into());
|
||||
}
|
||||
Ordering::Greater | Ordering::Equal => {
|
||||
|
||||
let children = bargs.widget_use.children.iter().map(|child| {
|
||||
build_gtk_widget(
|
||||
bargs.scope_graph,
|
||||
|
@ -1112,15 +1103,24 @@ fn build_gtk_stack(bargs: &mut BuilderArgs) -> Result<gtk::Stack> {
|
|||
bargs.custom_widget_invocation.clone(),
|
||||
)
|
||||
});
|
||||
|
||||
for (i, child) in children.enumerate() {
|
||||
let child = child?;
|
||||
gtk_widget.add_named(&child, &i.to_string());
|
||||
child.show();
|
||||
}
|
||||
|
||||
def_widget!(bargs, _g, gtk_widget, {
|
||||
// @prop selected - index of child which should be shown
|
||||
prop(selected: as_i32) { gtk_widget.set_visible_child_name(&selected.to_string()); },
|
||||
// @prop transition - the name of the transition. Possible values: $transition
|
||||
prop(transition: as_string = "crossfade") { gtk_widget.set_transition_type(parse_stack_transition(&transition)?); },
|
||||
// @prop same-size - sets whether all children should be the same size
|
||||
prop(same_size: as_bool = false) { gtk_widget.set_homogeneous(same_size); }
|
||||
});
|
||||
|
||||
Ok(gtk_widget)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const WIDGET_NAME_TRANSFORM: &str = "transform";
|
||||
/// @widget transform
|
||||
|
|
Loading…
Add table
Reference in a new issue