Skip to content

Commit

Permalink
Restore welcome page (#3429)
Browse files Browse the repository at this point in the history
Also restores the theme selector and base keymap selector. This does not
include a UI port.

Release Notes:

- N/A
  • Loading branch information
mikayla-maki authored Nov 29, 2023
2 parents 7677998 + a41c857 commit fbe4402
Show file tree
Hide file tree
Showing 19 changed files with 1,117 additions and 192 deletions.
48 changes: 48 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ members = [
"crates/theme2",
"crates/theme_importer",
"crates/theme_selector",
"crates/theme_selector2",
"crates/ui2",
"crates/util",
"crates/semantic_index",
Expand All @@ -115,6 +116,7 @@ members = [
"crates/vcs_menu",
"crates/workspace2",
"crates/welcome",
"crates/welcome2",
"crates/xtask",
"crates/zed",
"crates/zed2",
Expand Down
8 changes: 4 additions & 4 deletions crates/client2/src/client2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -693,8 +693,8 @@ impl Client {
}
}

pub async fn has_keychain_credentials(&self, cx: &AsyncAppContext) -> bool {
read_credentials_from_keychain(cx).await.is_some()
pub fn has_keychain_credentials(&self, cx: &AsyncAppContext) -> bool {
read_credentials_from_keychain(cx).is_some()
}

#[async_recursion(?Send)]
Expand Down Expand Up @@ -725,7 +725,7 @@ impl Client {
let mut read_from_keychain = false;
let mut credentials = self.state.read().credentials.clone();
if credentials.is_none() && try_keychain {
credentials = read_credentials_from_keychain(cx).await;
credentials = read_credentials_from_keychain(cx);
read_from_keychain = credentials.is_some();
}
if credentials.is_none() {
Expand Down Expand Up @@ -1324,7 +1324,7 @@ impl Client {
}
}

async fn read_credentials_from_keychain(cx: &AsyncAppContext) -> Option<Credentials> {
fn read_credentials_from_keychain(cx: &AsyncAppContext) -> Option<Credentials> {
if IMPERSONATE_LOGIN.is_some() {
return None;
}
Expand Down
10 changes: 6 additions & 4 deletions crates/command_palette2/src/command_palette.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
use std::{
cmp::{self, Reverse},
sync::Arc,
};

use collections::{CommandPaletteFilter, HashMap};
use fuzzy::{StringMatch, StringMatchCandidate};
use gpui::{
actions, Action, AppContext, DismissEvent, Div, EventEmitter, FocusHandle, FocusableView,
Keystroke, ParentElement, Render, Styled, View, ViewContext, VisualContext, WeakView,
};
use picker::{Picker, PickerDelegate};
use std::{
cmp::{self, Reverse},
sync::Arc,
};

use ui::{h_stack, v_stack, HighlightedLabel, KeyBinding, ListItem};
use util::{
channel::{parse_zed_link, ReleaseChannel, RELEASE_CHANNEL},
Expand Down
1 change: 1 addition & 0 deletions crates/gpui2/src/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ macro_rules! actions {

( $name:ident ) => {
#[derive(::std::cmp::PartialEq, ::std::clone::Clone, ::std::default::Default, gpui::serde_derive::Deserialize, gpui::Action)]
#[serde(crate = "gpui::serde")]
pub struct $name;
};

Expand Down
25 changes: 22 additions & 3 deletions crates/picker2/src/picker2.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use editor::Editor;
use gpui::{
div, prelude::*, uniform_list, AppContext, Div, FocusHandle, FocusableView, MouseButton,
MouseDownEvent, Render, Task, UniformListScrollHandle, View, ViewContext, WindowContext,
div, prelude::*, uniform_list, AnyElement, AppContext, Div, FocusHandle, FocusableView,
MouseButton, MouseDownEvent, Render, Task, UniformListScrollHandle, View, ViewContext,
WindowContext,
};
use std::{cmp, sync::Arc};
use ui::{prelude::*, v_stack, Color, Divider, Label};
Expand All @@ -16,7 +17,6 @@ pub struct Picker<D: PickerDelegate> {

pub trait PickerDelegate: Sized + 'static {
type ListItem: IntoElement;

fn match_count(&self) -> usize;
fn selected_index(&self) -> usize;
fn set_selected_index(&mut self, ix: usize, cx: &mut ViewContext<Picker<Self>>);
Expand Down Expand Up @@ -256,3 +256,22 @@ impl<D: PickerDelegate> Render for Picker<D> {
})
}
}

pub fn simple_picker_match(
selected: bool,
cx: &mut WindowContext,
children: impl FnOnce(&mut WindowContext) -> AnyElement,
) -> AnyElement {
let colors = cx.theme().colors();

div()
.px_1()
.text_color(colors.text)
.text_ui()
.bg(colors.ghost_element_background)
.rounded_md()
.when(selected, |this| this.bg(colors.ghost_element_selected))
.hover(|this| this.bg(colors.ghost_element_hover))
.child((children)(cx))
.into_any()
}
71 changes: 31 additions & 40 deletions crates/project_panel2/src/file_associations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,56 +41,47 @@ impl FileAssociations {
})
}

pub fn get_icon(path: &Path, cx: &AppContext) -> Arc<str> {
maybe!({
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
pub fn get_icon(path: &Path, cx: &AppContext) -> Option<Arc<str>> {
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;

// FIXME: Associate a type with the languages and have the file's langauge
// override these associations
maybe!({
let suffix = path.icon_suffix()?;
// FIXME: Associate a type with the languages and have the file's langauge
// override these associations
maybe!({
let suffix = path.icon_suffix()?;

this.suffixes
.get(suffix)
.and_then(|type_str| this.types.get(type_str))
.map(|type_config| type_config.icon.clone())
})
.or_else(|| this.types.get("default").map(|config| config.icon.clone()))
this.suffixes
.get(suffix)
.and_then(|type_str| this.types.get(type_str))
.map(|type_config| type_config.icon.clone())
})
.unwrap_or_else(|| Arc::from("".to_string()))
.or_else(|| this.types.get("default").map(|config| config.icon.clone()))
}

pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Arc<str> {
maybe!({
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Option<Arc<str>> {
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;

let key = if expanded {
EXPANDED_DIRECTORY_TYPE
} else {
COLLAPSED_DIRECTORY_TYPE
};
let key = if expanded {
EXPANDED_DIRECTORY_TYPE
} else {
COLLAPSED_DIRECTORY_TYPE
};

this.types
.get(key)
.map(|type_config| type_config.icon.clone())
})
.unwrap_or_else(|| Arc::from("".to_string()))
this.types
.get(key)
.map(|type_config| type_config.icon.clone())
}

pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Arc<str> {
maybe!({
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Option<Arc<str>> {
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;

let key = if expanded {
EXPANDED_CHEVRON_TYPE
} else {
COLLAPSED_CHEVRON_TYPE
};
let key = if expanded {
EXPANDED_CHEVRON_TYPE
} else {
COLLAPSED_CHEVRON_TYPE
};

this.types
.get(key)
.map(|type_config| type_config.icon.clone())
})
.unwrap_or_else(|| Arc::from("".to_string()))
this.types
.get(key)
.map(|type_config| type_config.icon.clone())
}
}
6 changes: 3 additions & 3 deletions crates/project_panel2/src/project_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,16 +1268,16 @@ impl ProjectPanel {
let icon = match entry.kind {
EntryKind::File(_) => {
if show_file_icons {
Some(FileAssociations::get_icon(&entry.path, cx))
FileAssociations::get_icon(&entry.path, cx)
} else {
None
}
}
_ => {
if show_folder_icons {
Some(FileAssociations::get_folder_icon(is_expanded, cx))
FileAssociations::get_folder_icon(is_expanded, cx)
} else {
Some(FileAssociations::get_chevron_icon(is_expanded, cx))
FileAssociations::get_chevron_icon(is_expanded, cx)
}
}
};
Expand Down
4 changes: 4 additions & 0 deletions crates/theme2/src/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ impl ThemeRegistry {
}));
}

pub fn clear(&mut self) {
self.themes.clear();
}

pub fn list_names(&self, _staff: bool) -> impl Iterator<Item = SharedString> + '_ {
self.themes.keys().cloned()
}
Expand Down
29 changes: 29 additions & 0 deletions crates/theme_selector2/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "theme_selector2"
version = "0.1.0"
edition = "2021"
publish = false

[lib]
path = "src/theme_selector.rs"
doctest = false

[dependencies]
editor = { package = "editor2", path = "../editor2" }
fuzzy = { package = "fuzzy2", path = "../fuzzy2" }
fs = { package = "fs2", path = "../fs2" }
gpui = { package = "gpui2", path = "../gpui2" }
ui = { package = "ui2", path = "../ui2" }
picker = { package = "picker2", path = "../picker2" }
theme = { package = "theme2", path = "../theme2" }
settings = { package = "settings2", path = "../settings2" }
feature_flags = { package = "feature_flags2", path = "../feature_flags2" }
workspace = { package = "workspace2", path = "../workspace2" }
util = { path = "../util" }
log.workspace = true
parking_lot.workspace = true
postage.workspace = true
smol.workspace = true

[dev-dependencies]
editor = { package = "editor2", path = "../editor2", features = ["test-support"] }
Loading

0 comments on commit fbe4402

Please sign in to comment.