Print info if an icon is not found
[klaudia.git] / src / xicon.py
blobacada147223312a784caf66c539d276ca09a4510
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
4 # Imports (Global)
5 from os import path
6 from xdg import IconTheme
8 # TODO - cache icons for faster lookup
10 class XIcon(object):
11 def __init__(self, *args):
12 self.extra_themes = []
14 def addIconPath(self, path):
15 IconTheme.icondirs.append(path)
17 def addThemeName(self, theme_name):
18 for i in range(len(IconTheme.icondirs)):
19 theme_path = path.join(IconTheme.icondirs[i], theme_name)
20 if (path.exists(theme_path)):
21 self.extra_themes.append(theme_name)
23 def getIconPath(self, name, size=48):
24 for i in range(len(self.extra_themes)):
25 icon = IconTheme.getIconPath(name, size, self.extra_themes[i])
26 if (icon != None):
27 break
28 else:
29 icon = IconTheme.getIconPath(name, size)
31 if (icon == None):
32 icon = ""
33 print "No icon found for", name
35 return icon