diff --git a/Cargo.lock b/Cargo.lock index b9a5a42b80..84971180f6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5546,6 +5546,7 @@ dependencies = [ "rand 0.8.5", "raw-window-handle", "refineable", + "reqwest_client", "resvg", "schemars", "seahash", diff --git a/crates/gpui/Cargo.toml b/crates/gpui/Cargo.toml index 5c692860c9..5795f68c30 100644 --- a/crates/gpui/Cargo.toml +++ b/crates/gpui/Cargo.toml @@ -202,11 +202,12 @@ windows-core = "0.58" backtrace = "0.3" collections = { workspace = true, features = ["test-support"] } env_logger.workspace = true -rand.workspace = true -util = { workspace = true, features = ["test-support"] } http_client = { workspace = true, features = ["test-support"] } -unicode-segmentation.workspace = true lyon = { version = "1.0", features = ["extra"] } +rand.workspace = true +unicode-segmentation.workspace = true +reqwest_client = { workspace = true, features = ["test-support"] } +util = { workspace = true, features = ["test-support"] } [target.'cfg(target_os = "windows")'.build-dependencies] embed-resource = "3.0" diff --git a/crates/gpui/examples/image/image.rs b/crates/gpui/examples/image/image.rs index 56a188832b..28ef606556 100644 --- a/crates/gpui/examples/image/image.rs +++ b/crates/gpui/examples/image/image.rs @@ -1,6 +1,5 @@ use std::fs; use std::path::PathBuf; -use std::str::FromStr; use std::sync::Arc; use anyhow::Result; @@ -9,6 +8,7 @@ use gpui::{ Bounds, Context, ImageSource, KeyBinding, Menu, MenuItem, Point, SharedString, SharedUri, TitlebarOptions, Window, WindowBounds, WindowOptions, }; +use reqwest_client::ReqwestClient; struct Assets { base: PathBuf, @@ -127,11 +127,16 @@ actions!(image, [Quit]); fn main() { env_logger::init(); + let manifest_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); + Application::new() .with_assets(Assets { - base: PathBuf::from("crates/gpui/examples"), + base: manifest_dir.join("examples"), }) - .run(|cx: &mut App| { + .run(move |cx: &mut App| { + let http_client = ReqwestClient::user_agent("gpui example").unwrap(); + cx.set_http_client(Arc::new(http_client)); + cx.activate(true); cx.on_action(|_: &Quit, cx| cx.quit()); cx.bind_keys([KeyBinding::new("cmd-q", Quit, None)]); @@ -158,9 +163,7 @@ fn main() { cx.open_window(window_options, |_, cx| { cx.new(|_| ImageShowcase { // Relative path to your root project path - local_resource: PathBuf::from_str("crates/gpui/examples/image/app-icon.png") - .unwrap() - .into(), + local_resource: manifest_dir.join("examples/image/app-icon.png").into(), remote_resource: "https://picsum.photos/512/512".into(),