Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

gpui: Update asset paths for more examples (#24646)

Marshall Bowers7b45901d96fa
diff --git a/crates/gpui/examples/gif_viewer.rs b/crates/gpui/examples/gif_viewer.rs
index bdec02d26bb..79e618fa558 100644
--- a/crates/gpui/examples/gif_viewer.rs
+++ b/crates/gpui/examples/gif_viewer.rs
@@ -25,15 +25,8 @@ impl Render for GifViewer {
fn main() {
env_logger::init();
Application::new().run(|cx: &mut App| {
- let cwd = std::env::current_dir().expect("Failed to get current working directory");
- let gif_path = cwd.join("crates/gpui/examples/image/black-cat-typing.gif");
-
- if !gif_path.exists() {
- eprintln!("Image file not found at {:?}", gif_path);
- eprintln!("Make sure you're running this example from the root of the gpui crate");
- cx.quit();
- return;
- }
+ let gif_path =
+ PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("examples/image/black-cat-typing.gif");
cx.open_window(
WindowOptions {
diff --git a/crates/gpui/examples/image_loading.rs b/crates/gpui/examples/image_loading.rs
index f211c10c5e2..5aeed16342d 100644
--- a/crates/gpui/examples/image_loading.rs
+++ b/crates/gpui/examples/image_loading.rs
@@ -29,7 +29,7 @@ impl AssetSource for Assets {
}
}
-const IMAGE: &str = "examples/image/app-icon.png";
+const IMAGE: &str = concat!(env!("CARGO_MANIFEST_DIR"), "/examples/image/app-icon.png");
#[derive(Copy, Clone, Hash)]
struct LoadImageParameters {
diff --git a/crates/gpui/examples/opacity.rs b/crates/gpui/examples/opacity.rs
index 4f8764497fc..43c8950f375 100644
--- a/crates/gpui/examples/opacity.rs
+++ b/crates/gpui/examples/opacity.rs
@@ -159,7 +159,7 @@ impl Render for HelloWorld {
fn main() {
Application::new()
.with_assets(Assets {
- base: PathBuf::from("crates/gpui/examples"),
+ base: PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("examples"),
})
.run(|cx: &mut App| {
let bounds = Bounds::centered(None, size(px(500.0), px(500.0)), cx);
@@ -171,5 +171,6 @@ fn main() {
|window, cx| cx.new(|cx| HelloWorld::new(window, cx)),
)
.unwrap();
+ cx.activate(true);
});
}
diff --git a/crates/gpui/examples/svg/svg.rs b/crates/gpui/examples/svg/svg.rs
index 5c583717e3f..62ce04e1ce9 100644
--- a/crates/gpui/examples/svg/svg.rs
+++ b/crates/gpui/examples/svg/svg.rs
@@ -70,7 +70,7 @@ impl Render for SvgExample {
fn main() {
Application::new()
.with_assets(Assets {
- base: PathBuf::from("crates/gpui/examples"),
+ base: PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("examples"),
})
.run(|cx: &mut App| {
let bounds = Bounds::centered(None, size(px(300.0), px(300.0)), cx);
@@ -82,5 +82,6 @@ fn main() {
|_, cx| cx.new(|_| SvgExample),
)
.unwrap();
+ cx.activate(true);
});
}