diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-11-18 16:38:51 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-11-18 16:38:51 -0700 |
| commit | dcf0c6ce5ce21647640b2b35715ede50a5a97881 (patch) | |
| tree | 7cf9e269511074553181883df16a4b1e6269bb37 /src/main.rs | |
| parent | 0bcfe7b468a83436a077824ca60e09c5fdd3f803 (diff) | |
dyn Module
fun this also seemed a good time to clean up the bibliography and publish it Force-Push: yes Change-Id: Ia8014fb84c1af37be4f3c915b8b8f70bc2022034
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/main.rs b/src/main.rs index 2d3c1d1..38a993f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -57,7 +57,11 @@ struct Dock { font: Arc<Font>, baseline_position: i16, facilities: FacilityMap, - time_module: Arc<Mutex<TimeModule>>, + modules: Vec<(Arc<Mutex<Box<dyn Module>>>, ModuleFraming)>, +} + +struct ModuleFraming { + alignment: Alignment, } unsafe impl Send for Dock { } @@ -175,7 +179,12 @@ impl Dock { let facilities = FacilityMap::new(); - let time_module = TimeModule::new()?; + let mut modules = Vec::new(); + modules.push((Arc::new(Mutex::new(TimeModule::new()?.as_box())), + ModuleFraming + { + alignment: Alignment::Right, + })); /* We start is_visible at false. Since redraw events set it to true, this * won't make us miss any drawing. @@ -187,7 +196,7 @@ impl Dock { font, baseline_position, facilities, - time_module, + modules, }; dock.set_string_property(&xcb::x::ATOM_WM_NAME, b"sandbar")?; @@ -297,13 +306,16 @@ impl Dock { self.draw_text("playful cool fic tech nonfic", Alignment::Left)?; - let time = self.time_module.lock()?.format(); - self.draw_text(&time, Alignment::Right)?; + for (module, framing) in &self.modules { + let text = module.lock()?.format(); + self.draw_text(&text, framing.alignment)?; + } let mut shortest_duration = None; - - let next_duration = self.time_module.lock()?.sleep_duration(); - shortest_duration = shorter_duration(shortest_duration, next_duration); + for (module, _) in &self.modules { + let next_duration = module.lock()?.sleep_duration(); + shortest_duration = shorter_duration(shortest_duration, next_duration); + } Ok(shortest_duration) } |