diff options
| author | ghost <andreas.monzner@multimedia-labs.de> | 2011-09-06 15:20:16 +0200 |
|---|---|---|
| committer | ghost <andreas.monzner@multimedia-labs.de> | 2011-09-06 15:20:16 +0200 |
| commit | 71dd5b32ca9f94f1a35ff6e82671d89642fec23b (patch) | |
| tree | 4824307914b21bf073d004cd55669c27a1597234 /lib/python/Components/Converter/ValueToPixmap.py | |
| parent | 80c9ad7d8d0e709d8bed740481b46ff23654fcaa (diff) | |
| parent | 399c119582c5f4e908f118a6057f2a041771b422 (diff) | |
| download | enigma2-71dd5b32ca9f94f1a35ff6e82671d89642fec23b.tar.gz enigma2-71dd5b32ca9f94f1a35ff6e82671d89642fec23b.zip | |
Merge remote-tracking branch 'origin/acid-burn/virtualkeyboard'
Diffstat (limited to 'lib/python/Components/Converter/ValueToPixmap.py')
| -rw-r--r-- | lib/python/Components/Converter/ValueToPixmap.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lib/python/Components/Converter/ValueToPixmap.py b/lib/python/Components/Converter/ValueToPixmap.py new file mode 100644 index 00000000..0acd2639 --- /dev/null +++ b/lib/python/Components/Converter/ValueToPixmap.py @@ -0,0 +1,40 @@ +from Components.Converter.Converter import Converter +from Components.Element import cached, ElementError +from Tools.Directories import fileExists, SCOPE_SKIN_IMAGE, SCOPE_CURRENT_SKIN, resolveFilename +from Tools.LoadPixmap import LoadPixmap + + +class ValueToPixmap(Converter, object): + LANGUAGE_CODE = 0 + PATH = 1 + + def __init__(self, type): + Converter.__init__(self, type) + if type == "LanguageCode": + self.type = self.LANGUAGE_CODE + elif type == "Path": + self.type = self.PATH + else: + raise ElementError("'%s' is not <LanguageCode|Path> for ValueToPixmap converter" % type) + + @cached + def getPixmap(self): + if self.source: + val = self.source.text + if val in (None, ""): + return None + if self.type == self.PATH: + return LoadPixmap(val) + if self.type == self.LANGUAGE_CODE: + png = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "countries/" + val[3:].lower() + ".png")) + if png == None: + png = LoadPixmap(cached=True, path=resolveFilename(SCOPE_SKIN_IMAGE, "countries/missing.png")) + return png + return None + + pixmap = property(getPixmap) + + def changed(self, what): + if what[0] != self.CHANGED_SPECIFIC or what[1] == self.type: + Converter.changed(self, what) + |
