1 # for localized messages
5 from Screens.Screen import Screen
6 from Screens.MessageBox import MessageBox
7 from Screens.InputBox import InputBox
10 from Components.ActionMap import ActionMap
11 from Components.Button import Button
12 from Components.TimerList import TimerList
13 from Components.SelectionList import SelectionList, SelectionEntryComponent
16 from RecordTimer import AFTEREVENT
18 # Needed to convert our timestamp back and forth
19 from time import localtime
21 afterevent = { AFTEREVENT.NONE: _("do nothing"), AFTEREVENT.DEEPSTANDBY: _("go to deep standby"), AFTEREVENT.STANDBY: _("go to standby")}
23 class AutoTimerImportSelector(Screen):
24 def __init__(self, session, autotimer):
25 Screen.__init__(self, session)
26 self.skinName = "TimerEditList"
28 self.autotimer = autotimer
33 self["timerlist"] = TimerList(self.list)
35 self["key_red"] = Button(_("Cancel"))
36 self["key_green"] = Button(_("OK"))
37 self["key_yellow"] = Button("")
38 self["key_blue"] = Button("")
40 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
42 "ok": self.openImporter,
43 "cancel": self.cancel,
44 "green": self.openImporter,
47 self.onLayoutFinish.append(self.setCustomTitle)
49 def setCustomTitle(self):
50 self.setTitle(_("Select a Timer to Import"))
52 def fillTimerList(self):
55 for timer in self.session.nav.RecordTimer.timer_list:
56 self.list.append((timer, False))
58 for timer in self.session.nav.RecordTimer.processed_timers:
59 self.list.append((timer, True))
60 self.list.sort(cmp = lambda x, y: x[0].begin < y[0].begin)
62 def importerClosed(self, ret):
68 def openImporter(self):
69 cur=self["timerlist"].getCurrent()
71 self.session.openWithCallback(
88 class AutoTimerImporter(Screen):
89 """Import AutoTimer from Timer"""
91 skin = """<screen name="AutoTimerImporter" title="Import AutoTimer" position="75,155" size="565,280">
92 <widget name="list" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
93 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
94 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
95 <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
96 <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
97 <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" />
98 <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" />
99 <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" />
100 <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" />
103 def __init__(self, session, autotimer, name, begin, end, disabled, sref, afterEvent, justplay, dirname):
104 Screen.__init__(self, session)
107 self.autotimer = autotimer
110 self["key_red"] = Button(_("Cancel"))
111 self["key_green"] = Button(_("OK"))
112 self["key_yellow"] = Button()
113 self["key_blue"] = Button()
117 if disabled is not None:
119 SelectionEntryComponent(
120 ': '.join([_("Enabled"), {True: _("disable"), False: _("enable")}[bool(disabled)]]),
128 SelectionEntryComponent(
129 _("Match title: %s") % (name),
136 begin = localtime(begin)
139 SelectionEntryComponent(
140 _("Match Timespan: %02d:%02d - %02d:%02d") % (begin[3], begin[4], end[3], end[4]),
141 ((begin[3], begin[4]), (end[3], end[4])),
148 SelectionEntryComponent(
149 _("Only on Service: %s") % (sref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '')),
155 if afterEvent is not None:
157 SelectionEntryComponent(
158 ': '.join([_("After event"), afterevent[afterEvent]]),
164 if justplay is not None:
166 SelectionEntryComponent(
167 ': '.join([_("Timer Type"), {0: _("record"), 1: _("zap")}[int(justplay)]]),
173 if dirname is not None:
175 SelectionEntryComponent(
176 ': '.join([_("Location"), dirname or "/hdd/movie/"]),
182 self["list"] = SelectionList(list)
185 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
187 "ok": self["list"].toggleSelection,
188 "cancel": self.cancel,
194 self.session.openWithCallback(
197 _("Really close without saving settings?")
200 def cancelConfirm(self, ret):
204 def gotCustomMatch(self, ret):
206 self.autotimer.match = ret
207 # Check if we have a trailing whitespace
209 self.session.openWithCallback(
210 self.trailingWhitespaceRemoval,
212 _('You entered "%s" as Text to match.\nDo you want to remove trailing whitespaces?') % (ret)
221 def trailingWhitespaceRemoval(self, ret):
224 self.autotimer.match = self.autotimer.match.rstrip()
231 list = self["list"].getSelectionsList()
234 if item[2] == 0: # Enable
235 self.autotimer.enabled = item[1]
236 elif item[2] == 1: # Match
237 self.autotimer.match = item[1]
238 elif item[2] == 2: # Timespan
239 self.autotimer.timespan = item[1]
240 elif item[2] == 3: # Service
243 # strip all after last :
244 pos = value.rfind(':')
246 value = value[:pos+1]
248 self.autotimer.services = [value]
249 elif item[2] == 4: # AfterEvent
250 self.autotimer.afterevent = [(item[1], None)]
251 elif item[2] == 5: # Justplay
252 self.autotimer.justplay = item[1]
253 elif item[2] == 6: # Location
254 self.autotimer.destination = item[1]
256 if self.autotimer.match == "":
257 self.session.openWithCallback(
260 title = _("Please provide a Text to match")