|
|
|
@ -15,13 +15,15 @@ import "git.tebibyte.media/tomo/nasin/internal/theme"
|
|
|
|
|
|
|
|
|
|
type iconTheme struct {
|
|
|
|
|
xdg xdgIconTheme.Theme
|
|
|
|
|
fallback theme.IconTheme
|
|
|
|
|
texturesSmall map[tomo.Icon] canvas.Texture
|
|
|
|
|
texturesMedium map[tomo.Icon] canvas.Texture
|
|
|
|
|
texturesLarge map[tomo.Icon] canvas.Texture
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func FindThemeWarn (name string, path ...string) (theme.IconTheme, error) {
|
|
|
|
|
func FindThemeWarn (name string, fallback theme.IconTheme, path ...string) (theme.IconTheme, error) {
|
|
|
|
|
this := &iconTheme {
|
|
|
|
|
fallback: fallback,
|
|
|
|
|
texturesLarge: make(map[tomo.Icon] canvas.Texture),
|
|
|
|
|
texturesMedium: make(map[tomo.Icon] canvas.Texture),
|
|
|
|
|
texturesSmall: make(map[tomo.Icon] canvas.Texture),
|
|
|
|
@ -68,19 +70,33 @@ func (this *iconTheme) xdgIcon (name string, size tomo.IconSize) (canvas.Texture
|
|
|
|
|
|
|
|
|
|
func (this *iconTheme) Icon (icon tomo.Icon, size tomo.IconSize) canvas.Texture {
|
|
|
|
|
source := this.selectSource(size)
|
|
|
|
|
if texture, ok := source[icon]; ok { return texture }
|
|
|
|
|
texture := this.icon(icon, size)
|
|
|
|
|
source[icon] = texture
|
|
|
|
|
return texture
|
|
|
|
|
texture, ok := source[icon]
|
|
|
|
|
if !ok {
|
|
|
|
|
texture = this.icon(icon, size)
|
|
|
|
|
source[icon] = texture
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if texture == nil {
|
|
|
|
|
return this.fallback.Icon(icon, size)
|
|
|
|
|
} else {
|
|
|
|
|
return texture
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *iconTheme) MimeIcon (mime data.Mime, size tomo.IconSize) canvas.Texture {
|
|
|
|
|
icon := tomo.Icon(mime.String())
|
|
|
|
|
source := this.selectSource(size)
|
|
|
|
|
if texture, ok := source[icon]; ok { return texture }
|
|
|
|
|
texture := this.mimeIcon(mime, size)
|
|
|
|
|
source[icon] = texture
|
|
|
|
|
return texture
|
|
|
|
|
texture, ok := source[icon]
|
|
|
|
|
if !ok {
|
|
|
|
|
texture = this.mimeIcon(mime, size)
|
|
|
|
|
source[icon] = texture
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if texture == nil {
|
|
|
|
|
return this.fallback.MimeIcon(mime, size)
|
|
|
|
|
} else {
|
|
|
|
|
return texture
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (this *iconTheme) icon (icon tomo.Icon, size tomo.IconSize) canvas.Texture {
|
|
|
|
|