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
|
@ -103,6 +103,21 @@ pub trait ExtensionThemeProxy: Send + Sync + 'static {
|
|||
fn load_user_theme(&self, theme_path: PathBuf, fs: Arc<dyn Fs>) -> Task<Result<()>>;
|
||||
|
||||
fn reload_current_theme(&self, cx: &mut AppContext);
|
||||
|
||||
fn list_icon_theme_names(
|
||||
&self,
|
||||
icon_theme_path: PathBuf,
|
||||
fs: Arc<dyn Fs>,
|
||||
) -> Task<Result<Vec<String>>>;
|
||||
|
||||
fn remove_icon_themes(&self, icon_themes: Vec<SharedString>);
|
||||
|
||||
fn load_icon_theme(
|
||||
&self,
|
||||
icon_theme_path: PathBuf,
|
||||
icons_root_dir: PathBuf,
|
||||
fs: Arc<dyn Fs>,
|
||||
) -> Task<Result<()>>;
|
||||
}
|
||||
|
||||
impl ExtensionThemeProxy for ExtensionHostProxy {
|
||||
|
@ -137,6 +152,39 @@ impl ExtensionThemeProxy for ExtensionHostProxy {
|
|||
|
||||
proxy.reload_current_theme(cx)
|
||||
}
|
||||
|
||||
fn list_icon_theme_names(
|
||||
&self,
|
||||
icon_theme_path: PathBuf,
|
||||
fs: Arc<dyn Fs>,
|
||||
) -> Task<Result<Vec<String>>> {
|
||||
let Some(proxy) = self.theme_proxy.read().clone() else {
|
||||
return Task::ready(Ok(Vec::new()));
|
||||
};
|
||||
|
||||
proxy.list_icon_theme_names(icon_theme_path, fs)
|
||||
}
|
||||
|
||||
fn remove_icon_themes(&self, icon_themes: Vec<SharedString>) {
|
||||
let Some(proxy) = self.theme_proxy.read().clone() else {
|
||||
return;
|
||||
};
|
||||
|
||||
proxy.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 Some(proxy) = self.theme_proxy.read().clone() else {
|
||||
return Task::ready(Ok(()));
|
||||
};
|
||||
|
||||
proxy.load_icon_theme(icon_theme_path, icons_root_dir, fs)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ExtensionGrammarProxy: Send + Sync + 'static {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue