tauri_plugin_single_window/
config.rs1#[derive(Clone, Default)]
2pub struct Config {
3 pub duplicate_notice: Option<String>,
4 pub target_window_label: Option<String>,
5 pub(crate) activation_callback: Option<std::sync::Arc<dyn std::any::Any + Send + Sync>>,
6}
7
8impl Config {
9 pub fn new() -> Self {
10 Self {
11 duplicate_notice: None,
12 target_window_label: None,
13 activation_callback: None,
14 }
15 }
16
17 pub fn with_duplicate_notice<S: Into<String>>(mut self, duplicate_notice: S) -> Self {
18 self.duplicate_notice = Some(duplicate_notice.into());
19 self
20 }
21
22 pub fn with_target_window<S: Into<String>>(mut self, target_window_label: S) -> Self {
23 self.target_window_label = Some(target_window_label.into());
24 self
25 }
26
27 pub fn on_activate<R, F>(mut self, callback: F) -> Self
28 where
29 R: tauri::Runtime,
30 F: Fn(tauri::AppHandle<R>, crate::ActivationPayload) + Send + Sync + 'static,
31 {
32 let callback: crate::ActivationCallback<R> = std::sync::Arc::new(callback);
33 self.activation_callback = Some(std::sync::Arc::new(callback));
34 self
35 }
36}