This PR adds the supporting infrastructure to support loading icon
themes defined by extensions.
Here's an example icon theme:
```json
{
"name": "My Icon Theme",
"author": "Me <me@example.com>",
"themes": [
{
"name": "My Icon Theme",
"appearance": "dark",
"file_icons": {
"gleam": { "path": "./icons/file_type_gleam.svg" },
"toml": { "path": "./icons/file_type_toml.svg" }
}
}
]
}
```
The icon paths are resolved relative to the root of the extension
directory.
Release Notes:
- N/A
45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
#![allow(missing_docs)]
|
|
|
|
use gpui::SharedString;
|
|
use schemars::JsonSchema;
|
|
use serde::{Deserialize, Serialize};
|
|
use std::collections::HashMap;
|
|
|
|
use crate::AppearanceContent;
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
|
pub struct IconThemeFamilyContent {
|
|
pub name: String,
|
|
pub author: String,
|
|
pub themes: Vec<IconThemeContent>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
|
pub struct IconThemeContent {
|
|
pub name: String,
|
|
pub appearance: AppearanceContent,
|
|
#[serde(default)]
|
|
pub directory_icons: DirectoryIconsContent,
|
|
#[serde(default)]
|
|
pub chevron_icons: ChevronIconsContent,
|
|
#[serde(default)]
|
|
pub file_icons: HashMap<String, IconDefinitionContent>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
|
|
pub struct DirectoryIconsContent {
|
|
pub collapsed: Option<SharedString>,
|
|
pub expanded: Option<SharedString>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Default, Serialize, Deserialize, JsonSchema)]
|
|
pub struct ChevronIconsContent {
|
|
pub collapsed: Option<SharedString>,
|
|
pub expanded: Option<SharedString>,
|
|
}
|
|
|
|
#[derive(Debug, Clone, Serialize, Deserialize, JsonSchema)]
|
|
pub struct IconDefinitionContent {
|
|
pub path: SharedString,
|
|
}
|