1 # for localized messages
5 from Screens.Screen import Screen
6 from Screens.HelpMenu import HelpableScreen
7 from Screens.MessageBox import MessageBox
8 from Screens.ChoiceBox import ChoiceBox
9 from AutoTimerEditor import AutoTimerEditor, AutoTimerChannelSelection
10 from AutoTimerSettings import AutoTimerSettings
11 from AutoTimerPreview import AutoTimerPreview
12 from AutoTimerImporter import AutoTimerImportSelector
13 from AutoTimerWizard import AutoTimerWizard
16 from AutoTimerList import AutoTimerList
17 from Components.ActionMap import HelpableActionMap
18 from Components.config import config
19 from Components.Sources.StaticText import StaticText
22 from AutoTimerComponent import AutoTimerComponent
24 class AutoTimerOverviewSummary(Screen):
26 <screen position="0,0" size="132,64">
27 <widget source="parent.title" render="Label" position="6,4" size="120,21" font="Regular;18" />
28 <widget source="entry" render="Label" position="6,25" size="120,21" font="Regular;16" />
29 <widget source="global.CurrentTime" render="Label" position="56,46" size="82,18" font="Regular;16" >
30 <convert type="ClockToText">WithSeconds</convert>
34 def __init__(self, session, parent):
35 Screen.__init__(self, session, parent = parent)
36 self["entry"] = StaticText("")
37 self.onShow.append(self.addWatcher)
38 self.onHide.append(self.removeWatcher)
41 self.parent.onChangedEntry.append(self.selectionChanged)
42 self.parent.selectionChanged()
44 def removeWatcher(self):
45 self.parent.onChangedEntry.remove(self.selectionChanged)
47 def selectionChanged(self, text):
48 self["entry"].setText(text)
50 class AutoTimerOverview(Screen, HelpableScreen):
51 """Overview of AutoTimers"""
53 skin = """<screen name="AutoTimerOverview" position="center,center" size="460,280" title="AutoTimer Overview">
54 <widget name="entries" position="5,5" size="450,225" scrollbarMode="showOnDemand" />
55 <ePixmap position="0,235" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
56 <ePixmap position="140,235" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
57 <ePixmap position="280,235" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
58 <ePixmap position="422,245" zPosition="1" size="35,25" pixmap="skin_default/buttons/key_menu.png" alphatest="on" />
59 <widget source="key_green" render="Label" position="0,235" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
60 <widget source="key_yellow" render="Label" position="140,235" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
61 <widget source="key_blue" render="Label" position="280,235" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
64 def __init__(self, session, autotimer):
65 Screen.__init__(self, session)
66 HelpableScreen.__init__(self)
69 self.autotimer = autotimer
74 self["key_green"] = StaticText(_("Save"))
75 self["key_yellow"] = StaticText(_("Delete"))
76 self["key_blue"] = StaticText(_("Add"))
78 # Create List of Timers
79 self["entries"] = AutoTimerList(autotimer.getSortedTupleTimerList())
82 self.onChangedEntry = []
83 self["title"] = StaticText()
84 self["entries"].onSelectionChanged.append(self.selectionChanged)
87 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
89 "ok": (self.ok, _("Edit selected AutoTimer")),
90 "cancel": (self.cancel, _("Close and forget changes")),
94 self["MenuActions"] = HelpableActionMap(self, "MenuActions",
96 "menu": (self.menu, _("Open Context Menu"))
100 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
102 "green": (self.save, _("Close and save changes")),
103 "yellow": (self.remove, _("Remove selected AutoTimer")),
104 "blue": (self.add, _("Add new AutoTimer")),
108 self.onLayoutFinish.append(self.setCustomTitle)
110 def setTitle(self, title):
111 Screen.setTitle(self, title)
112 self["title"].setText(title)
114 def setCustomTitle(self):
115 self.setTitle(_("AutoTimer Overview"))
117 def createSummary(self):
118 return AutoTimerOverviewSummary
120 def selectionChanged(self):
121 sel = self["entries"].getCurrent()
122 text = sel and sel.name or ""
123 for x in self.onChangedEntry:
130 newTimer = self.autotimer.defaultTimer.clone()
131 newTimer.id = self.autotimer.getUniqueId()
133 if config.plugins.autotimer.editor.value == "wizard":
134 self.session.openWithCallback(
140 self.session.openWithCallback(
146 def editCallback(self, ret):
151 def addCallback(self, ret):
154 self.autotimer.add(ret)
157 def importCallback(self, ret):
159 self.session.openWithCallback(
165 def refresh(self, res = None):
167 cur = self["entries"].getCurrent()
168 self["entries"].setList(self.autotimer.getSortedTupleTimerList())
169 self["entries"].moveToEntry(cur)
172 # Edit selected Timer
173 current = self["entries"].getCurrent()
174 if current is not None:
175 self.session.openWithCallback(
182 # Remove selected Timer
183 cur = self["entries"].getCurrent()
185 self.session.openWithCallback(
188 _("Do you really want to delete %s?") % (cur.name),
191 def removeCallback(self, ret):
192 cur = self["entries"].getCurrent()
194 self.autotimer.remove(cur.id)
199 self.session.openWithCallback(
202 _("Really close without saving settings?")
207 def cancelConfirm(self, ret):
209 # Invalidate config mtime to force re-read on next run
210 self.autotimer.configMtime = -1
212 # Close and indicated that we canceled by returning None
217 (_("Preview"), "preview"),
218 (_("Import existing Timer"), "import"),
219 (_("Import from EPG"), "import_epg"),
220 (_("Setup"), "setup"),
221 (_("Edit new timer defaults"), "defaults"),
224 if config.plugins.autotimer.editor.value == "wizard":
225 list.append((_("Create a new timer using the classic editor"), "newplain"))
227 list.append((_("Create a new timer using the wizard"), "newwizard"))
229 self.session.openWithCallback(
235 def menuCallback(self, ret):
239 total, new, modified, timers = self.autotimer.parseEPG(simulateOnly = True)
244 elif ret == "import":
245 newTimer = self.autotimer.defaultTimer.clone()
246 newTimer.id = self.autotimer.getUniqueId()
248 self.session.openWithCallback(
250 AutoTimerImportSelector,
253 elif ret == "import_epg":
254 self.session.openWithCallback(
256 AutoTimerChannelSelection,
263 elif ret == "defaults":
266 self.autotimer.defaultTimer,
267 editingDefaults = True
269 elif ret == "newwizard":
270 newTimer = self.autotimer.defaultTimer.clone()
271 newTimer.id = self.autotimer.getUniqueId()
273 self.session.openWithCallback(
274 self.addCallback, # XXX: we could also use importCallback... dunno what seems more natural
278 elif ret == "newplain":
279 newTimer = self.autotimer.defaultTimer.clone()
280 newTimer.id = self.autotimer.getUniqueId()
282 self.session.openWithCallback(
289 # Just close here, saving will be done by cb
290 self.close(self.session)