title_bar_settings.rs

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