Restore welcome page and several pickers
This commit is contained in:
parent
d927c2f497
commit
ed8e62cd18
4 changed files with 63 additions and 69 deletions
|
@ -41,8 +41,7 @@ impl FileAssociations {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_icon(path: &Path, cx: &AppContext) -> Arc<str> {
|
pub fn get_icon(path: &Path, cx: &AppContext) -> Option<Arc<str>> {
|
||||||
maybe!({
|
|
||||||
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
|
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
|
||||||
|
|
||||||
// FIXME: Associate a type with the languages and have the file's langauge
|
// FIXME: Associate a type with the languages and have the file's langauge
|
||||||
|
@ -56,12 +55,9 @@ impl FileAssociations {
|
||||||
.map(|type_config| type_config.icon.clone())
|
.map(|type_config| type_config.icon.clone())
|
||||||
})
|
})
|
||||||
.or_else(|| this.types.get("default").map(|config| config.icon.clone()))
|
.or_else(|| this.types.get("default").map(|config| config.icon.clone()))
|
||||||
})
|
|
||||||
.unwrap_or_else(|| Arc::from("".to_string()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Arc<str> {
|
pub fn get_folder_icon(expanded: bool, cx: &AppContext) -> Option<Arc<str>> {
|
||||||
maybe!({
|
|
||||||
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
|
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
|
||||||
|
|
||||||
let key = if expanded {
|
let key = if expanded {
|
||||||
|
@ -73,12 +69,9 @@ impl FileAssociations {
|
||||||
this.types
|
this.types
|
||||||
.get(key)
|
.get(key)
|
||||||
.map(|type_config| type_config.icon.clone())
|
.map(|type_config| type_config.icon.clone())
|
||||||
})
|
|
||||||
.unwrap_or_else(|| Arc::from("".to_string()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Arc<str> {
|
pub fn get_chevron_icon(expanded: bool, cx: &AppContext) -> Option<Arc<str>> {
|
||||||
maybe!({
|
|
||||||
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
|
let this = cx.has_global::<Self>().then(|| cx.global::<Self>())?;
|
||||||
|
|
||||||
let key = if expanded {
|
let key = if expanded {
|
||||||
|
@ -90,7 +83,5 @@ impl FileAssociations {
|
||||||
this.types
|
this.types
|
||||||
.get(key)
|
.get(key)
|
||||||
.map(|type_config| type_config.icon.clone())
|
.map(|type_config| type_config.icon.clone())
|
||||||
})
|
|
||||||
.unwrap_or_else(|| Arc::from("".to_string()))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1269,16 +1269,16 @@ impl ProjectPanel {
|
||||||
let icon = match entry.kind {
|
let icon = match entry.kind {
|
||||||
EntryKind::File(_) => {
|
EntryKind::File(_) => {
|
||||||
if show_file_icons {
|
if show_file_icons {
|
||||||
Some(FileAssociations::get_icon(&entry.path, cx))
|
FileAssociations::get_icon(&entry.path, cx)
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => {
|
_ => {
|
||||||
if show_folder_icons {
|
if show_folder_icons {
|
||||||
Some(FileAssociations::get_folder_icon(is_expanded, cx))
|
FileAssociations::get_folder_icon(is_expanded, cx)
|
||||||
} else {
|
} else {
|
||||||
Some(FileAssociations::get_chevron_icon(is_expanded, cx))
|
FileAssociations::get_chevron_icon(is_expanded, cx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -58,6 +58,7 @@ impl Render for WelcomePage {
|
||||||
type Element = Focusable<Div>;
|
type Element = Focusable<Div>;
|
||||||
|
|
||||||
fn render(&mut self, _cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
fn render(&mut self, _cx: &mut gpui::ViewContext<Self>) -> Self::Element {
|
||||||
|
// todo!(welcome_ui)
|
||||||
// let self_handle = cx.handle();
|
// let self_handle = cx.handle();
|
||||||
// let theme = cx.theme();
|
// let theme = cx.theme();
|
||||||
// let width = theme.welcome.page_width;
|
// let width = theme.welcome.page_width;
|
||||||
|
|
|
@ -166,7 +166,7 @@ fn main() {
|
||||||
|
|
||||||
// cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))
|
// cx.spawn(|_| watch_languages(fs.clone(), languages.clone()))
|
||||||
// .detach();
|
// .detach();
|
||||||
// watch_file_types(fs.clone(), cx);
|
watch_file_types(fs.clone(), cx);
|
||||||
|
|
||||||
languages.set_theme(cx.theme().clone());
|
languages.set_theme(cx.theme().clone());
|
||||||
cx.observe_global::<SettingsStore>({
|
cx.observe_global::<SettingsStore>({
|
||||||
|
@ -722,31 +722,33 @@ async fn watch_languages(fs: Arc<dyn fs::Fs>, languages: Arc<LanguageRegistry>)
|
||||||
Some(())
|
Some(())
|
||||||
}
|
}
|
||||||
|
|
||||||
//todo!()
|
#[cfg(debug_assertions)]
|
||||||
// #[cfg(debug_assertions)]
|
fn watch_file_types(fs: Arc<dyn fs::Fs>, cx: &mut AppContext) {
|
||||||
// fn watch_file_types(fs: Arc<dyn Fs>, cx: &mut AppContext) {
|
use std::time::Duration;
|
||||||
// cx.spawn(|mut cx| async move {
|
|
||||||
// let mut events = fs
|
cx.spawn(|mut cx| async move {
|
||||||
// .watch(
|
let mut events = fs
|
||||||
// "assets/icons/file_icons/file_types.json".as_ref(),
|
.watch(
|
||||||
// Duration::from_millis(100),
|
"assets/icons/file_icons/file_types.json".as_ref(),
|
||||||
// )
|
Duration::from_millis(100),
|
||||||
// .await;
|
)
|
||||||
// while (events.next().await).is_some() {
|
.await;
|
||||||
// cx.update(|cx| {
|
while (events.next().await).is_some() {
|
||||||
// cx.update_global(|file_types, _| {
|
cx.update(|cx| {
|
||||||
// *file_types = project_panel::file_associations::FileAssociations::new(Assets);
|
cx.update_global(|file_types, _| {
|
||||||
// });
|
*file_types = project_panel::file_associations::FileAssociations::new(Assets);
|
||||||
// })
|
});
|
||||||
// }
|
})
|
||||||
// })
|
.ok();
|
||||||
// .detach()
|
}
|
||||||
// }
|
})
|
||||||
|
.detach()
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {
|
async fn watch_languages(_: Arc<dyn Fs>, _: Arc<LanguageRegistry>) -> Option<()> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
// #[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
// fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}
|
fn watch_file_types(_fs: Arc<dyn Fs>, _cx: &mut AppContext) {}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue