2022-08-14 14:30:13 +01:00
|
|
|
/// Displays the current date and time.
|
|
|
|
///
|
|
|
|
/// A custom date/time format string can be set in the config.
|
|
|
|
///
|
|
|
|
/// Clicking the widget opens a popup containing the current time
|
|
|
|
/// with second-level precision and a calendar.
|
|
|
|
pub mod clock;
|
2022-08-14 20:40:11 +01:00
|
|
|
pub mod focused;
|
2022-08-14 14:30:13 +01:00
|
|
|
pub mod launcher;
|
|
|
|
pub mod mpd;
|
|
|
|
pub mod script;
|
|
|
|
pub mod sysinfo;
|
|
|
|
pub mod tray;
|
|
|
|
pub mod workspaces;
|
|
|
|
|
2022-08-14 20:40:11 +01:00
|
|
|
use crate::config::BarPosition;
|
2022-08-21 23:36:07 +01:00
|
|
|
use color_eyre::Result;
|
2022-08-14 14:30:13 +01:00
|
|
|
/// Shamelessly stolen from here:
|
|
|
|
/// <https://github.com/zeroeightysix/rustbar/blob/master/src/modules/module.rs>
|
|
|
|
use glib::IsA;
|
2022-08-15 21:11:00 +01:00
|
|
|
use gtk::gdk::Monitor;
|
2022-08-14 14:30:13 +01:00
|
|
|
use gtk::{Application, Widget};
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
pub enum ModuleLocation {
|
|
|
|
Left,
|
|
|
|
Center,
|
|
|
|
Right,
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct ModuleInfo<'a> {
|
|
|
|
pub app: &'a Application,
|
|
|
|
pub location: ModuleLocation,
|
2022-08-14 16:23:41 +01:00
|
|
|
pub bar_position: &'a BarPosition,
|
2022-08-15 21:11:00 +01:00
|
|
|
pub monitor: &'a Monitor,
|
2022-08-14 20:40:11 +01:00
|
|
|
pub output_name: &'a str,
|
2022-08-14 14:30:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
pub trait Module<W>
|
|
|
|
where
|
|
|
|
W: IsA<Widget>,
|
|
|
|
{
|
|
|
|
/// Consumes the module config
|
|
|
|
/// and produces a GTK widget of type `W`
|
2022-08-21 23:36:07 +01:00
|
|
|
fn into_widget(self, info: &ModuleInfo) -> Result<W>;
|
2022-08-14 14:30:13 +01:00
|
|
|
}
|