pub struct TrayIcon {
pub tooltip: String,
pub icon_rgba: Vec<u8>,
pub icon_width: u32,
pub icon_height: u32,
pub menu: Option<TrayMenu>,
pub visible: bool,
pub click_count: usize,
pub last_action_id: Option<u64>,
pub badge: Option<String>,
}Expand description
System tray icon abstraction.
Fields§
§tooltip: String§icon_rgba: Vec<u8>§icon_width: u32§icon_height: u32§visible: bool§click_count: usize§last_action_id: Option<u64>§badge: Option<String>Implementations§
Source§impl TrayIcon
impl TrayIcon
Sourcepub fn new(
tooltip: impl Into<String>,
icon_rgba: Vec<u8>,
icon_width: u32,
icon_height: u32,
) -> Self
pub fn new( tooltip: impl Into<String>, icon_rgba: Vec<u8>, icon_width: u32, icon_height: u32, ) -> Self
Creates a new system tray icon.
Sourcepub fn set_badge(&mut self, badge: Option<String>)
pub fn set_badge(&mut self, badge: Option<String>)
Sets the notification badge text (e.g. “99+” or “NEW”).
Sourcepub fn set_badge_count(&mut self, count: Option<u32>)
pub fn set_badge_count(&mut self, count: Option<u32>)
Sets the notification badge as a numeric count (or clears it if None or 0).
Sourcepub fn set_tooltip(&mut self, tooltip: impl Into<String>)
pub fn set_tooltip(&mut self, tooltip: impl Into<String>)
Sets the hover tooltip text.
Sets or clears the tray context menu.
Sourcepub fn set_visible(&mut self, visible: bool)
pub fn set_visible(&mut self, visible: bool)
Sets whether the icon is visible in the status bar/system tray.
Sourcepub fn trigger_click(&mut self)
pub fn trigger_click(&mut self)
Simulates or executes a primary click on the tray icon.
Simulates or executes a menu item action by ID. Returns true if the item was found and enabled.
Sourcepub fn spawn_native<F>(self, event_sink: F) -> NativeTrayHandle
pub fn spawn_native<F>(self, event_sink: F) -> NativeTrayHandle
Spawns an OS-native system tray handle dispatching events through the provided event callback.
On Linux the native indicator is created immediately when this is called
on the GTK main thread after gtk::init(). Callers on any other thread,
and callers where the Ayatana AppIndicator library is absent, receive a
handle-only controller that still dispatches events from the in-process
model.
Sourcepub fn spawn_handle_only<F>(self, event_sink: F) -> NativeTrayHandle
pub fn spawn_handle_only<F>(self, event_sink: F) -> NativeTrayHandle
Spawns a deterministic in-process tray controller (backend_name() == "handle-only")
without attempting OS tray registration.