Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
title_bar: Add icon for project branch trigger button (#29494)
Shashank Verma9d97e08e4f03
diff --git a/assets/settings/default.json b/assets/settings/default.jsonindex d58ddd0ef85..47d0ac45da4 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.rsindex 2001db9b8bd..b84561292db 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.rsnew file mode 100644index 00000000000..ed7108a96c9--- /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<bool>,+}++impl Settings for TitleBarSettings {+ const KEY: Option<&'static str> = Some("title_bar");++ type FileContent = TitleBarSettingsContent;++ fn load(sources: SettingsSources<Self::FileContent>, _: &mut gpui::App) -> anyhow::Result<Self>+ where+ Self: Sized,+ {+ sources.json_merge()+ }++ fn import_from_vscode(_: &settings::VsCodeSettings, _: &mut Self::FileContent) {}+}