mirror of
https://github.com/tauri-apps/tauri.git
synced 2026-02-06 13:57:16 +00:00
feat: expose internal TrayIcon (#13959)
This commit is contained in:
parent
0c402bfb6b
commit
f1232671ab
8
.changes/expose-inner-tray-icon.md
Normal file
8
.changes/expose-inner-tray-icon.md
Normal file
@ -0,0 +1,8 @@
|
||||
---
|
||||
"tauri": 'minor:enhance'
|
||||
---
|
||||
|
||||
Introduce `with_inner_tray_icon` for Tauri `TrayIcon` to access the inner platform-specific tray icon.
|
||||
|
||||
Note that `tray-icon` crate may be updated in minor releases of Tauri.
|
||||
Therefore, it’s recommended to pin Tauri to at least a minor version when you’re using `with_inner_tray_icon`.
|
||||
@ -603,6 +603,18 @@ impl<R: Runtime> TrayIcon<R> {
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Do something with the inner [`tray_icon::TrayIcon`] on main thread
|
||||
///
|
||||
/// Note that `tray-icon` crate may be updated in minor releases of Tauri.
|
||||
/// Therefore, it’s recommended to pin Tauri to at least a minor version when you’re using `with_inner_tray_icon`.
|
||||
pub fn with_inner_tray_icon<F, T>(&self, f: F) -> crate::Result<T>
|
||||
where
|
||||
F: FnOnce(&tray_icon::TrayIcon) -> T + Send + 'static,
|
||||
T: Send + 'static,
|
||||
{
|
||||
run_item_main_thread!(self, |self_: Self| { f(&self_.inner) })
|
||||
}
|
||||
}
|
||||
|
||||
impl<R: Runtime> Resource for TrayIcon<R> {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user