title_bar_settings.rs

 1use db::anyhow;
 2use schemars::JsonSchema;
 3use serde::{Deserialize, Serialize};
 4use settings::{Settings, SettingsSources};
 5use util::serde::default_true;
 6
 7#[derive(Deserialize, Debug, Clone, Copy, PartialEq)]
 8pub struct TitleBarSettings {
 9    #[serde(default)]
10    pub show_branch_icon: bool,
11    #[serde(default = "default_true")]
12    pub show_branch_name: bool,
13    #[serde(default = "default_true")]
14    pub show_project_items: bool,
15    #[serde(default = "default_true")]
16    pub show_onboarding_banner: bool,
17    #[serde(default = "default_true")]
18    pub show_user_picture: bool,
19}
20
21#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)]
22pub struct TitleBarSettingsContent {
23    /// Whether to show the branch icon beside branch switcher in the title bar.
24    ///
25    /// Default: false
26    pub show_branch_icon: Option<bool>,
27    /// Whether to show onboarding banners in the title bar.
28    ///
29    /// Default: true
30    pub show_onboarding_banner: Option<bool>,
31    /// Whether to show user avatar in the title bar.
32    ///
33    /// Default: true
34    pub show_user_picture: Option<bool>,
35    /// Whether to show the branch name button in the titlebar.
36    ///
37    /// Default: true
38    pub show_branch_name: Option<bool>,
39    /// Whether to show the project host and name in the titlebar.
40    ///
41    /// Default: true
42    pub show_project_items: Option<bool>,
43}
44
45impl Settings for TitleBarSettings {
46    const KEY: Option<&'static str> = Some("title_bar");
47
48    type FileContent = TitleBarSettingsContent;
49
50    fn load(sources: SettingsSources<Self::FileContent>, _: &mut gpui::App) -> anyhow::Result<Self>
51    where
52        Self: Sized,
53    {
54        sources.json_merge()
55    }
56
57    fn import_from_vscode(_: &settings::VsCodeSettings, _: &mut Self::FileContent) {}
58}