| 1 | use std::borrow::Cow; |
| 2 | |
| 3 | use gpui_kit::{AssetSource, Result, SharedString}; |
| 4 | |
| 5 | macro_rules! symbols { |
| 6 | ($($name:literal),* $(,)?) => { |
| 7 | [$((concat!("symbols/", $name, ".svg"), include_bytes!(concat!("../assets/symbols/", $name, ".svg")) as &[u8])),*] |
| 8 | }; |
| 9 | } |
| 10 | |
| 11 | const SYMBOLS: [(&str, &[u8]); 43] = symbols![ |
| 12 | "done", |
| 13 | "done_all", |
| 14 | "keyboard_return", |
| 15 | "schedule", |
| 16 | "schedule_send", |
| 17 | "event", |
| 18 | "wb_sunny", |
| 19 | "work", |
| 20 | "close", |
| 21 | "reply", |
| 22 | "group", |
| 23 | "tag", |
| 24 | "image", |
| 25 | "check_circle", |
| 26 | "error", |
| 27 | "notifications", |
| 28 | "content_copy", |
| 29 | "attach_file", |
| 30 | "upload", |
| 31 | "download", |
| 32 | "folder_open", |
| 33 | "refresh", |
| 34 | "code", |
| 35 | "link", |
| 36 | "format_list_bulleted", |
| 37 | "format_list_numbered", |
| 38 | "format_quote", |
| 39 | "mood", |
| 40 | "status_dot", |
| 41 | "status_dnd", |
| 42 | "status_away", |
| 43 | "status_ring", |
| 44 | "zoom_in", |
| 45 | "zoom_out", |
| 46 | "rotate_right", |
| 47 | "forward", |
| 48 | "open_in_new", |
| 49 | "chevron_left", |
| 50 | "chevron_right", |
| 51 | "fullscreen", |
| 52 | "spinner_track", |
| 53 | "spinner_arc", |
| 54 | "shield", |
| 55 | ]; |
| 56 | |
| 57 | pub struct AppAssets; |
| 58 | |
| 59 | impl AssetSource for AppAssets { |
| 60 | fn load(&self, path: &str) -> Result<Option<Cow<'static, [u8]>>> { |
| 61 | if let Some((_, bytes)) = SYMBOLS.iter().find(|(name, _)| *name == path) { |
| 62 | return Ok(Some(Cow::Borrowed(bytes))); |
| 63 | } |
| 64 | gpui_kit::assets::AllAssets.load(path) |
| 65 | } |
| 66 | |
| 67 | fn list(&self, path: &str) -> Result<Vec<SharedString>> { |
| 68 | let mut names = gpui_kit::assets::AllAssets.list(path)?; |
| 69 | names.extend( |
| 70 | SYMBOLS |
| 71 | .iter() |
| 72 | .filter(|(name, _)| name.starts_with(path)) |
| 73 | .map(|(name, _)| SharedString::from(*name)), |
| 74 | ); |
| 75 | Ok(names) |
| 76 | } |
| 77 | } |