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