Use ListBox Widget

This commit is contained in:
Julian Mutter 2024-02-02 21:17:03 +01:00
parent 9069138255
commit 5ee898c9c5
2 changed files with 14 additions and 11 deletions

View File

@ -31,9 +31,10 @@ impl SimpleComponent for SheetListingModel {
gtk::Box { gtk::Box {
// set_orientation: gtk::Orientation::Vertical, // set_orientation: gtk::Orientation::Vertical,
model.sheets.widget() -> &gtk::Box { model.sheets.widget() -> &gtk::ListBox {
set_orientation: gtk::Orientation::Vertical, set_hexpand: true,
set_spacing: 5, // set_orientation: gtk::Orientation::Vertical,
// set_spacing: 5,
}, },
} }
} }
@ -43,7 +44,7 @@ impl SimpleComponent for SheetListingModel {
root: &Self::Root, root: &Self::Root,
sender: ComponentSender<Self>, sender: ComponentSender<Self>,
) -> ComponentParts<Self> { ) -> ComponentParts<Self> {
let mut sheets = FactoryVecDeque::new(gtk::Box::default(), sender.input_sender()); let mut sheets = FactoryVecDeque::new(gtk::ListBox::default(), sender.input_sender());
for sheet_model_type in init { for sheet_model_type in init {
sheets.guard().push_back(sheet_model_type); sheets.guard().push_back(sheet_model_type);
} }

View File

@ -19,7 +19,7 @@ pub struct SheetModel {
#[relm4::factory(pub)] #[relm4::factory(pub)]
impl FactoryComponent for SheetModel { impl FactoryComponent for SheetModel {
type Init = SheetModelType; type Init = SheetModelType;
type ParentWidget = gtk::Box; type ParentWidget = gtk::ListBox;
type CommandOutput = (); type CommandOutput = ();
type ParentInput = SheetListingInput; type ParentInput = SheetListingInput;
type Input = (); type Input = ();
@ -27,12 +27,14 @@ impl FactoryComponent for SheetModel {
view! { view! {
#[root] #[root]
gtk::Box { gtk::ListBoxRow {
set_orientation: gtk::Orientation::Vertical, gtk::Box {
append = &gtk::Label { set_orientation: gtk::Orientation::Vertical,
set_label: &self.label, append = &gtk::Label {
set_halign: gtk::Align::Start, set_label: &self.label,
set_margin_all: 10, set_halign: gtk::Align::Start,
set_margin_all: 10,
}
} }
} }
} }