use relm4::{ adw::prelude::{BoxExt, OrientableExt, WidgetExt}, factory::{FactoryPrototype, FactoryVec}, gtk::{self, Orientation}, view, Sender, WidgetPlus, }; use super::{ messages::ToolboxAppDialogMsg, model::DotDesktopApplication, widgets::AppFactoryWidgets, }; impl FactoryPrototype for DotDesktopApplication { type Factory = FactoryVec; type Widgets = AppFactoryWidgets; type Root = gtk::Box; type View = gtk::FlowBox; type Msg = ToolboxAppDialogMsg; fn init_view( &self, key: &>::Key, sender: Sender, ) -> Self::Widgets { view! { app_box = >k::Box { set_css_classes: &[&"card"], set_halign: gtk::Align::Center, set_valign: gtk::Align::Center, set_orientation: Orientation::Vertical, set_hexpand: false, set_vexpand: false, set_width_request: 100, set_height_request: 100, append = >k::Switch { set_halign: gtk::Align::Center, set_valign: gtk::Align::Center, set_hexpand: false, set_vexpand: false, set_margin_all: 10, set_active: self.selected, }, append = >k::Image::from_file(&self.icon_path) { set_halign: gtk::Align::Center, set_valign: gtk::Align::Center, set_width_request: 64, set_height_request: 64, set_margin_start: 36, set_margin_end: 36, set_hexpand: false, set_vexpand: false, }, append = >k::Label { set_halign: gtk::Align::Center, set_valign: gtk::Align::Center, set_text: &self.name, set_margin_all: 5, set_hexpand: false, set_vexpand: false, } } } AppFactoryWidgets { app_box } } fn position( &self, key: &>::Key, ) -> >::Position { } fn view( &self, key: &>::Key, widgets: &Self::Widgets, ) { } fn root_widget(widgets: &Self::Widgets) -> &Self::Root { &widgets.app_box } }