aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Converter
diff options
context:
space:
mode:
Diffstat (limited to 'lib/python/Components/Converter')
-rw-r--r--lib/python/Components/Converter/Makefile.am2
-rw-r--r--lib/python/Components/Converter/ValueToPixmap.py40
2 files changed, 41 insertions, 1 deletions
diff --git a/lib/python/Components/Converter/Makefile.am b/lib/python/Components/Converter/Makefile.am
index 3b6fd3e8..b73f6d5a 100644
--- a/lib/python/Components/Converter/Makefile.am
+++ b/lib/python/Components/Converter/Makefile.am
@@ -6,4 +6,4 @@ install_PYTHON = \
ConditionalShowHide.py ServicePosition.py ValueRange.py RdsInfo.py Streaming.py \
StaticMultiList.py ServiceTime.py MovieInfo.py MenuEntryCompare.py StringListSelection.py \
ValueBitTest.py TunerInfo.py ConfigEntryTest.py TemplatedMultiContent.py ProgressToText.py \
- Combine.py SensorToText.py
+ Combine.py SensorToText.py ValueToPixmap.py
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)
+