Add infrastructure for loading icon themes from extensions (#23203)
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
This commit is contained in:
parent
3b8a5c9647
commit
f53915c711
11 changed files with 303 additions and 10 deletions
|
@ -44,4 +44,37 @@ impl ExtensionThemeProxy for ThemeRegistryProxy {
|
|||
fn reload_current_theme(&self, cx: &mut AppContext) {
|
||||
ThemeSettings::reload_current_theme(cx)
|
||||
}
|
||||
|
||||
fn list_icon_theme_names(
|
||||
&self,
|
||||
icon_theme_path: PathBuf,
|
||||
fs: Arc<dyn Fs>,
|
||||
) -> Task<Result<Vec<String>>> {
|
||||
self.executor.spawn(async move {
|
||||
let icon_theme_family = theme::read_icon_theme(&icon_theme_path, fs).await?;
|
||||
Ok(icon_theme_family
|
||||
.themes
|
||||
.into_iter()
|
||||
.map(|theme| theme.name)
|
||||
.collect())
|
||||
})
|
||||
}
|
||||
|
||||
fn remove_icon_themes(&self, icon_themes: Vec<SharedString>) {
|
||||
self.theme_registry.remove_icon_themes(&icon_themes);
|
||||
}
|
||||
|
||||
fn load_icon_theme(
|
||||
&self,
|
||||
icon_theme_path: PathBuf,
|
||||
icons_root_dir: PathBuf,
|
||||
fs: Arc<dyn Fs>,
|
||||
) -> Task<Result<()>> {
|
||||
let theme_registry = self.theme_registry.clone();
|
||||
self.executor.spawn(async move {
|
||||
theme_registry
|
||||
.load_icon_theme(&icon_theme_path, &icons_root_dir, fs)
|
||||
.await
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue