diff --git a/assets/settings/default.json b/assets/settings/default.json index d58ddd0ef8..47d0ac45da 100644 --- a/assets/settings/default.json +++ b/assets/settings/default.json @@ -307,6 +307,11 @@ // Whether to show agent review buttons in the editor toolbar. "agent_review": true }, + // Titlebar related settings + "title_bar": { + // Whether to show the branch icon beside branch switcher in the title bar. + "show_branch_icon": false + }, // Scrollbar related settings "scrollbar": { // When to show the scrollbar in the editor. diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 2001db9b8b..b84561292d 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -2,6 +2,7 @@ mod application_menu; mod collab; mod onboarding_banner; mod platforms; +mod title_bar_settings; mod window_controls; #[cfg(feature = "stories")] @@ -31,6 +32,7 @@ use settings::Settings as _; use smallvec::SmallVec; use std::sync::Arc; use theme::ActiveTheme; +use title_bar_settings::TitleBarSettings; use ui::{ Avatar, Button, ButtonLike, ButtonStyle, ContextMenu, Icon, IconName, IconSize, IconWithIndicator, Indicator, PopoverMenu, Tooltip, h_flex, prelude::*, @@ -53,6 +55,8 @@ const BOOK_ONBOARDING: &str = "https://dub.sh/zed-c-onboarding"; actions!(collab, [ToggleUserMenu, ToggleProjectMenu, SwitchBranch]); pub fn init(cx: &mut App) { + TitleBarSettings::register(cx); + cx.observe_new(|workspace: &mut Workspace, window, cx| { let Some(window) = window else { return; @@ -549,7 +553,16 @@ impl TitleBar { let _ = workspace.update(cx, |_this, cx| { window.dispatch_action(zed_actions::git::Branch.boxed_clone(), cx); }); - }), + }) + .when( + TitleBarSettings::get_global(cx).show_branch_icon, + |branch_button| { + branch_button + .icon(IconName::GitBranch) + .icon_position(IconPosition::Start) + .icon_color(Color::Muted) + }, + ), ) } diff --git a/crates/title_bar/src/title_bar_settings.rs b/crates/title_bar/src/title_bar_settings.rs new file mode 100644 index 0000000000..ed7108a96c --- /dev/null +++ b/crates/title_bar/src/title_bar_settings.rs @@ -0,0 +1,32 @@ +use db::anyhow; +use schemars::JsonSchema; +use serde::{Deserialize, Serialize}; +use settings::{Settings, SettingsSources}; + +#[derive(Deserialize, Debug, Clone, Copy, PartialEq)] +pub struct TitleBarSettings { + pub show_branch_icon: bool, +} + +#[derive(Clone, Default, Serialize, Deserialize, JsonSchema, Debug)] +pub struct TitleBarSettingsContent { + /// Whether to show the branch icon beside branch switcher in the title bar. + /// + /// Default: false + pub show_branch_icon: Option, +} + +impl Settings for TitleBarSettings { + const KEY: Option<&'static str> = Some("title_bar"); + + type FileContent = TitleBarSettingsContent; + + fn load(sources: SettingsSources, _: &mut gpui::App) -> anyhow::Result + where + Self: Sized, + { + sources.json_merge() + } + + fn import_from_vscode(_: &settings::VsCodeSettings, _: &mut Self::FileContent) {} +}