From 574b943081c1645c0c0f2eed57f99d24e113d353 Mon Sep 17 00:00:00 2001 From: localcc Date: Wed, 17 Sep 2025 12:47:09 +0200 Subject: [PATCH] Add wsl specific icon (#38316) Release Notes: - N/A --- assets/icons/linux.svg | 11 +++++++++ crates/icons/src/icons.rs | 1 + crates/recent_projects/src/recent_projects.rs | 11 +++++---- .../recent_projects/src/remote_connections.rs | 24 ++++++++++++++----- crates/recent_projects/src/remote_servers.rs | 16 +++++++++++-- crates/title_bar/src/title_bar.rs | 13 +++++----- 6 files changed, 57 insertions(+), 19 deletions(-) create mode 100644 assets/icons/linux.svg diff --git a/assets/icons/linux.svg b/assets/icons/linux.svg new file mode 100644 index 0000000000000000000000000000000000000000..fc76742a3f236650cb8c514c8263ec2c3b2d4521 --- /dev/null +++ b/assets/icons/linux.svg @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/crates/icons/src/icons.rs b/crates/icons/src/icons.rs index f3609f7ea8706f33eb07eaaf456731e14c85555a..0f05e58c27c48c37043fe90f64b4f03968b22752 100644 --- a/crates/icons/src/icons.rs +++ b/crates/icons/src/icons.rs @@ -263,6 +263,7 @@ pub enum IconName { ZedPredictError, ZedPredictUp, ZedXCopilot, + Linux, } impl IconName { diff --git a/crates/recent_projects/src/recent_projects.rs b/crates/recent_projects/src/recent_projects.rs index aa0ce7661b29123c25fdf20cbde5f53e6525d2d6..2fc57a52fcb55f62b213cd7bb842009384b6ec91 100644 --- a/crates/recent_projects/src/recent_projects.rs +++ b/crates/recent_projects/src/recent_projects.rs @@ -417,10 +417,13 @@ impl PickerDelegate for RecentProjectsDelegate { SerializedWorkspaceLocation::Local => Icon::new(IconName::Screen) .color(Color::Muted) .into_any_element(), - SerializedWorkspaceLocation::Remote(_) => { - Icon::new(IconName::Server) - .color(Color::Muted) - .into_any_element() + SerializedWorkspaceLocation::Remote(options) => { + Icon::new(match options { + RemoteConnectionOptions::Ssh { .. } => IconName::Server, + RemoteConnectionOptions::Wsl { .. } => IconName::Linux, + }) + .color(Color::Muted) + .into_any_element() } }) }) diff --git a/crates/recent_projects/src/remote_connections.rs b/crates/recent_projects/src/remote_connections.rs index 72e2844d501f8f8860d62964d22430af80bab4b6..8b47cbfc0f031f6f7013d9f105dd496223a67cec 100644 --- a/crates/recent_projects/src/remote_connections.rs +++ b/crates/recent_projects/src/remote_connections.rs @@ -192,6 +192,7 @@ impl Settings for SshSettings { pub struct RemoteConnectionPrompt { connection_string: SharedString, nickname: Option, + is_wsl: bool, status_message: Option, prompt: Option<(Entity, oneshot::Sender)>, cancellation: Option>, @@ -216,12 +217,14 @@ impl RemoteConnectionPrompt { pub(crate) fn new( connection_string: String, nickname: Option, + is_wsl: bool, window: &mut Window, cx: &mut Context, ) -> Self { Self { connection_string: connection_string.into(), nickname: nickname.map(|nickname| nickname.into()), + is_wsl, editor: cx.new(|cx| Editor::single_line(window, cx)), status_message: None, cancellation: None, @@ -350,15 +353,16 @@ impl RemoteConnectionModal { window: &mut Window, cx: &mut Context, ) -> Self { - let (connection_string, nickname) = match connection_options { + let (connection_string, nickname, is_wsl) = match connection_options { RemoteConnectionOptions::Ssh(options) => { - (options.connection_string(), options.nickname.clone()) + (options.connection_string(), options.nickname.clone(), false) } - RemoteConnectionOptions::Wsl(options) => (options.distro_name.clone(), None), + RemoteConnectionOptions::Wsl(options) => (options.distro_name.clone(), None, true), }; Self { - prompt: cx - .new(|cx| RemoteConnectionPrompt::new(connection_string, nickname, window, cx)), + prompt: cx.new(|cx| { + RemoteConnectionPrompt::new(connection_string, nickname, is_wsl, window, cx) + }), finished: false, paths, } @@ -389,6 +393,7 @@ pub(crate) struct SshConnectionHeader { pub(crate) connection_string: SharedString, pub(crate) paths: Vec, pub(crate) nickname: Option, + pub(crate) is_wsl: bool, } impl RenderOnce for SshConnectionHeader { @@ -404,6 +409,11 @@ impl RenderOnce for SshConnectionHeader { (self.connection_string, None) }; + let icon = match self.is_wsl { + true => IconName::Linux, + false => IconName::Server, + }; + h_flex() .px(DynamicSpacing::Base12.rems(cx)) .pt(DynamicSpacing::Base08.rems(cx)) @@ -411,7 +421,7 @@ impl RenderOnce for SshConnectionHeader { .rounded_t_sm() .w_full() .gap_1p5() - .child(Icon::new(IconName::Server).size(IconSize::Small)) + .child(Icon::new(icon).size(IconSize::Small)) .child( h_flex() .gap_1() @@ -443,6 +453,7 @@ impl Render for RemoteConnectionModal { fn render(&mut self, window: &mut Window, cx: &mut Context) -> impl ui::IntoElement { let nickname = self.prompt.read(cx).nickname.clone(); let connection_string = self.prompt.read(cx).connection_string.clone(); + let is_wsl = self.prompt.read(cx).is_wsl; let theme = cx.theme().clone(); let body_color = theme.colors().editor_background; @@ -461,6 +472,7 @@ impl Render for RemoteConnectionModal { paths: self.paths.clone(), connection_string, nickname, + is_wsl, } .render(window, cx), ) diff --git a/crates/recent_projects/src/remote_servers.rs b/crates/recent_projects/src/remote_servers.rs index d7e7505851a2b0cd2f86c807d6850937096dac7c..1ef9ab671f35dc477d1113e1b924c1272e13de2f 100644 --- a/crates/recent_projects/src/remote_servers.rs +++ b/crates/recent_projects/src/remote_servers.rs @@ -288,7 +288,7 @@ impl picker::PickerDelegate for WslPickerDelegate { h_flex() .flex_grow() .gap_3() - .child(Icon::new(IconName::Server)) + .child(Icon::new(IconName::Linux)) .child(v_flex().child(HighlightedLabel::new( matched.string.clone(), matched.positions.clone(), @@ -483,12 +483,14 @@ impl gpui::Render for ProjectPicker { connection_string: connection_string.clone(), paths: Default::default(), nickname: nickname.clone(), + is_wsl: false, } .render(window, cx), ProjectPickerData::Wsl { distro_name } => SshConnectionHeader { connection_string: distro_name.clone(), paths: Default::default(), nickname: None, + is_wsl: true, } .render(window, cx), }) @@ -799,6 +801,7 @@ impl RemoteServerProjects { RemoteConnectionPrompt::new( connection_options.connection_string(), connection_options.nickname.clone(), + false, window, cx, ) @@ -870,7 +873,13 @@ impl RemoteServerProjects { }; let prompt = cx.new(|cx| { - RemoteConnectionPrompt::new(connection_options.distro_name.clone(), None, window, cx) + RemoteConnectionPrompt::new( + connection_options.distro_name.clone(), + None, + true, + window, + cx, + ) }); let connection = connect( ConnectionIdentifier::setup(), @@ -1644,6 +1653,7 @@ impl RemoteServerProjects { connection_string: connection.host.clone().into(), paths: Default::default(), nickname: connection.nickname.clone().map(|s| s.into()), + is_wsl: false, } .render(window, cx) .into_any_element(), @@ -1651,6 +1661,7 @@ impl RemoteServerProjects { connection_string: connection.distro_name.clone().into(), paths: Default::default(), nickname: None, + is_wsl: true, } .render(window, cx) .into_any_element(), @@ -1988,6 +1999,7 @@ impl RemoteServerProjects { connection_string, paths: Default::default(), nickname, + is_wsl: false, } .render(window, cx), ) diff --git a/crates/title_bar/src/title_bar.rs b/crates/title_bar/src/title_bar.rs index 129b5645641a01ba22d6993621b92a17664f5c8a..9f00b0ffeffe6b9744ffa67a0f52795e31e5737f 100644 --- a/crates/title_bar/src/title_bar.rs +++ b/crates/title_bar/src/title_bar.rs @@ -349,10 +349,11 @@ impl TitleBar { let options = self.project.read(cx).remote_connection_options(cx)?; let host: SharedString = options.display_name().into(); - let nickname = if let RemoteConnectionOptions::Ssh(options) = options { - options.nickname.map(|nick| nick.into()) - } else { - None + let (nickname, icon) = match options { + RemoteConnectionOptions::Ssh(options) => { + (options.nickname.map(|nick| nick.into()), IconName::Server) + } + RemoteConnectionOptions::Wsl(_) => (None, IconName::Linux), }; let nickname = nickname.unwrap_or_else(|| host.clone()); @@ -390,9 +391,7 @@ impl TitleBar { .max_w_32() .child( IconWithIndicator::new( - Icon::new(IconName::Server) - .size(IconSize::Small) - .color(icon_color), + Icon::new(icon).size(IconSize::Small).color(icon_color), Some(Indicator::dot().color(indicator_color)), ) .indicator_border_color(Some(cx.theme().colors().title_bar_background))