From 5ee898c9c5e7441f4eca3a2ad5877190ff9c6842 Mon Sep 17 00:00:00 2001 From: Julian Mutter Date: Fri, 2 Feb 2024 21:17:03 +0100 Subject: [PATCH] Use ListBox Widget --- src/ui/sheet_listing.rs | 9 +++++---- src/ui/sheet_model.rs | 16 +++++++++------- 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/src/ui/sheet_listing.rs b/src/ui/sheet_listing.rs index d1ec6a6..b1578c5 100644 --- a/src/ui/sheet_listing.rs +++ b/src/ui/sheet_listing.rs @@ -31,9 +31,10 @@ impl SimpleComponent for SheetListingModel { gtk::Box { // set_orientation: gtk::Orientation::Vertical, - model.sheets.widget() -> >k::Box { - set_orientation: gtk::Orientation::Vertical, - set_spacing: 5, + model.sheets.widget() -> >k::ListBox { + set_hexpand: true, + // set_orientation: gtk::Orientation::Vertical, + // set_spacing: 5, }, } } @@ -43,7 +44,7 @@ impl SimpleComponent for SheetListingModel { root: &Self::Root, sender: ComponentSender, ) -> ComponentParts { - 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 { sheets.guard().push_back(sheet_model_type); } diff --git a/src/ui/sheet_model.rs b/src/ui/sheet_model.rs index 7c868a2..6100624 100644 --- a/src/ui/sheet_model.rs +++ b/src/ui/sheet_model.rs @@ -19,7 +19,7 @@ pub struct SheetModel { #[relm4::factory(pub)] impl FactoryComponent for SheetModel { type Init = SheetModelType; - type ParentWidget = gtk::Box; + type ParentWidget = gtk::ListBox; type CommandOutput = (); type ParentInput = SheetListingInput; type Input = (); @@ -27,12 +27,14 @@ impl FactoryComponent for SheetModel { view! { #[root] - gtk::Box { - set_orientation: gtk::Orientation::Vertical, - append = >k::Label { - set_label: &self.label, - set_halign: gtk::Align::Start, - set_margin_all: 10, + gtk::ListBoxRow { + gtk::Box { + set_orientation: gtk::Orientation::Vertical, + append = >k::Label { + set_label: &self.label, + set_halign: gtk::Align::Start, + set_margin_all: 10, + } } } }