From 545831408329978dde927938417484894e9e8c81 Mon Sep 17 00:00:00 2001 From: Duncan Tourolle Date: Sun, 20 Sep 2026 19:23:21 +0200 Subject: [PATCH] Split import_ui::wire into one function per section The 188-line wire() registered the import page's callbacks in four comment-delimited sections. Lift each into its own fn: wire_opening_and_closing, wire_choosing_a_source, wire_options, wire_running. context stays generic over C on each of the three functions that use it, matching how survey() and start() already take it (impl Fn, implicitly Sized) rather than coercing it to a trait object, which would have needed ?Sized added to those two unrelated functions for no benefit. --- ui/dr-ui/src/import_ui.rs | 35 +++++++++++++++++++++++++++++++---- 1 file changed, 31 insertions(+), 4 deletions(-) diff --git a/ui/dr-ui/src/import_ui.rs b/ui/dr-ui/src/import_ui.rs index 28052ef..2c98dc3 100644 --- a/ui/dr-ui/src/import_ui.rs +++ b/ui/dr-ui/src/import_ui.rs @@ -310,7 +310,17 @@ where let context = Rc::new(context); let on_imported = Rc::new(on_imported); - // --- opening and closing --------------------------------------------- + wire_opening_and_closing(window, &ctl, &context); + wire_choosing_a_source(window, &ctl, &context); + wire_options(window, &ctl); + wire_running(window, &ctl, &context, &on_imported); +} + +/// Opening and closing. +fn wire_opening_and_closing(window: &AppWindow, ctl: &Rc, context: &Rc) +where + C: Fn() -> Option + 'static, +{ { let weak = window.as_weak(); let ctl = ctl.clone(); @@ -351,8 +361,13 @@ where w.set_show_import(false); }); } +} - // --- choosing a source ------------------------------------------------- +/// Choosing a source. +fn wire_choosing_a_source(window: &AppWindow, ctl: &Rc, context: &Rc) +where + C: Fn() -> Option + 'static, +{ { let weak = window.as_weak(); let ctl = ctl.clone(); @@ -395,8 +410,10 @@ where render(&w, &ctl); }); } +} - // --- options ----------------------------------------------------------- +/// Options. +fn wire_options(window: &AppWindow, ctl: &Rc) { { let weak = window.as_weak(); let ctl = ctl.clone(); @@ -465,8 +482,18 @@ where render(&w, &ctl); }); } +} - // --- running ----------------------------------------------------------- +/// Running. +fn wire_running( + window: &AppWindow, + ctl: &Rc, + context: &Rc, + on_imported: &Rc, +) where + C: Fn() -> Option + 'static, + F: Fn() + 'static, +{ { let weak = window.as_weak(); let ctl = ctl.clone();