Skip to content

Commit c0d03af

Browse files
authored
refactor!: renamed TrayIconBuilder/TrayIcon::on_tray_event to TrayIconBuilder/TrayIcon::on_tray_icon_event (#7943)
1 parent b7fd88e commit c0d03af

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'tauri': 'patch:breaking'
3+
---
4+
5+
Changed `TrayIconBuilder/TrayIcon::on_tray_event` to `TrayIconBuilder/TrayIcon::on_tray_icon_event` for consistency of naming.

core/tauri/src/tray.rs

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl From<tray_icon::TrayIconEvent> for TrayIconEvent {
109109
#[derive(Default)]
110110
pub struct TrayIconBuilder<R: Runtime> {
111111
on_menu_event: Option<GlobalMenuEventListener<AppHandle<R>>>,
112-
on_tray_event: Option<GlobalTrayIconEventListener<TrayIcon<R>>>,
112+
on_tray_icon_event: Option<GlobalTrayIconEventListener<TrayIcon<R>>>,
113113
inner: tray_icon::TrayIconBuilder,
114114
}
115115

@@ -124,7 +124,7 @@ impl<R: Runtime> TrayIconBuilder<R> {
124124
Self {
125125
inner: tray_icon::TrayIconBuilder::new(),
126126
on_menu_event: None,
127-
on_tray_event: None,
127+
on_tray_icon_event: None,
128128
}
129129
}
130130

@@ -223,11 +223,11 @@ impl<R: Runtime> TrayIconBuilder<R> {
223223
}
224224

225225
/// Set a handler for this tray icon events.
226-
pub fn on_tray_event<F: Fn(&TrayIcon<R>, TrayIconEvent) + Sync + Send + 'static>(
226+
pub fn on_tray_icon_event<F: Fn(&TrayIcon<R>, TrayIconEvent) + Sync + Send + 'static>(
227227
mut self,
228228
f: F,
229229
) -> Self {
230-
self.on_tray_event.replace(Box::new(f));
230+
self.on_tray_icon_event.replace(Box::new(f));
231231
self
232232
}
233233

@@ -247,7 +247,11 @@ impl<R: Runtime> TrayIconBuilder<R> {
247247
app_handle: manager.app_handle().clone(),
248248
};
249249

250-
icon.register(&icon.app_handle, self.on_menu_event, self.on_tray_event);
250+
icon.register(
251+
&icon.app_handle,
252+
self.on_menu_event,
253+
self.on_tray_icon_event,
254+
);
251255

252256
Ok(icon)
253257
}
@@ -285,7 +289,7 @@ impl<R: Runtime> TrayIcon<R> {
285289
&self,
286290
app_handle: &AppHandle<R>,
287291
on_menu_event: Option<GlobalMenuEventListener<AppHandle<R>>>,
288-
on_tray_event: Option<GlobalTrayIconEventListener<TrayIcon<R>>>,
292+
on_tray_icon_event: Option<GlobalTrayIconEventListener<TrayIcon<R>>>,
289293
) {
290294
if let Some(handler) = on_menu_event {
291295
app_handle
@@ -297,7 +301,7 @@ impl<R: Runtime> TrayIcon<R> {
297301
.push(handler);
298302
}
299303

300-
if let Some(handler) = on_tray_event {
304+
if let Some(handler) = on_tray_icon_event {
301305
app_handle
302306
.manager
303307
.inner
@@ -337,7 +341,10 @@ impl<R: Runtime> TrayIcon<R> {
337341
}
338342

339343
/// Register a handler for this tray icon events.
340-
pub fn on_tray_event<F: Fn(&TrayIcon<R>, TrayIconEvent) + Sync + Send + 'static>(&self, f: F) {
344+
pub fn on_tray_icon_event<F: Fn(&TrayIcon<R>, TrayIconEvent) + Sync + Send + 'static>(
345+
&self,
346+
f: F,
347+
) {
341348
self
342349
.app_handle
343350
.manager

0 commit comments

Comments
 (0)