Skip to content

Commit

Permalink
refactor: unified Icons instance
Browse files Browse the repository at this point in the history
  • Loading branch information
quentinguidee committed Feb 25, 2024
1 parent a79681c commit 6ca1e2f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 7 deletions.
11 changes: 11 additions & 0 deletions src/main/kotlin/com/github/catppuccin/jetbrains_icons/IconPack.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package com.github.catppuccin.jetbrains_icons

import com.github.catppuccin.jetbrains_icons.settings.PluginSettingsState

class IconPack {
val icons = Icons(PluginSettingsState.instance.variant)

companion object {
val instance = IconPack()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import com.intellij.psi.util.PsiUtilCore
import javax.swing.Icon

class IconProvider : IconProvider() {
private var icons = Icons(PluginSettingsState.instance.variant)
private var icons = IconPack.instance.icons

override fun getIcon(element: PsiElement, flags: Int): Icon {
val file = PsiUtilCore.getVirtualFile(element)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,18 @@
package com.github.catppuccin.jetbrains_icons.decorators

import com.github.catppuccin.jetbrains_icons.Icons
import com.github.catppuccin.jetbrains_icons.settings.PluginSettingsState
import com.github.catppuccin.jetbrains_icons.IconPack
import com.intellij.ide.projectView.ProjectViewNode
import com.intellij.ide.projectView.PresentationData
import com.intellij.ide.projectView.ProjectViewNodeDecorator

class PythonProjectViewNodeDecorator : ProjectViewNodeDecorator {
private var icons = Icons(PluginSettingsState.instance.variant)
private var icons = IconPack.instance.icons

override fun decorate(node: ProjectViewNode<*>, data: PresentationData) {
val fileType = node.virtualFile?.name?.split(".")?.last()
val extension = node.virtualFile?.name?.split(".")?.last()

if (fileType.equals("py")) {
data.setIcon(icons.EXT_TO_ICONS["py"])
if (extension.equals("py")) {
data.setIcon(icons.EXT_TO_ICONS[extension])
}
}
}

0 comments on commit 6ca1e2f

Please sign in to comment.