use super::diff::{Diff, MenuItemDiff}; use crate::{spawn, try_send}; use glib::Propagation; use gtk::prelude::*; use gtk::{CheckMenuItem, Image, Label, Menu, MenuItem, SeparatorMenuItem}; use std::collections::HashMap; use system_tray::client::ActivateRequest; use system_tray::item::{IconPixmap, StatusNotifierItem}; use system_tray::menu::{MenuItem as MenuItemInfo, MenuType, ToggleState, ToggleType}; use tokio::sync::mpsc; /// Calls a method on the underlying widget, /// passing in a single argument. /// /// This is useful to avoid matching on /// `TrayMenuWidget` constantly. /// /// # Example /// ```rust /// call!(container, add, my_widget) /// ``` /// is the same as: /// ``` /// match &my_widget { /// TrayMenuWidget::Separator(w) => { /// container.add(w); /// } /// TrayMenuWidget::Standard(w) => { /// container.add(w); /// } /// TrayMenuWidget::Checkbox(w) => { /// container.add(w); /// } /// } /// ``` macro_rules! call { ($parent:expr, $method:ident, $child:expr) => { match &$child { TrayMenuWidget::Separator(w) => { $parent.$method(w); } TrayMenuWidget::Standard(w) => { $parent.$method(w); } TrayMenuWidget::Checkbox(w) => { $parent.$method(w); } } }; } /// Main tray icon to show on the bar pub(crate) struct TrayMenu { pub widget: MenuItem, menu_widget: Menu, image_widget: Option, label_widget: Option