aboutsummaryrefslogtreecommitdiff
path: root/lib/python/Components
diff options
context:
space:
mode:
authorFelix Domke <tmbinc@elitedvb.net>2008-02-19 23:33:24 +0000
committerFelix Domke <tmbinc@elitedvb.net>2008-02-19 23:33:24 +0000
commit5e942862b2017443ec34831f649f890f8215a534 (patch)
treea0ef856d2579bb0f53cc979a39a64d938b143e24 /lib/python/Components
parent8bf997495d8f192ccd44545b8fba92a3bcbb3e22 (diff)
downloadenigma2-5e942862b2017443ec34831f649f890f8215a534.tar.gz
enigma2-5e942862b2017443ec34831f649f890f8215a534.zip
movie player configuration options, by Anders Holst
Diffstat (limited to 'lib/python/Components')
-rw-r--r--lib/python/Components/RecordingConfig.py6
-rw-r--r--lib/python/Components/UsageConfig.py57
-rw-r--r--lib/python/Components/config.py132
3 files changed, 187 insertions, 8 deletions
diff --git a/lib/python/Components/RecordingConfig.py b/lib/python/Components/RecordingConfig.py
index d3a0daf2..9a13bd62 100644
--- a/lib/python/Components/RecordingConfig.py
+++ b/lib/python/Components/RecordingConfig.py
@@ -1,9 +1,9 @@
-from config import ConfigInteger, ConfigYesNo, ConfigSubsection, config
+from config import ConfigNumber, ConfigYesNo, ConfigSubsection, config
def InitRecordingConfig():
config.recording = ConfigSubsection();
# actually this is "recordings always have priority". "Yes" does mean: don't ask. The RecordTimer will ask when value is 0.
config.recording.asktozap = ConfigYesNo(default=True)
- config.recording.margin_before = ConfigInteger(default=0, limits=(0,30))
- config.recording.margin_after = ConfigInteger(default=0, limits=(0,30))
+ config.recording.margin_before = ConfigNumber(default=0)
+ config.recording.margin_after = ConfigNumber(default=0)
config.recording.debug = ConfigYesNo(default = False)
diff --git a/lib/python/Components/UsageConfig.py b/lib/python/Components/UsageConfig.py
index 36d149cf..3df3a442 100644
--- a/lib/python/Components/UsageConfig.py
+++ b/lib/python/Components/UsageConfig.py
@@ -1,4 +1,4 @@
-from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigInteger
+from config import ConfigSubsection, ConfigYesNo, config, ConfigSelection, ConfigText, ConfigNumber, ConfigSet, ConfigNothing
from enigma import Misc_Options, setTunerTypePriorityOrder;
from SystemInfo import SystemInfo
import os
@@ -24,12 +24,18 @@ def InitUsageConfig():
("248", "4 " + _("hours")) ])
config.usage.output_12V = ConfigSelection(default = "do not change", choices = [
("do not change", _("do not change")), ("off", _("off")), ("on", _("on")) ])
- config.usage.self_defined_seek = ConfigInteger(default=10, limits=(1,9999))
config.usage.pip_zero_button = ConfigSelection(default = "standard", choices = [
("standard", _("standard")), ("swap", _("swap PiP and main picture")),
("swapstop", _("move PiP to main picture")), ("stop", _("stop PiP")) ])
+ config.usage.on_movie_start = ConfigSelection(default = "ask", choices = [
+ ("ask", _("Ask user")), ("resume", _("Resume from last position")), ("beginning", _("Start from the beginning")) ])
+ config.usage.on_movie_stop = ConfigSelection(default = "ask", choices = [
+ ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")) ])
+ config.usage.on_movie_eof = ConfigSelection(default = "ask", choices = [
+ ("ask", _("Ask user")), ("movielist", _("Return to movie list")), ("quit", _("Return to previous service")), ("pause", _("Pause movie at end")) ])
+
config.usage.setup_level = ConfigSelection(default = "intermediate", choices = [
("simple", _("Simple")),
("intermediate", _("Intermediate")),
@@ -67,3 +73,50 @@ def InitUsageConfig():
SystemInfo["12V_Output"] = Misc_Options.getInstance().detected_12V_output()
config.usage.keymap = ConfigText(default = "/usr/share/enigma2/keymap.xml")
+
+ config.seek = ConfigSubsection()
+ config.seek.selfdefined_13 = ConfigNumber(default=15)
+ config.seek.selfdefined_46 = ConfigNumber(default=60)
+ config.seek.selfdefined_79 = ConfigNumber(default=300)
+
+ config.seek.speeds_forward = ConfigSet(default=[2, 4, 8, 16, 32, 64, 128], choices=[2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128])
+ config.seek.speeds_backward = ConfigSet(default=[2, 4, 8, 16, 32, 64, 128], choices=[1, 2, 4, 6, 8, 12, 16, 24, 32, 48, 64, 96, 128])
+ config.seek.speeds_slowmotion = ConfigSet(default=[2, 4, 8], choices=[2, 4, 6, 8, 12, 16, 25])
+
+ config.seek.enter_forward = ConfigSelection(default = "2", choices = ["2"])
+ config.seek.enter_backward = ConfigSelection(default = "2", choices = ["2"])
+ config.seek.stepwise_minspeed = ConfigSelection(default = "16", choices = ["Never", "2", "4", "6", "8", "12", "16", "24", "32", "48", "64", "96", "128"])
+ config.seek.stepwise_repeat = ConfigSelection(default = "3", choices = ["2", "3", "4", "5", "6"])
+
+ config.seek.on_pause = ConfigSelection(default = "play", choices = [
+ ("play", _("Play")),
+ ("step", _("Singlestep (GOP)")),
+ ("last", _("Last speed")) ])
+
+ def updateEnterForward(configElement):
+ if not configElement.value:
+ configElement.value = [2]
+ updateChoices(config.seek.enter_forward, configElement.value)
+
+ config.seek.speeds_forward.addNotifier(updateEnterForward)
+
+ def updateEnterBackward(configElement):
+ if not configElement.value:
+ configElement.value = [2]
+ updateChoices(config.seek.enter_backward, configElement.value)
+
+ config.seek.speeds_backward.addNotifier(updateEnterBackward)
+
+def updateChoices(sel, choices):
+ if choices:
+ defval = None
+ val = int(sel.value)
+ if not val in choices:
+ tmp = choices+[]
+ tmp.reverse()
+ for x in tmp:
+ if x < val:
+ defval = str(x)
+ break
+ sel.setChoices(map(str, choices), defval)
+
diff --git a/lib/python/Components/config.py b/lib/python/Components/config.py
index 861e70bf..59fb7255 100644
--- a/lib/python/Components/config.py
+++ b/lib/python/Components/config.py
@@ -133,6 +133,10 @@ def getKeyNumber(key):
class ConfigSelection(ConfigElement):
def __init__(self, choices, default = None):
ConfigElement.__init__(self)
+ self._value = None
+ self.setChoices(choices, default)
+
+ def setChoices(self, choices, default = None):
self.choices = []
self.description = {}
@@ -163,7 +167,10 @@ class ConfigSelection(ConfigElement):
for x in self.choices:
assert isinstance(x, str), "ConfigSelection choices must be strings"
- self.value = self.default = default
+ self.default = default
+
+ if self.value == None or not self.value in self.choices:
+ self.value = default
def setValue(self, value):
if value in self.choices:
@@ -699,7 +706,7 @@ class ConfigText(ConfigElement, NumericalTextInput):
_value = property(getValue, setValue)
def getText(self):
- return self.value
+ return self.text.encode("utf-8")
def getMulti(self, selected):
if self.visible_width:
@@ -713,7 +720,7 @@ class ConfigText(ConfigElement, NumericalTextInput):
mark = range(0, len(self.text))
else:
mark = [self.marked_pos]
- return ("mtext"[1-selected:], self.value+" ", mark)
+ return ("mtext"[1-selected:], self.text.encode("utf-8")+" ", mark)
def onSelect(self, session):
self.allmarked = (self.value != "")
@@ -735,6 +742,54 @@ class ConfigText(ConfigElement, NumericalTextInput):
def unsafeAssign(self, value):
self.value = str(value)
+class ConfigNumber(ConfigText):
+ def __init__(self, default = 0):
+ ConfigText.__init__(self, str(default), fixed_size = False)
+
+ def getValue(self):
+ return int(self.text)
+
+ def setValue(self, val):
+ self.text = str(val)
+
+ value = property(getValue, setValue)
+ _value = property(getValue, setValue)
+
+ def conform(self):
+ pos = len(self.text) - self.marked_pos
+ self.text = self.text.lstrip("0")
+ if self.text == "":
+ self.text = "0"
+ if pos > len(self.text):
+ self.marked_pos = 0
+ else:
+ self.marked_pos = len(self.text) - pos
+
+ def handleKey(self, key):
+ if key in KEY_NUMBERS or key == KEY_ASCII:
+ if key == KEY_ASCII:
+ ascii = getPrevAsciiCode()
+ if not (48 <= ascii <= 57):
+ return
+ else:
+ ascii = getKeyNumber(key) + 48
+ newChar = unichr(ascii)
+ if self.allmarked:
+ self.deleteAllChars()
+ self.allmarked = False
+ self.insertChar(newChar, self.marked_pos, False)
+ self.marked_pos += 1
+ else:
+ ConfigText.handleKey(self, key)
+ self.conform()
+
+ def onSelect(self, session):
+ self.allmarked = (self.value != "")
+
+ def onDeselect(self, session):
+ self.marked_pos = 0
+ self.offset = 0
+
# a slider.
class ConfigSlider(ConfigElement):
def __init__(self, default = 0, increment = 1, limits = (0, 100)):
@@ -968,6 +1023,77 @@ class ConfigSubsection(object):
def dict(self):
return self.content.items
+class ConfigSet(ConfigElement):
+ def __init__(self, choices, default = []):
+ ConfigElement.__init__(self)
+ choices.sort()
+ self.choices = choices
+ self.pos = -1
+ default.sort()
+ self.default = default
+ self.value = default+[]
+
+ def toggleChoice(self, choice):
+ if choice in self.value:
+ self.value.remove(choice)
+ else:
+ self.value.append(choice)
+ self.value.sort()
+
+ def handleKey(self, key):
+ if key in KEY_NUMBERS + [KEY_DELETE, KEY_BACKSPACE]:
+ if self.pos != -1:
+ self.toggleChoice(self.choices[self.pos])
+ elif key == KEY_LEFT:
+ self.pos -= 1
+ if self.pos < -1:
+ self.pos = len(self.choices)-1
+ elif key == KEY_RIGHT:
+ self.pos += 1
+ if self.pos >= len(self.choices):
+ self.pos = -1
+ elif key in [KEY_HOME, KEY_END]:
+ self.pos = -1
+
+ def genString(self, lst):
+ res = ""
+ for x in lst:
+ res += str(x)+" "
+ return res
+
+ def getText(self):
+ self.genString(self.value)
+
+ def getMulti(self, selected):
+ if not selected or self.pos == -1:
+ return ("text", self.genString(self.value))
+ else:
+ tmp = self.value+[]
+ ch = self.choices[self.pos]
+ mem = ch in self.value
+ if not mem:
+ tmp.append(ch)
+ tmp.sort()
+ ind = tmp.index(ch)
+ val1 = self.genString(tmp[:ind])
+ val2 = " "+self.genString(tmp[ind+1:])
+ if mem:
+ chstr = " "+str(ch)+" "
+ else:
+ chstr = "("+str(ch)+")"
+ return ("mtext", val1+chstr+val2, range(len(val1),len(val1)+len(chstr)))
+
+ def onDeselect(self, session):
+ self.pos = -1
+ self.changed()
+
+ def tostring(self, value):
+ return str(value)
+
+ def fromstring(self, val):
+ return eval(val)
+
+
# the root config object, which also can "pickle" (=serialize)
# down the whole config tree.
#