+# -*- coding: UTF-8 -*-
+# for localized messages
+from . import _
+
# GUI (Screens)
from Screens.Screen import Screen
from Screens.MessageBox import MessageBox
# GUI (Components)
from Components.ActionMap import ActionMap
from Components.Button import Button
-from Components.TimerList import TimerList
from Components.SelectionList import SelectionList, SelectionEntryComponent
+from Components.Sources.StaticText import StaticText
+from Components.TimerList import TimerList
# Timer
from RecordTimer import AFTEREVENT
# Needed to convert our timestamp back and forth
from time import localtime
-afterevent = { AFTEREVENT.NONE: _("do nothing"), AFTEREVENT.DEEPSTANDBY: _("go to deep standby"), AFTEREVENT.STANDBY: _("go to standby")}
+from enigma import eServiceReference
+
+afterevent = {
+ AFTEREVENT.NONE: _("do nothing"),
+ AFTEREVENT.DEEPSTANDBY: _("go to deep standby"),
+ AFTEREVENT.STANDBY: _("go to standby"),
+ AFTEREVENT.AUTO: _("auto")
+}
class AutoTimerImportSelector(Screen):
def __init__(self, session, autotimer):
self.onLayoutFinish.append(self.setCustomTitle)
def setCustomTitle(self):
- self.setTitle(_("Select a Timer to Import"))
+ self.setTitle(_("Select a timer to import"))
def fillTimerList(self):
- del self.list[:]
-
- for timer in self.session.nav.RecordTimer.timer_list:
- self.list.append((timer, False))
+ l = self.list
+ del l[:]
- for timer in self.session.nav.RecordTimer.processed_timers:
- self.list.append((timer, True))
- self.list.sort(cmp = lambda x, y: x[0].begin < y[0].begin)
+ l.extend([(timer, False) for timer in self.session.nav.RecordTimer.timer_list])
+ l.extend([(timer, True) for timer in self.session.nav.RecordTimer.processed_timers])
+ l.sort(key = lambda x: x[0].begin)
def importerClosed(self, ret):
+ ret = ret and ret[0]
if ret is not None:
ret.name = ret.match
self.close(ret)
self.session.openWithCallback(
self.importerClosed,
AutoTimerImporter,
- cur,
- self.autotimer
+ self.autotimer,
+ cur.name,
+ cur.begin,
+ cur.end,
+ cur.disabled,
+ cur.service_ref,
+ cur.afterEvent,
+ cur.justplay,
+ cur.dirname,
+ cur.tags
)
def cancel(self):
class AutoTimerImporter(Screen):
"""Import AutoTimer from Timer"""
- skin = """<screen name="AutoTimerImporter" title="Import AutoTimer" position="75,155" size="565,280">
- <widget name="list" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
- <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/key-red.png" transparent="1" alphatest="on" />
- <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/key-green.png" transparent="1" alphatest="on" />
- <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/key-yellow.png" transparent="1" alphatest="on" />
- <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/key-blue.png" transparent="1" alphatest="on" />
- <widget name="key_red" position="0,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
- <widget name="key_green" position="140,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
- <widget name="key_yellow" position="280,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
- <widget name="key_blue" position="420,235" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+ skin = """<screen name="AutoTimerImporter" title="Import AutoTimer" position="center,center" size="565,290">
+ <ePixmap position="0,0" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
+ <ePixmap position="140,0" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
+ <ePixmap position="280,0" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
+ <ePixmap position="420,0" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
+ <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+ <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+ <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+ <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
+ <widget name="list" position="5,45" size="555,240" scrollbarMode="showOnDemand" />
</screen>"""
- def __init__(self, session, timer, autotimer):
+ def __init__(self, session, autotimer, name, begin, end, disabled, sref, afterEvent, justplay, dirname, tags):
Screen.__init__(self, session)
# Keep AutoTimer
self.autotimer = autotimer
# Initialize Buttons
- self["key_red"] = Button(_("Cancel"))
- self["key_green"] = Button(_("OK"))
- self["key_yellow"] = Button()
- self["key_blue"] = Button()
-
- begin = localtime(timer.begin)
- end = localtime(timer.end)
- list = [
- SelectionEntryComponent(
- _("Match title: %s") % (timer.name),
- timer.name,
- 0,
- True
- ),
- SelectionEntryComponent(
- _("Match Timespan: %02d:%02d - %02d:%02d") % (begin[3], begin[4], end[3], end[4]),
- ((begin[3], begin[4]), (end[3], end[4])),
- 1,
- True
- ),
- SelectionEntryComponent(
- _("Only on Service: %s") % (timer.service_ref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '')),
- str(timer.service_ref),
- 2,
- True
- ),
- SelectionEntryComponent(
- _("AfterEvent: %s") % (afterevent[timer.afterEvent]),
- timer.afterEvent,
- 3,
- True
- )
- ]
+ self["key_red"] = StaticText(_("Cancel"))
+ self["key_green"] = StaticText(_("OK"))
+ self["key_yellow"] = StaticText()
+ self["key_blue"] = StaticText()
+
+ list = []
+
+ if disabled is not None:
+ list.append(
+ SelectionEntryComponent(
+ ': '.join((_("Enabled"), {True: _("disable"), False: _("enable")}[bool(disabled)])),
+ not disabled,
+ 0,
+ True
+ ))
+
+ if name != "":
+ list.extend([
+ SelectionEntryComponent(
+ _("Match title: %s") % (name),
+ name,
+ 1,
+ True
+ ),
+ SelectionEntryComponent(
+ _("Exact match"),
+ True,
+ 8,
+ True
+ )
+ ])
+
+ if begin and end:
+ begin = localtime(begin)
+ end = localtime(end)
+ list.append(
+ SelectionEntryComponent(
+ _("Match Timespan: %02d:%02d - %02d:%02d") % (begin[3], begin[4], end[3], end[4]),
+ ((begin[3], begin[4]), (end[3], end[4])),
+ 2,
+ True
+ ))
+
+ if sref:
+ list.append(
+ SelectionEntryComponent(
+ _("Only on Service: %s") % (sref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '')),
+ str(sref),
+ 3,
+ True
+ ))
+
+ if afterEvent is not None:
+ list.append(
+ SelectionEntryComponent(
+ ': '.join((_("After event"), afterevent[afterEvent])),
+ afterEvent,
+ 4,
+ True
+ ))
+
+ if justplay is not None:
+ list.append(
+ SelectionEntryComponent(
+ ': '.join((_("Timer type"), {0: _("record"), 1: _("zap")}[int(justplay)])),
+ int(justplay),
+ 5,
+ True
+ ))
+
+ if dirname is not None:
+ list.append(
+ SelectionEntryComponent(
+ ': '.join((_("Location"), dirname or "/hdd/movie/")),
+ dirname,
+ 6,
+ True
+ ))
+
+ if tags:
+ list.append(
+ SelectionEntryComponent(
+ ': '.join((_("Tags"), ', '.join(tags))),
+ tags,
+ 7,
+ True
+ ))
self["list"] = SelectionList(list)
# Define Actions
- self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
+ self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
{
"ok": self["list"].toggleSelection,
"cancel": self.cancel,
"green": self.accept
}, -1)
+ self.onLayoutFinish.append(self.setCustomTitle)
+
+ def setCustomTitle(self):
+ self.setTitle(_("Import AutoTimer"))
+
def cancel(self):
- self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
+ self.session.openWithCallback(
+ self.cancelConfirm,
+ MessageBox,
+ _("Really close without saving settings?")
+ )
def cancelConfirm(self, ret):
if ret:
)
# Just confirm else
else:
- self.close(self.autotimer)
+ self.close((
+ self.autotimer,
+ self.session
+ ))
def trailingWhitespaceRemoval(self, ret):
if ret is not None:
if ret:
self.autotimer.match = self.autotimer.match.rstrip()
- self.close(self.autotimer)
+ self.close((
+ self.autotimer,
+ self.session
+ ))
def accept(self):
list = self["list"].getSelectionsList()
+ autotimer = self.autotimer
for item in list:
- if item[2] == 0: # Match (should maybe be forced?)
- self.autotimer.match = item[1]
- if item[2] == 1: # Timespan
- self.autotimer.timespan = item[1]
- if item[2] == 2: # Service
+ if item[2] == 0: # Enable
+ autotimer.enabled = item[1]
+ elif item[2] == 1: # Match
+ autotimer.match = item[1]
+ elif item[2] == 2: # Timespan
+ autotimer.timespan = item[1]
+ elif item[2] == 3: # Service
value = item[1]
- # strip all after last :
- pos = value.rfind(':')
- if pos != -1:
- value = value[:pos+1]
-
- self.autotimer.services = [value]
- if item[2] == 3: # AfterEvent
- self.autotimer.afterevent = [(item[1], None)]
-
- if self.autotimer.match == "":
+ myref = eServiceReference(value)
+ if not (myref.flags & eServiceReference.isGroup):
+ # strip all after last :
+ pos = value.rfind(':')
+ if pos != -1:
+ if value[pos-1] == ':':
+ pos -= 1
+ value = value[:pos+1]
+
+ autotimer.services = [value]
+ elif item[2] == 4: # AfterEvent
+ autotimer.afterevent = [(item[1], None)]
+ elif item[2] == 5: # Justplay
+ autotimer.justplay = item[1]
+ elif item[2] == 6: # Location
+ autotimer.destination = item[1]
+ elif item[2] == 7: # Tags
+ autotimer.tags = item[1]
+ elif item[2] == 8: # Exact match
+ autotimer.searchType = "exact"
+ autotimer.searchCase = "sensitive"
+
+ if autotimer.match == "":
self.session.openWithCallback(
self.gotCustomMatch,
InputBox,
- title = _("Please provide a Text to Match")
+ title = _("Please provide a Text to match")
)
else:
- self.close(self.autotimer)
+ self.close((
+ autotimer,
+ self.session
+ ))
+