aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components/Converter
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2009-02-11 12:52:48 +0100
committerFelix Domke <tmbinc@elitedvb.net>2009-02-11 12:52:48 +0100
commitbbfcb7ea1f040d030277e2b6f2efa9ea0967bf2b (patch)
treec5945c791698c14723e989449e6b4bfcc275c05d /lib/python/Components/Converter
parent4f7990ff2a55874b9eb65e3c9cd47dacb9f76deb (diff)
parent5e6f814d005a01caa437a532e61f4b338617ff67 (diff)
downloadenigma2-bbfcb7ea1f040d030277e2b6f2efa9ea0967bf2b.tar.gz
enigma2-bbfcb7ea1f040d030277e2b6f2efa9ea0967bf2b.zip
Merge branch 'master' of /home/tmbinc/enigma2-git into tmbinc/FixTimingBugs
Conflicts: lib/dvb/decoder.cpp
Diffstat (limited to 'lib/python/Components/Converter')
-rw-r--r--lib/python/Components/Converter/EventTime.py4
-rw-r--r--lib/python/Components/Converter/MovieInfo.py4
-rw-r--r--lib/python/Components/Converter/RemainingToText.py34
-rw-r--r--lib/python/Components/Converter/ServicePosition.py15
-rw-r--r--lib/python/Components/Converter/ServiceTime.py4
-rw-r--r--lib/python/Components/Converter/TemplatedMultiContent.py32
6 files changed, 75 insertions, 18 deletions
diff --git a/lib/python/Components/Converter/EventTime.py b/lib/python/Components/Converter/EventTime.py
index 966f2ca8..41f1ebf3 100644
--- a/lib/python/Components/Converter/EventTime.py
+++ b/lib/python/Components/Converter/EventTime.py
@@ -1,7 +1,7 @@
from Converter import Converter
from Poll import Poll
from time import time
-from Components.Element import cached
+from Components.Element import cached, ElementError
class EventTime(Poll, Converter, object):
STARTTIME = 0
@@ -28,7 +28,7 @@ class EventTime(Poll, Converter, object):
self.poll_interval = 30*1000
self.poll_enabled = True
else:
- raise str("'%s' is not <StartTime|EndTime|Remaining|Duration|Progress> for EventTime converter" % type)
+ raise ElementError("'%s' is not <StartTime|EndTime|Remaining|Duration|Progress> for EventTime converter" % type)
@cached
def getTime(self):
diff --git a/lib/python/Components/Converter/MovieInfo.py b/lib/python/Components/Converter/MovieInfo.py
index 068d24d3..be28dcce 100644
--- a/lib/python/Components/Converter/MovieInfo.py
+++ b/lib/python/Components/Converter/MovieInfo.py
@@ -1,5 +1,5 @@
from Components.Converter.Converter import Converter
-from Components.Element import cached
+from Components.Element import cached, ElementError
from enigma import iServiceInformation
from ServiceReference import ServiceReference
@@ -16,7 +16,7 @@ class MovieInfo(Converter, object):
elif type == "RecordServiceName":
self.type = self.MOVIE_REC_SERVICE_NAME
else:
- raise str("'%s' is not <ShortDescription|MetaDescription|RecordServiceName> for MovieInfo converter" % type)
+ raise ElementError("'%s' is not <ShortDescription|MetaDescription|RecordServiceName> for MovieInfo converter" % type)
Converter.__init__(self, type)
@cached
diff --git a/lib/python/Components/Converter/RemainingToText.py b/lib/python/Components/Converter/RemainingToText.py
index adefe9cf..4249e30a 100644
--- a/lib/python/Components/Converter/RemainingToText.py
+++ b/lib/python/Components/Converter/RemainingToText.py
@@ -2,19 +2,43 @@ from Components.Converter.Converter import Converter
from Components.Element import cached
class RemainingToText(Converter, object):
+ DEFAULT = 0
+ WITH_SECONDS = 1
+ NO_SECONDS = 2
+
def __init__(self, type):
Converter.__init__(self, type)
+ if type == "WithSeconds":
+ self.type = self.WITH_SECONDS
+ elif type == "NoSeconds":
+ self.type = self.NO_SECONDS
+ else:
+ self.type = self.DEFAULT
@cached
def getText(self):
- r = self.source.time
- if r is None:
+ time = self.source.time
+ if time is None:
return ""
(duration, remaining) = self.source.time
- if remaining is not None:
- return "+%d min" % (remaining / 60)
+
+ if self.type == self.WITH_SECONDS:
+ if remaining is not None:
+ return "%d:%02d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60), remaining % 60)
+ else:
+ return "%02d:%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60), duration % 60)
+ elif self.type == self.NO_SECONDS:
+ if remaining is not None:
+ return "+%d:%02d" % (remaining / 3600, (remaining / 60) - ((remaining / 3600) * 60))
+ else:
+ return "%02d:%02d" % (duration / 3600, (duration / 60) - ((duration / 3600) * 60))
+ elif self.type == self.DEFAULT:
+ if remaining is not None:
+ return "+%d min" % (remaining / 60)
+ else:
+ return "%d min" % (duration / 60)
else:
- return "%d min" % (duration / 60)
+ return "???"
text = property(getText)
diff --git a/lib/python/Components/Converter/ServicePosition.py b/lib/python/Components/Converter/ServicePosition.py
index b488258b..2bcc5492 100644
--- a/lib/python/Components/Converter/ServicePosition.py
+++ b/lib/python/Components/Converter/ServicePosition.py
@@ -1,7 +1,7 @@
from Converter import Converter
from Poll import Poll
from enigma import iPlayableService
-from Components.Element import cached
+from Components.Element import cached, ElementError
class ServicePosition(Converter, Poll, object):
TYPE_LENGTH = 0
@@ -19,6 +19,7 @@ class ServicePosition(Converter, Poll, object):
self.negate = 'Negate' in args
self.detailed = 'Detailed' in args
self.showHours = 'ShowHours' in args
+ self.showNoSeconds = 'ShowNoSeconds' in args
if self.detailed:
self.poll_interval = 100
@@ -34,7 +35,7 @@ class ServicePosition(Converter, Poll, object):
elif type == "Gauge":
self.type = self.TYPE_GAUGE
else:
- raise "type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours}"
+ raise ElementError("type must be {Length|Position|Remaining|Gauge} with optional arguments {Negate|Detailed|ShowHours|NoSeconds}")
self.poll_enabled = self.type != self.TYPE_LENGTH
@@ -94,9 +95,15 @@ class ServicePosition(Converter, Poll, object):
if not self.detailed:
if self.showHours:
- return sign + "%d:%02d:%02d" % (l/3600, l%3600/60, l%60)
+ if self.showNoSeconds:
+ return sign + "%d:%02d" % (l/3600, l%3600/60)
+ else:
+ return sign + "%d:%02d:%02d" % (l/3600, l%3600/60, l%60)
else:
- return sign + "%d:%02d" % (l/60, l%60)
+ if self.showNoSeconds:
+ return sign + "%d" % (l/60)
+ else:
+ return sign + "%d:%02d" % (l/60, l%60)
else:
if self.showHours:
return sign + "%d:%02d:%02d:%03d" % ((l/3600/90000), (l/90000)%3600/60, (l/90000)%60, (l%90000)/90)
diff --git a/lib/python/Components/Converter/ServiceTime.py b/lib/python/Components/Converter/ServiceTime.py
index 16bcae3a..89965067 100644
--- a/lib/python/Components/Converter/ServiceTime.py
+++ b/lib/python/Components/Converter/ServiceTime.py
@@ -1,5 +1,5 @@
from Converter import Converter
-from Components.Element import cached
+from Components.Element import cached, ElementError
from enigma import iServiceInformation
class ServiceTime(Converter, object):
@@ -16,7 +16,7 @@ class ServiceTime(Converter, object):
elif type == "Duration":
self.type = self.DURATION
else:
- raise str("'%s' is not <StartTime|EndTime|Duration> for eEventTime converter" % type)
+ raise ElementError("'%s' is not <StartTime|EndTime|Duration> for eEventTime converter" % type)
@cached
def getTime(self):
diff --git a/lib/python/Components/Converter/TemplatedMultiContent.py b/lib/python/Components/Converter/TemplatedMultiContent.py
index a1b601d6..5f1d4f24 100644
--- a/lib/python/Components/Converter/TemplatedMultiContent.py
+++ b/lib/python/Components/Converter/TemplatedMultiContent.py
@@ -5,22 +5,27 @@ class TemplatedMultiContent(StringList):
def __init__(self, args):
StringList.__init__(self, args)
from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_HALIGN_RIGHT, RT_VALIGN_TOP, RT_VALIGN_CENTER, RT_VALIGN_BOTTOM
- from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmap, MultiContentEntryPixmapAlphaTest
+ from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmap, MultiContentEntryPixmapAlphaTest, MultiContentTemplateColor
l = locals()
del l["self"] # cleanup locals a bit
del l["args"]
self.template = eval(args, {}, l)
+ self.active_style = None
assert "fonts" in self.template
assert "itemHeight" in self.template
- assert "template" in self.template
+ assert "template" in self.template or "templates" in self.template
+ assert "template" in self.template or "default" in self.template["templates"] # we need to have a default template
+
+ if not "template" in self.template: # default template can be ["template"] or ["templates"]["default"]
+ self.template["template"] = self.template["templates"]["default"]
def changed(self, what):
if not self.content:
from enigma import eListboxPythonMultiContent
self.content = eListboxPythonMultiContent()
self.content.setItemHeight(self.template["itemHeight"])
- self.content.setTemplate(self.template["template"])
+ self.setTemplate()
# also setup fonts (also given by source)
index = 0
@@ -28,7 +33,28 @@ class TemplatedMultiContent(StringList):
self.content.setFont(index, f)
index += 1
+ # if only template changed, don't reload list
+ if what[0] == self.CHANGED_SPECIFIC and what[1] == "style":
+ self.setTemplate()
+ return
+
if self.source:
self.content.setList(self.source.list)
+ self.setTemplate()
self.downstream_elements.changed(what)
+
+ def setTemplate(self):
+ if self.source:
+ style = self.source.style
+ if style == self.active_style:
+ return # style did not change
+
+ # if skin defined "templates", that means that it defines multiple styles in a dict. template should still be a default
+ templates = self.template.get("templates")
+ template = self.template.get("template")
+
+ if templates and style: # if we have a custom style defined in the source, and different templates in the skin, look it up
+ template = templates.get(self.source.style, template) # default to default template
+
+ self.content.setTemplate(template)