title_bar_settings.rs

 1use db::anyhow;
 2use schemars::JsonSchema;
 3use serde::{Deserialize, Serialize};
 4use settings::{Settings, SettingsContent, 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, 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
26impl Settings for TitleBarSettings {
27    fn from_defaults(s: &SettingsContent) -> Option<Self> {
28        let content = s.title_bar?;
29        TitleBarSettings {
30            show: content.show?,
31            show_branch_icon: content.show_branch_icon?,
32            show_onboarding_banner: content.show_onboarding_banner?,
33            show_user_picture: content.show_user_picture?,
34            show_branch_name: content.show_branch_name?,
35            show_project_items: content.show_project_items?,
36            show_sign_in: content.show_sign_in?,
37            show_menus: content.show_menus?,
38        }
39    }
40
41    fn refine(&mut self, s: &SettingsContent, _: &mut App) {
42        let Some(content) = s.title_bar else {
43            return
44        }
45
46        self.show.refine(&content.show);
47        self.show_branch_icon.refine(content.show_branch_icon);
48        self.show_onboarding_banner.refine(content.show_onboarding_banner);
49        self.show_user_picture.refine(content.show_user_picture);
50        self.show_branch_name.refine(content.show_branch_name);
51        self.show_project_items.refine(content.show_project_items);
52        self.show_sign_in.refine(content.show_sign_in);
53        self.show_menus.refine(content.show_menus);
54    }
55
56    fn import_from_vscode(_: &settings::VsCodeSettings, _: &mut Self::FileContent) {}
57}