1 # -*- coding: UTF-8 -*-
2 # for localized messages
6 from Screens.Screen import Screen
7 from Screens.MessageBox import MessageBox
8 from Screens.InputBox import InputBox
11 from Components.ActionMap import ActionMap
12 from Components.Button import Button
13 from Components.TimerList import TimerList
14 from Components.SelectionList import SelectionList, SelectionEntryComponent
17 from RecordTimer import AFTEREVENT
19 # Needed to convert our timestamp back and forth
20 from time import localtime
22 afterevent = { AFTEREVENT.NONE: _("do nothing"), AFTEREVENT.DEEPSTANDBY: _("go to deep standby"), AFTEREVENT.STANDBY: _("go to standby")}
24 class AutoTimerImportSelector(Screen):
25 def __init__(self, session, autotimer):
26 Screen.__init__(self, session)
27 self.skinName = "TimerEditList"
29 self.autotimer = autotimer
34 self["timerlist"] = TimerList(self.list)
36 self["key_red"] = Button(_("Cancel"))
37 self["key_green"] = Button(_("OK"))
38 self["key_yellow"] = Button("")
39 self["key_blue"] = Button("")
41 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
43 "ok": self.openImporter,
44 "cancel": self.cancel,
45 "green": self.openImporter,
48 self.onLayoutFinish.append(self.setCustomTitle)
50 def setCustomTitle(self):
51 self.setTitle(_("Select a Timer to Import"))
53 def fillTimerList(self):
56 for timer in self.session.nav.RecordTimer.timer_list:
57 self.list.append((timer, False))
59 for timer in self.session.nav.RecordTimer.processed_timers:
60 self.list.append((timer, True))
61 self.list.sort(cmp = lambda x, y: x[0].begin < y[0].begin)
63 def importerClosed(self, ret):
69 def openImporter(self):
70 cur=self["timerlist"].getCurrent()
72 self.session.openWithCallback(
89 class AutoTimerImporter(Screen):
90 """Import AutoTimer from Timer"""
92 skin = """<screen name="AutoTimerImporter" title="Import AutoTimer" position="75,155" size="565,280">
93 <widget name="list" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
94 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
95 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
96 <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
97 <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
98 <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" />
99 <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" />
100 <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" />
101 <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" />
104 def __init__(self, session, autotimer, name, begin, end, disabled, sref, afterEvent, justplay, dirname):
105 Screen.__init__(self, session)
108 self.autotimer = autotimer
111 self["key_red"] = Button(_("Cancel"))
112 self["key_green"] = Button(_("OK"))
113 self["key_yellow"] = Button()
114 self["key_blue"] = Button()
118 if disabled is not None:
120 SelectionEntryComponent(
121 ': '.join([_("Enabled"), {True: _("disable"), False: _("enable")}[bool(disabled)]]),
129 SelectionEntryComponent(
130 _("Match title: %s") % (name),
137 begin = localtime(begin)
140 SelectionEntryComponent(
141 _("Match Timespan: %02d:%02d - %02d:%02d") % (begin[3], begin[4], end[3], end[4]),
142 ((begin[3], begin[4]), (end[3], end[4])),
149 SelectionEntryComponent(
150 _("Only on Service: %s") % (sref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '')),
156 if afterEvent is not None:
158 SelectionEntryComponent(
159 ': '.join([_("After event"), afterevent[afterEvent]]),
165 if justplay is not None:
167 SelectionEntryComponent(
168 ': '.join([_("Timer Type"), {0: _("record"), 1: _("zap")}[int(justplay)]]),
174 if dirname is not None:
176 SelectionEntryComponent(
177 ': '.join([_("Location"), dirname or "/hdd/movie/"]),
183 self["list"] = SelectionList(list)
186 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
188 "ok": self["list"].toggleSelection,
189 "cancel": self.cancel,
195 self.session.openWithCallback(
198 _("Really close without saving settings?")
201 def cancelConfirm(self, ret):
205 def gotCustomMatch(self, ret):
207 self.autotimer.match = ret
208 # Check if we have a trailing whitespace
210 self.session.openWithCallback(
211 self.trailingWhitespaceRemoval,
213 _('You entered "%s" as Text to match.\nDo you want to remove trailing whitespaces?') % (ret)
222 def trailingWhitespaceRemoval(self, ret):
225 self.autotimer.match = self.autotimer.match.rstrip()
232 list = self["list"].getSelectionsList()
235 if item[2] == 0: # Enable
236 self.autotimer.enabled = item[1]
237 elif item[2] == 1: # Match
238 self.autotimer.match = item[1]
239 elif item[2] == 2: # Timespan
240 self.autotimer.timespan = item[1]
241 elif item[2] == 3: # Service
244 # strip all after last :
245 pos = value.rfind(':')
247 value = value[:pos+1]
249 self.autotimer.services = [value]
250 elif item[2] == 4: # AfterEvent
251 self.autotimer.afterevent = [(item[1], None)]
252 elif item[2] == 5: # Justplay
253 self.autotimer.justplay = item[1]
254 elif item[2] == 6: # Location
255 self.autotimer.destination = item[1]
257 if self.autotimer.match == "":
258 self.session.openWithCallback(
261 title = _("Please provide a Text to match")