1pub use settings::TitleBarVisibility;
2use settings::{Settings, SettingsContent};
3use ui::App;
4use util::MergeFrom;
5
6#[derive(Copy, Clone, Debug)]
7pub struct TitleBarSettings {
8 pub show: TitleBarVisibility,
9 pub show_branch_icon: bool,
10 pub show_onboarding_banner: bool,
11 pub show_user_picture: bool,
12 pub show_branch_name: bool,
13 pub show_project_items: bool,
14 pub show_sign_in: bool,
15 pub show_menus: bool,
16}
17
18impl Settings for TitleBarSettings {
19 fn from_defaults(s: &SettingsContent, _: &mut App) -> Self {
20 let content = s.title_bar.clone().unwrap();
21 TitleBarSettings {
22 show: content.show.unwrap(),
23 show_branch_icon: content.show_branch_icon.unwrap(),
24 show_onboarding_banner: content.show_onboarding_banner.unwrap(),
25 show_user_picture: content.show_user_picture.unwrap(),
26 show_branch_name: content.show_branch_name.unwrap(),
27 show_project_items: content.show_project_items.unwrap(),
28 show_sign_in: content.show_sign_in.unwrap(),
29 show_menus: content.show_menus.unwrap(),
30 }
31 }
32
33 fn refine(&mut self, s: &SettingsContent, _: &mut App) {
34 let Some(content) = &s.title_bar else {
35 return;
36 };
37
38 self.show.merge_from(&content.show);
39 self.show_branch_icon.merge_from(&content.show_branch_icon);
40 self.show_onboarding_banner
41 .merge_from(&content.show_onboarding_banner);
42 self.show_user_picture
43 .merge_from(&content.show_user_picture);
44 self.show_branch_name.merge_from(&content.show_branch_name);
45 self.show_project_items
46 .merge_from(&content.show_project_items);
47 self.show_sign_in.merge_from(&content.show_sign_in);
48 self.show_menus.merge_from(&content.show_menus);
49 }
50
51 fn import_from_vscode(_: &settings::VsCodeSettings, _: &mut SettingsContent) {}
52}