diff --git a/crates/gpui/examples/gif_viewer.rs b/crates/gpui/examples/gif_viewer.rs index bdec02d26bbcdba77dc7df10c9f2cff120a4d32c..79e618fa558a8585c458d24024d6518a77f5126f 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 f211c10c5e2b8f0f918ff4da282fca169b072c50..5aeed16342de0e1b820d1c7e68d07e8aa4a6d6e8 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 4f8764497fc61fa53e419431ffdb8a1c7769b168..43c8950f3750bf4224315193d4e870abb4a592c8 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 5c583717e3f870fffdb20dd10c379937ca34cc7b..62ce04e1ce94f632f121bc85a2bf531870ccb4bf 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); }); }