1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
pub mod i3block_data;
pub mod rotatingtext;
pub mod text;
use std::str::FromStr;
use serde::de::value::{Error, StrDeserializer};
use serde::de::{Deserialize, IntoDeserializer};
use serde_derive::Deserialize;
use crate::themes::Theme;
use i3block_data::I3BlockData;
#[derive(Debug, Copy, Clone, Deserialize)]
pub enum Spacing {
Normal,
Inline,
Hidden,
}
#[derive(Debug, Copy, Clone, Deserialize)]
pub enum State {
Idle,
Info,
Good,
Warning,
Critical,
}
impl State {
pub fn theme_keys(self, theme: &Theme) -> (&Option<String>, &Option<String>) {
use self::State::*;
match self {
Idle => (&theme.idle_bg, &theme.idle_fg),
Info => (&theme.info_bg, &theme.info_fg),
Good => (&theme.good_bg, &theme.good_fg),
Warning => (&theme.warning_bg, &theme.warning_fg),
Critical => (&theme.critical_bg, &theme.critical_fg),
}
}
}
impl FromStr for State {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let deserializer: StrDeserializer<Error> = s.into_deserializer();
State::deserialize(deserializer).map_err(|_| ())
}
}
pub trait I3BarWidget {
fn get_data(&self) -> I3BlockData;
}