gdritter repos knurling / 5265971
a few tweaks Getty Ritter 3 years ago
3 changed file(s) with 15 addition(s) and 9 deletion(s). Collapse all Expand all
156156 }
157157 ctx.paint();
158158
159 // set the foreground color for drawing
160 {
161 let (r, g, b) = self.fg_color;
162 ctx.set_source_rgb(r, g, b);
163 }
164
165159 // set up a struct with everything that widgets need to draw
166160 let d = w::Drawing {
167161 ctx,
173167
174168 let mut offset = 10;
175169 for w in self.left.iter() {
170 // set the foreground color for drawing
171 {
172 let (r, g, b) = self.fg_color;
173 ctx.set_source_rgb(r, g, b);
174 }
176175 offset += 10 + w.widget.draw(&d, w::Located::FromLeft(offset));
177176 }
178177 offset = 10;
179178 for w in self.right.iter() {
179 // set the foreground color for drawing
180 {
181 let (r, g, b) = self.fg_color;
182 ctx.set_source_rgb(r, g, b);
183 }
180184 offset += 10 + w.widget.draw(&d, w::Located::FromRight(offset));
181185 }
182186
4848
4949 // we do some grossness with file descriptors later, so we need
5050 // the file descriptors we care about here
51 let window_fds: Vec<i32> = ws.iter_mut().map({ |w| w.get_fd() }).collect();
51 let window_fds: Vec<i32> = ws.iter_mut().map(|w| w.get_fd()).collect();
5252 let stdin_fd = std::io::stdin().as_raw_fd();
5353
5454 // To begin with, our left-hand side---which normally is whatever
11 pub mod battery;
2 pub mod chromachron;
23 pub mod mpd;
34 pub mod standard;
45 pub mod widget;
56
67 pub use crate::widgets::widget::{Drawing, Located, Size, Widget};
78
8 const ALL_WIDGETS: [(
9 const ALL_WIDGETS: &[(
910 &str,
1011 &dyn Fn(&toml::map::Map<String, toml::Value>) -> Result<Box<dyn Widget>, failure::Error>,
11 ); 6] = [
12 )] = &[
1213 ("box", &|_| Ok(Box::new(standard::Time::new()))),
1314 ("battery", &|_| Ok(Box::new(battery::Battery::new()?))),
1415 ("caesura", &|_| Ok(Box::new(standard::Caesura))),
16 ("chromachron", &|_| Ok(Box::new(chromachron::Chromachron))),
1517 ("mpd", &|config| {
1618 let host = config["host"]
1719 .as_str()