Skip to main content

origin_tauri/
config.rs

1/// Host-level product configuration.
2///
3/// In Phase 4 this is generated from the app manifest (ADR-0011); until then products
4/// construct it by hand.
5#[derive(Debug, Clone)]
6pub struct HostConfig {
7    /// Reverse-DNS product id, e.g. `dev.origin.demo`. Also scopes credentials in the
8    /// system keychain, so two Origin apps cannot read each other's tokens.
9    pub app_id: String,
10    pub tray: bool,
11    pub tray_tooltip: String,
12    /// Closing the last window hides the app instead of quitting it.
13    pub close_to_tray: bool,
14    pub single_instance: bool,
15    pub window_state: bool,
16}
17
18impl HostConfig {
19    pub fn new(app_id: impl Into<String>) -> Self {
20        let app_id = app_id.into();
21        Self {
22            tray_tooltip: app_id.clone(),
23            app_id,
24            tray: false,
25            close_to_tray: false,
26            single_instance: true,
27            window_state: true,
28        }
29    }
30
31    pub fn with_tray(mut self, tooltip: impl Into<String>) -> Self {
32        self.tray = true;
33        self.tray_tooltip = tooltip.into();
34        self
35    }
36
37    pub fn with_close_to_tray(mut self, close_to_tray: bool) -> Self {
38        self.close_to_tray = close_to_tray;
39        self
40    }
41}