a few tweaks
Getty Ritter
3 years ago
156 | 156 |
}
|
157 | 157 |
ctx.paint();
|
158 | 158 |
|
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 | |
|
165 | 159 |
// set up a struct with everything that widgets need to draw
|
166 | 160 |
let d = w::Drawing {
|
167 | 161 |
ctx,
|
|
173 | 167 |
|
174 | 168 |
let mut offset = 10;
|
175 | 169 |
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 |
}
|
176 | 175 |
offset += 10 + w.widget.draw(&d, w::Located::FromLeft(offset));
|
177 | 176 |
}
|
178 | 177 |
offset = 10;
|
179 | 178 |
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 |
}
|
180 | 184 |
offset += 10 + w.widget.draw(&d, w::Located::FromRight(offset));
|
181 | 185 |
}
|
182 | 186 |
|
48 | 48 |
|
49 | 49 |
// we do some grossness with file descriptors later, so we need
|
50 | 50 |
// 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();
|
52 | 52 |
let stdin_fd = std::io::stdin().as_raw_fd();
|
53 | 53 |
|
54 | 54 |
// To begin with, our left-hand side---which normally is whatever
|
1 | 1 |
pub mod battery;
|
| 2 |
pub mod chromachron;
|
2 | 3 |
pub mod mpd;
|
3 | 4 |
pub mod standard;
|
4 | 5 |
pub mod widget;
|
5 | 6 |
|
6 | 7 |
pub use crate::widgets::widget::{Drawing, Located, Size, Widget};
|
7 | 8 |
|
8 | |
const ALL_WIDGETS: [(
|
| 9 |
const ALL_WIDGETS: &[(
|
9 | 10 |
&str,
|
10 | 11 |
&dyn Fn(&toml::map::Map<String, toml::Value>) -> Result<Box<dyn Widget>, failure::Error>,
|
11 | |
); 6] = [
|
| 12 |
)] = &[
|
12 | 13 |
("box", &|_| Ok(Box::new(standard::Time::new()))),
|
13 | 14 |
("battery", &|_| Ok(Box::new(battery::Battery::new()?))),
|
14 | 15 |
("caesura", &|_| Ok(Box::new(standard::Caesura))),
|
| 16 |
("chromachron", &|_| Ok(Box::new(chromachron::Chromachron))),
|
15 | 17 |
("mpd", &|config| {
|
16 | 18 |
let host = config["host"]
|
17 | 19 |
.as_str()
|