12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- use std::sync::mpsc;
- use xcb;
- use mpd;
- use config::Config;
- use ui::context::Context;
- use ui::x11;
- mod title;
- mod tray;
- mod sensors;
- mod wm;
- mod spacer;
- mod music;
- pub use self::title::title;
- pub use self::tray::tray;
- pub use self::sensors::sensors;
- pub use self::spacer::spacer;
- pub use self::music::mpd;
- pub use self::wm::bspwm;
- pub type MessageSender = mpsc::Sender<Message>;
- pub enum Message {
- Update,
- Quit,
- MousePress(u16),
- BspwmEvent(String),
- MpdEvent(mpd::status::State, Option<mpd::song::Song>),
- XcbEvent(xcb::GenericEvent)
- }
- pub enum Update {
- Nothing,
- Rerender,
- Relayout,
- Quit
- }
- pub trait Widget {
- fn init(&mut self) {}
- fn render(&mut self, x: u16, width: u16);
- fn width(&mut self) -> u16;
- fn fit_width(&self) -> bool {
- false
- }
- fn handle_event(&mut self, _event: &Message) -> Update {
- Update::Nothing
- }
- fn finish(&mut self) {}
- }
- #[derive(Clone)]
- pub struct WidgetParams {
- pub id: String,
- pub context: Context,
- pub tx: MessageSender,
- pub config: Config
- }
- impl WidgetParams {
- fn conn(&self) -> x11::Connection {
- self.context.conn.clone()
- }
- fn window(&self) -> xcb::Window {
- self.context.window
- }
- }
- pub type WidgetConstructor = fn(WidgetParams) -> Box<Widget>;
|