Skip to content

Commit

Permalink
make ScrolledWindow direct parent of directory ListView
Browse files Browse the repository at this point in the history
Otherwise, the ListView does not receive the adjustments, and the list
items don't update as the view is scrolled.

Fixes #57.
  • Loading branch information
euclio committed Aug 14, 2023
1 parent 9abae42 commit 3d57a77
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/component/directory_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,31 +119,29 @@ impl FactoryComponent for Directory {
type CommandOutput = ();

view! {
root = gtk::ScrolledWindow {
root = gtk::Stack {
set_width_request: WIDTH,
set_hscrollbar_policy: gtk::PolicyType::Never,

#[name = "stack"]
gtk::Stack {
set_vhomogeneous: false,
add_child = &gtk::Spinner {
set_halign: gtk::Align::Center,
set_valign: gtk::Align::Center,
set_spinning: true,
} -> { set_name: "spinner" },

add_child = &gtk::Spinner {
set_halign: gtk::Align::Center,
set_valign: gtk::Align::Center,
set_spinning: true,
} -> { set_name: "spinner" },
add_child = &gtk::ScrolledWindow {
set_hscrollbar_policy: gtk::PolicyType::Never,

#[wrap(Some)]
#[name = "list_view"]
add_child = &gtk::ListView {
set_child = &gtk::ListView {
set_factory: Some(&factory),
set_model: Some(&self.list_model),

connect_activate[sender] => move |_, position| {
sender.input(DirectoryMessage::OpenItemAtPosition(position))
}

} -> { set_name: "listing" },
}
},
} -> { set_name: "listing" },
}
}

Expand Down Expand Up @@ -269,7 +267,7 @@ impl FactoryComponent for Directory {
widgets.list_view.add_controller(click_controller);

self.directory_list
.bind_property("loading", &widgets.stack, "visible-child-name")
.bind_property("loading", &widgets.root, "visible-child-name")
.transform_to(|_, loading| Some(if loading { "spinner" } else { "listing" }))
.sync_create()
.build();
Expand Down

0 comments on commit 3d57a77

Please sign in to comment.