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
23 AFTEREVENT.NONE: _("do nothing"),
24 AFTEREVENT.DEEPSTANDBY: _("go to deep standby"),
25 AFTEREVENT.STANDBY: _("go to standby"),
26 AFTEREVENT.AUTO: _("auto")
29 class AutoTimerImportSelector(Screen):
30 def __init__(self, session, autotimer):
31 Screen.__init__(self, session)
32 self.skinName = "TimerEditList"
34 self.autotimer = autotimer
39 self["timerlist"] = TimerList(self.list)
41 self["key_red"] = Button(_("Cancel"))
42 self["key_green"] = Button(_("OK"))
43 self["key_yellow"] = Button("")
44 self["key_blue"] = Button("")
46 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
48 "ok": self.openImporter,
49 "cancel": self.cancel,
50 "green": self.openImporter,
53 self.onLayoutFinish.append(self.setCustomTitle)
55 def setCustomTitle(self):
56 self.setTitle(_("Select a Timer to Import"))
58 def fillTimerList(self):
62 for timer in self.session.nav.RecordTimer.timer_list:
63 l.append((timer, False))
65 for timer in self.session.nav.RecordTimer.processed_timers:
66 l.append((timer, True))
67 l.sort(key = lambda x: x[0].begin)
69 def importerClosed(self, ret):
75 def openImporter(self):
76 cur=self["timerlist"].getCurrent()
78 self.session.openWithCallback(
96 class AutoTimerImporter(Screen):
97 """Import AutoTimer from Timer"""
99 skin = """<screen name="AutoTimerImporter" title="Import AutoTimer" position="75,155" size="565,280">
100 <widget name="list" position="5,5" size="555,225" scrollbarMode="showOnDemand" />
101 <ePixmap position="0,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
102 <ePixmap position="140,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
103 <ePixmap position="280,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
104 <ePixmap position="420,235" zPosition="4" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
105 <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" />
106 <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" />
107 <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" />
108 <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" />
111 def __init__(self, session, autotimer, name, begin, end, disabled, sref, afterEvent, justplay, dirname, tags):
112 Screen.__init__(self, session)
115 self.autotimer = autotimer
118 self["key_red"] = Button(_("Cancel"))
119 self["key_green"] = Button(_("OK"))
120 self["key_yellow"] = Button()
121 self["key_blue"] = Button()
125 if disabled is not None:
127 SelectionEntryComponent(
128 ': '.join([_("Enabled"), {True: _("disable"), False: _("enable")}[bool(disabled)]]),
136 SelectionEntryComponent(
137 _("Match title: %s") % (name),
142 SelectionEntryComponent(
151 begin = localtime(begin)
154 SelectionEntryComponent(
155 _("Match Timespan: %02d:%02d - %02d:%02d") % (begin[3], begin[4], end[3], end[4]),
156 ((begin[3], begin[4]), (end[3], end[4])),
163 SelectionEntryComponent(
164 _("Only on Service: %s") % (sref.getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', '')),
170 if afterEvent is not None:
172 SelectionEntryComponent(
173 ': '.join([_("After event"), afterevent[afterEvent]]),
179 if justplay is not None:
181 SelectionEntryComponent(
182 ': '.join([_("Timer Type"), {0: _("record"), 1: _("zap")}[int(justplay)]]),
188 if dirname is not None:
190 SelectionEntryComponent(
191 ': '.join([_("Location"), dirname or "/hdd/movie/"]),
199 SelectionEntryComponent(
200 ': '.join([_("Tags"), ', '.join(tags)]),
206 self["list"] = SelectionList(list)
209 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
211 "ok": self["list"].toggleSelection,
212 "cancel": self.cancel,
217 self.onLayoutFinish.append(self.setCustomTitle)
219 def setCustomTitle(self):
220 self.setTitle(_("Import AutoTimer"))
223 self.session.openWithCallback(
226 _("Really close without saving settings?")
229 def cancelConfirm(self, ret):
233 def gotCustomMatch(self, ret):
235 self.autotimer.match = ret
236 # Check if we have a trailing whitespace
238 self.session.openWithCallback(
239 self.trailingWhitespaceRemoval,
241 _('You entered "%s" as Text to match.\nDo you want to remove trailing whitespaces?') % (ret)
250 def trailingWhitespaceRemoval(self, ret):
253 self.autotimer.match = self.autotimer.match.rstrip()
260 list = self["list"].getSelectionsList()
261 autotimer = self.autotimer
264 if item[2] == 0: # Enable
265 autotimer.enabled = item[1]
266 elif item[2] == 1: # Match
267 autotimer.match = item[1]
268 elif item[2] == 2: # Timespan
269 autotimer.timespan = item[1]
270 elif item[2] == 3: # Service
273 # strip all after last :
274 pos = value.rfind(':')
276 value = value[:pos+1]
278 autotimer.services = [value]
279 elif item[2] == 4: # AfterEvent
280 autotimer.afterevent = [(item[1], None)]
281 elif item[2] == 5: # Justplay
282 autotimer.justplay = item[1]
283 elif item[2] == 6: # Location
284 autotimer.destination = item[1]
285 elif item[2] == 7: # Tags
286 autotimer.tags = item[1]
287 elif item[2] == 8: # Exact match
288 autotimer.searchType = "exact"
289 autotimer.searchCase = "sensitive"
291 if autotimer.match == "":
292 self.session.openWithCallback(
295 title = _("Please provide a Text to match")