#[derive(Clone, Default)]
pub struct Config {
pub duplicate_notice: Option<String>,
pub target_window_label: Option<String>,
pub focus_existing_window: bool,
pub(crate) activation_callback: Option<std::sync::Arc<dyn std::any::Any + Send + Sync>>,
}
impl Config {
pub fn new() -> Self {
Self {
duplicate_notice: None,
target_window_label: None,
focus_existing_window: true,
activation_callback: None,
}
}
pub fn with_duplicate_notice<S: Into<String>>(mut self, duplicate_notice: S) -> Self {
self.duplicate_notice = Some(duplicate_notice.into());
self
}
pub fn with_target_window<S: Into<String>>(mut self, target_window_label: S) -> Self {
self.target_window_label = Some(target_window_label.into());
self
}
pub fn without_window_focus(mut self) -> Self {
self.focus_existing_window = false;
self
}
pub fn on_activate<R, F>(mut self, callback: F) -> Self
where
R: tauri::Runtime,
F: Fn(tauri::AppHandle<R>, crate::ActivationPayload) + Send + Sync + 'static,
{
let callback: crate::ActivationCallback<R> = std::sync::Arc::new(callback);
self.activation_callback = Some(std::sync::Arc::new(callback));
self
}
}