提交 f91c7ded 编写于 作者: M Martin Aeschlimann

product icons more

上级 18f3bee3
......@@ -35,9 +35,13 @@
"url": "vscode://schemas/language-configuration"
},
{
"fileMatch": "*icon-theme.json",
"fileMatch": ["*icon-theme.json", "!*product-icon-theme.json"],
"url": "vscode://schemas/icon-theme"
},
{
"fileMatch": "*product-icon-theme.json",
"url": "vscode://schemas/product-icon-theme"
},
{
"fileMatch": "*color-theme.json",
"url": "vscode://schemas/color-theme"
......
......@@ -55,6 +55,13 @@
"fontStyle": "bold"
}
}
],
"productIconThemes": [
{
"id": "Test Product Icons",
"label": "The Test Product Icon Theme",
"path": "./producticons/test-product-icon-theme.json"
}
]
}
}
The MIT License (MIT)
Copyright (c) <2013> <Elegant Themes, Inc.>
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
\ No newline at end of file
{
// ElegantIcons from https://www.elegantthemes.com/icons/elegant_font.zip
"fonts": [
{
"id": "elegant",
"src": [
{
"path": "./ElegantIcons.woff",
"format": "woff"
}
],
"weight": "normal",
"style": "normal",
}
],
"iconDefinitions": {
"chevron-down": {
"fontCharacter": "\\43",
},
"chevron-right": {
"fontCharacter": "\\45"
},
"error": {
"fontCharacter": "\\e062"
},
"warning": {
"fontCharacter": "\\e063"
},
"settings-gear": {
"fontCharacter": "\\e035"
},
"settings-files": {
"fontCharacter": "\\e006;"
}
}
}
......@@ -81,7 +81,7 @@ export class FileIconThemeData implements IWorkbenchFileIconTheme {
private static _noIconTheme: FileIconThemeData | null = null;
static noIconTheme(): FileIconThemeData {
static get noIconTheme(): FileIconThemeData {
let themeData = FileIconThemeData._noIconTheme;
if (!themeData) {
themeData = FileIconThemeData._noIconTheme = new FileIconThemeData('', '', null);
......
......@@ -83,7 +83,7 @@ export class ProductIconThemeData implements IWorkbenchProductIconTheme {
private static _defaultProductIconTheme: ProductIconThemeData | null = null;
static defaultTheme(): ProductIconThemeData {
static get defaultTheme(): ProductIconThemeData {
let themeData = ProductIconThemeData._defaultProductIconTheme;
if (!themeData) {
themeData = ProductIconThemeData._defaultProductIconTheme = new ProductIconThemeData(DEFAULT_PRODUCT_ICON_THEME_ID, nls.localize('defaultTheme', 'Default theme'), DEFAULT_PRODUCT_ICON_THEME_SETTING_VALUE);
......
......@@ -29,7 +29,7 @@ import { getRemoteAuthority } from 'vs/platform/remote/common/remoteHosts';
import { IWorkbenchLayoutService } from 'vs/workbench/services/layout/browser/layoutService';
import { IExtensionResourceLoaderService } from 'vs/workbench/services/extensionResourceLoader/common/extensionResourceLoader';
import { ThemeRegistry, registerColorThemeExtensionPoint, registerFileIconThemeExtensionPoint, registerProductIconThemeExtensionPoint } from 'vs/workbench/services/themes/common/themeExtensionPoints';
import { updateColorThemeConfigurationSchemas, updateFileIconThemeConfigurationSchemas, ThemeConfiguration, updateProductIconThemeConfigurationSchemas } from 'vs/workbench/services/themes/common/themeConfiguration';
import { updateColorThemeConfigurationSchemas, updateFileIconThemeConfigurationSchemas, ThemeConfiguration, updateProductIconThemeConfigurationSchemas, DEFAULT_PRODUCT_ICON_THEME_SETTING_VALUE } from 'vs/workbench/services/themes/common/themeConfiguration';
import { ProductIconThemeData, DEFAULT_PRODUCT_ICON_THEME_ID } from 'vs/workbench/services/themes/browser/productIconThemeData';
import { registerProductIconThemeSchemas } from 'vs/workbench/services/themes/common/productIconThemeSchema';
......@@ -108,12 +108,12 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
this.currentColorTheme = ColorThemeData.createUnloadedTheme('');
this.fileIconThemeWatcher = new ThemeFileWatcher(fileService, environmentService, this.reloadCurrentFileIconTheme.bind(this));
this.fileIconThemeRegistry = new ThemeRegistry(extensionService, fileIconThemesExtPoint, FileIconThemeData.fromExtensionTheme, true);
this.fileIconThemeRegistry = new ThemeRegistry(extensionService, fileIconThemesExtPoint, FileIconThemeData.fromExtensionTheme, true, FileIconThemeData.noIconTheme);
this.onFileIconThemeChange = new Emitter<IWorkbenchFileIconTheme>();
this.currentFileIconTheme = FileIconThemeData.createUnloadedTheme('');
this.productIconThemeWatcher = new ThemeFileWatcher(fileService, environmentService, this.reloadCurrentProductIconTheme.bind(this));
this.productIconThemeRegistry = new ThemeRegistry(extensionService, productIconThemesExtPoint, ProductIconThemeData.fromExtensionTheme, true);
this.productIconThemeRegistry = new ThemeRegistry(extensionService, productIconThemesExtPoint, ProductIconThemeData.fromExtensionTheme, true, ProductIconThemeData.defaultTheme);
this.onProductIconThemeChange = new Emitter<IWorkbenchProductIconTheme>();
this.currentProductIconTheme = ProductIconThemeData.createUnloadedTheme('');
......@@ -187,7 +187,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if (!await this.restoreFileIconTheme()) { // checks if theme from settings exists and is set
// restore theme
if (this.currentFileIconTheme.id === DEFAULT_FILE_ICON_THEME_ID && !types.isUndefined(prevFileIconId) && await this.findFileIconThemeById(prevFileIconId)) {
if (this.currentFileIconTheme.id === DEFAULT_FILE_ICON_THEME_ID && !types.isUndefined(prevFileIconId) && await this.fileIconThemeRegistry.findThemeById(prevFileIconId)) {
this.setFileIconTheme(prevFileIconId, 'auto');
prevFileIconId = undefined;
} else {
......@@ -206,7 +206,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if (await this.restoreProductIconTheme()) { // checks if theme from settings exists and is set
// restore theme
if (this.currentProductIconTheme.id === DEFAULT_PRODUCT_ICON_THEME_ID && !types.isUndefined(prevProductIconId) && await this.findProductIconThemeById(prevProductIconId)) {
if (this.currentProductIconTheme.id === DEFAULT_PRODUCT_ICON_THEME_ID && !types.isUndefined(prevProductIconId) && await this.productIconThemeRegistry.findThemeById(prevProductIconId)) {
this.setProductIconTheme(prevProductIconId, 'auto');
prevProductIconId = undefined;
} else {
......@@ -256,7 +256,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if (devThemes.length) {
return this.setFileIconTheme(devThemes[0].id, ConfigurationTarget.MEMORY);
}
const theme = await this.findFileIconThemeBySettingsId(this.settings.fileIconTheme);
const theme = await this.fileIconThemeRegistry.findThemeBySettingsId(this.settings.fileIconTheme);
return this.setFileIconTheme(theme ? theme.id : DEFAULT_FILE_ICON_THEME_ID, undefined);
};
......@@ -265,7 +265,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
if (devThemes.length) {
return this.setProductIconTheme(devThemes[0].id, ConfigurationTarget.MEMORY);
}
const theme = await this.findProductIconThemeBySettingsId(this.settings.productIconTheme);
const theme = await this.productIconThemeRegistry.findThemeBySettingsId(this.settings.productIconTheme);
return this.setProductIconTheme(theme ? theme.id : DEFAULT_PRODUCT_ICON_THEME_ID, undefined);
};
......@@ -514,7 +514,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
return this.currentFileIconTheme;
}
const newThemeData = (await this.findFileIconThemeById(iconTheme)) || FileIconThemeData.noIconTheme();
const newThemeData = (await this.fileIconThemeRegistry.findThemeById(iconTheme)) || FileIconThemeData.noIconTheme;
await newThemeData.ensureLoaded(this.fileService);
_applyRules(newThemeData.styleSheetContent!, fileIconThemeRulesClassName);
......@@ -529,14 +529,6 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
return newThemeData;
}
private async findFileIconThemeById(id: string): Promise<FileIconThemeData | undefined> {
return id.length === 0 ? FileIconThemeData.noIconTheme() : this.fileIconThemeRegistry.findThemeById(id);
}
private async findFileIconThemeBySettingsId(settingsId: string | null): Promise<FileIconThemeData | undefined> {
return !settingsId ? FileIconThemeData.noIconTheme() : this.fileIconThemeRegistry.findThemeBySettingsId(settingsId);
}
private async reloadCurrentFileIconTheme() {
await this.currentFileIconTheme.reload(this.fileService);
_applyRules(this.currentFileIconTheme.styleSheetContent!, fileIconThemeRulesClassName);
......@@ -545,7 +537,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
public async restoreFileIconTheme(): Promise<boolean> {
const settingId = this.settings.fileIconTheme;
const theme = await this.findFileIconThemeBySettingsId(settingId);
const theme = await this.fileIconThemeRegistry.findThemeBySettingsId(settingId);
if (theme) {
if (settingId !== this.currentFileIconTheme.settingsId) {
await this.setFileIconTheme(theme.id, undefined);
......@@ -588,7 +580,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
return this.currentProductIconTheme;
}
const newThemeData = await this.findProductIconThemeById(iconTheme) || ProductIconThemeData.defaultTheme();
const newThemeData = await this.productIconThemeRegistry.findThemeById(iconTheme) || ProductIconThemeData.defaultTheme;
await newThemeData.ensureLoaded(this.fileService);
_applyRules(newThemeData.styleSheetContent!, fileIconThemeRulesClassName);
......@@ -603,14 +595,6 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
return newThemeData;
}
private async findProductIconThemeById(id: string): Promise<ProductIconThemeData | undefined> {
return id.length === 0 ? ProductIconThemeData.defaultTheme() : this.productIconThemeRegistry.findThemeById(id);
}
private async findProductIconThemeBySettingsId(settingsId: string | null): Promise<ProductIconThemeData | undefined> {
return !settingsId ? ProductIconThemeData.defaultTheme() : this.productIconThemeRegistry.findThemeBySettingsId(settingsId);
}
private async reloadCurrentProductIconTheme() {
await this.currentProductIconTheme.reload(this.fileService);
_applyRules(this.currentProductIconTheme.styleSheetContent!, productIconThemeRulesClassName);
......@@ -619,7 +603,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService {
public async restoreProductIconTheme(): Promise<boolean> {
const settingId = this.settings.productIconTheme;
const theme = await this.findProductIconThemeBySettingsId(settingId);
const theme = await this.productIconThemeRegistry.findThemeBySettingsId(settingId);
if (theme) {
if (settingId !== this.currentProductIconTheme.settingsId) {
await this.setProductIconTheme(theme.id, undefined);
......
......@@ -126,7 +126,8 @@ export class ThemeRegistry<T extends IThemeData> {
@IExtensionService private readonly extensionService: IExtensionService,
private readonly themesExtPoint: IExtensionPoint<IThemeExtensionPoint[]>,
private create: (theme: IThemeExtensionPoint, themeLocation: URI, extensionData: ExtensionData) => T,
private idRequired = false
private idRequired = false,
private builtInTheme: T | undefined = undefined
) {
this.extensionThemes = [];
this.initialize();
......@@ -198,34 +199,38 @@ export class ThemeRegistry<T extends IThemeData> {
});
}
public findThemeById(themeId: string, defaultId?: string): Promise<T | undefined> {
return this.getThemes().then(allThemes => {
let defaultTheme: T | undefined = undefined;
for (let t of allThemes) {
if (t.id === themeId) {
return t;
}
if (t.id === defaultId) {
defaultTheme = t;
}
public async findThemeById(themeId: string, defaultId?: string): Promise<T | undefined> {
if (this.builtInTheme && this.builtInTheme.id === themeId) {
return this.builtInTheme;
}
const allThemes = await this.getThemes();
let defaultTheme: T | undefined = undefined;
for (let t of allThemes) {
if (t.id === themeId) {
return t;
}
return defaultTheme;
});
if (t.id === defaultId) {
defaultTheme = t;
}
}
return defaultTheme;
}
public findThemeBySettingsId(settingsId: string | null, defaultId?: string): Promise<T | undefined> {
return this.getThemes().then(allThemes => {
let defaultTheme: T | undefined = undefined;
for (let t of allThemes) {
if (t.settingsId === settingsId) {
return t;
}
if (t.id === defaultId) {
defaultTheme = t;
}
public async findThemeBySettingsId(settingsId: string | null, defaultId?: string): Promise<T | undefined> {
if (this.builtInTheme && this.builtInTheme.settingsId === settingsId) {
return this.builtInTheme;
}
const allThemes = await this.getThemes();
let defaultTheme: T | undefined = undefined;
for (let t of allThemes) {
if (t.settingsId === settingsId) {
return t;
}
return defaultTheme;
});
if (t.id === defaultId) {
defaultTheme = t;
}
}
return defaultTheme;
}
public findThemeByExtensionLocation(extLocation: URI | undefined): Promise<T[]> {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册