forked from kkabt/blendgit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimage_util.py
More file actions
32 lines (22 loc) · 698 Bytes
/
Copy pathimage_util.py
File metadata and controls
32 lines (22 loc) · 698 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import bpy
import bpy.utils.previews
from .common import get_subpath
preview_collections = {}
GIT_ICONS = {
'LOGO': "Git-Icon-1788C.png",
}
def get_icon(name: str) -> 'icon_id: int':
pcoll = preview_collections["blendgit"]
image = pcoll.get(name)
return image.icon_id if image else 0
def register():
pcoll = bpy.utils.previews.new()
preview_collections["blendgit"] = pcoll
# load icons
for name, filename in GIT_ICONS.items():
abspath = get_subpath("icons", filename)
pcoll.load(name, abspath, 'IMAGE')
def unregister():
for pcoll in preview_collections.values():
bpy.utils.previews.remove(pcoll)
preview_collections.clear()