use std::sync::{Arc, RwLock}; use color_eyre::Result; use glib::IsA; use gtk::gdk::{EventMask, Monitor}; use gtk::prelude::*; use gtk::{Application, Button, EventBox, IconTheme, Orientation, Revealer, Widget}; use tokio::sync::mpsc; use tracing::debug; use crate::bridge_channel::BridgeChannel; use crate::config::{BarPosition, CommonConfig, TransitionType}; use crate::gtk_helpers::{IronbarGtkExt, WidgetGeometry}; use crate::popup::Popup; use crate::{send, write_lock}; #[cfg(feature = "clipboard")] pub mod clipboard; /// 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. #[cfg(feature = "clock")] pub mod clock; pub mod custom; pub mod focused; pub mod label; pub mod launcher; #[cfg(feature = "music")] pub mod music; pub mod script; #[cfg(feature = "sys_info")] pub mod sysinfo; #[cfg(feature = "tray")] pub mod tray; #[cfg(feature = "upower")] pub mod upower; #[cfg(feature = "workspaces")] pub mod workspaces; #[derive(Clone)] pub enum ModuleLocation { Left, Center, Right, } pub struct ModuleInfo<'a> { pub app: &'a Application, pub location: ModuleLocation, pub bar_position: BarPosition, pub monitor: &'a Monitor, pub output_name: &'a str, pub icon_theme: &'a IconTheme, } #[derive(Debug)] pub enum ModuleUpdateEvent { /// Sends an update to the module UI. Update(T), /// Toggles the open state of the popup. /// Takes the button ID. TogglePopup(usize), /// Force sets the popup open. /// Takes the button ID. OpenPopup(usize), OpenPopupAt(WidgetGeometry), /// Force sets the popup closed. ClosePopup, } pub struct WidgetContext { pub id: usize, pub tx: mpsc::Sender>, pub controller_tx: mpsc::Sender, pub widget_rx: glib::Receiver, pub popup_rx: glib::Receiver, } pub struct ModuleParts> { pub widget: W, pub popup: Option, } impl> ModuleParts { fn new(widget: W, popup: Option) -> Self { Self { widget, popup } } } #[derive(Debug, Clone)] pub struct ModulePopupParts { /// The popup container, with all its contents pub container: gtk::Box, /// An array of buttons which can be used for opening the popup. /// For most modules, this will only be a single button. /// For some advanced modules, such as `Launcher`, this is all item buttons. pub buttons: Vec