use std::path::PathBuf; use std::sync::Arc; use druid::text::Formatter; use druid::{Data, Widget}; pub mod controller; pub trait ExtraWidgetExt: Widget + Sized + 'static {} impl + 'static> ExtraWidgetExt for W {} pub(crate) struct PathBufFormatter; impl PathBufFormatter { pub fn new() -> Self { Self {} } } impl Formatter> for PathBufFormatter { fn format(&self, value: &Arc) -> String { value.display().to_string() } fn validate_partial_input( &self, _input: &str, _sel: &druid::text::Selection, ) -> druid::text::Validation { druid::text::Validation::success() } fn value(&self, input: &str) -> Result, druid::text::ValidationError> { let p = PathBuf::from(input); Ok(Arc::new(p)) } }