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
21 class AutoTimerOverviewSummary(Screen):
23 <screen position="0,0" size="132,64">
24 <widget source="parent.Title" render="Label" position="6,4" size="120,21" font="Regular;18" />
25 <widget source="entry" render="Label" position="6,25" size="120,21" font="Regular;16" />
26 <widget source="global.CurrentTime" render="Label" position="56,46" size="82,18" font="Regular;16" >
27 <convert type="ClockToText">WithSeconds</convert>
31 def __init__(self, session, parent):
32 Screen.__init__(self, session, parent = parent)
33 self["entry"] = StaticText("")
34 self.onShow.append(self.addWatcher)
35 self.onHide.append(self.removeWatcher)
38 self.parent.onChangedEntry.append(self.selectionChanged)
39 self.parent.selectionChanged()
41 def removeWatcher(self):
42 self.parent.onChangedEntry.remove(self.selectionChanged)
44 def selectionChanged(self, text):
45 self["entry"].text = text
47 class AutoTimerOverview(Screen, HelpableScreen):
48 """Overview of AutoTimers"""
50 skin = """<screen name="AutoTimerOverview" position="center,center" size="460,280" title="AutoTimer Overview">
51 <ePixmap position="0,0" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
52 <ePixmap position="140,0" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
53 <ePixmap position="280,0" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
54 <ePixmap position="422,10" zPosition="1" size="35,25" pixmap="skin_default/buttons/key_menu.png" alphatest="on" />
55 <widget source="key_green" 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" />
56 <widget source="key_yellow" 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" />
57 <widget source="key_blue" 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" />
58 <widget name="entries" position="5,45" size="450,225" scrollbarMode="showOnDemand" />
61 def __init__(self, session, autotimer):
62 Screen.__init__(self, session)
63 HelpableScreen.__init__(self)
66 self.autotimer = autotimer
71 self["key_green"] = StaticText(_("Save"))
72 self["key_yellow"] = StaticText(_("Delete"))
73 self["key_blue"] = StaticText(_("Add"))
75 # Create List of Timers
76 self["entries"] = AutoTimerList(autotimer.getSortedTupleTimerList())
79 self.onChangedEntry = []
80 self["entries"].onSelectionChanged.append(self.selectionChanged)
83 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
85 "ok": (self.ok, _("Edit selected AutoTimer")),
86 "cancel": (self.cancel, _("Close and forget changes")),
90 self["MenuActions"] = HelpableActionMap(self, "MenuActions",
92 "menu": (self.menu, _("Open Context Menu"))
96 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
98 "green": (self.save, _("Close and save changes")),
99 "yellow": (self.remove, _("Remove selected AutoTimer")),
100 "blue": (self.add, _("Add new AutoTimer")),
104 self.onLayoutFinish.append(self.setCustomTitle)
106 def setCustomTitle(self):
107 self.setTitle(_("AutoTimer overview"))
109 def createSummary(self):
110 return AutoTimerOverviewSummary
112 def selectionChanged(self):
113 sel = self["entries"].getCurrent()
114 text = sel and sel.name or ""
115 for x in self.onChangedEntry:
122 newTimer = self.autotimer.defaultTimer.clone()
123 newTimer.id = self.autotimer.getUniqueId()
125 if config.plugins.autotimer.editor.value == "wizard":
126 self.session.openWithCallback(
132 self.session.openWithCallback(
138 def editCallback(self, ret):
143 def addCallback(self, ret):
146 self.autotimer.add(ret)
149 def importCallback(self, ret):
151 self.session.openWithCallback(
157 def refresh(self, res = None):
159 cur = self["entries"].getCurrent()
160 self["entries"].setList(self.autotimer.getSortedTupleTimerList())
161 self["entries"].moveToEntry(cur)
164 # Edit selected Timer
165 current = self["entries"].getCurrent()
166 if current is not None:
167 self.session.openWithCallback(
174 # Remove selected Timer
175 cur = self["entries"].getCurrent()
177 self.session.openWithCallback(
180 _("Do you really want to delete %s?") % (cur.name),
183 def removeCallback(self, ret):
184 cur = self["entries"].getCurrent()
186 self.autotimer.remove(cur.id)
191 self.session.openWithCallback(
194 _("Really close without saving settings?")
199 def cancelConfirm(self, ret):
201 # Invalidate config mtime to force re-read on next run
202 self.autotimer.configMtime = -1
204 # Close and indicated that we canceled by returning None
209 (_("Preview"), "preview"),
210 (_("Import existing Timer"), "import"),
211 (_("Import from EPG"), "import_epg"),
212 (_("Setup"), "setup"),
213 (_("Edit new timer defaults"), "defaults"),
216 if config.plugins.autotimer.editor.value == "wizard":
217 list.append((_("Create a new timer using the classic editor"), "newplain"))
219 list.append((_("Create a new timer using the wizard"), "newwizard"))
221 self.session.openWithCallback(
227 def menuCallback(self, ret):
231 total, new, modified, timers = self.autotimer.parseEPG(simulateOnly = True)
236 elif ret == "import":
237 newTimer = self.autotimer.defaultTimer.clone()
238 newTimer.id = self.autotimer.getUniqueId()
240 self.session.openWithCallback(
242 AutoTimerImportSelector,
245 elif ret == "import_epg":
246 self.session.openWithCallback(
248 AutoTimerChannelSelection,
255 elif ret == "defaults":
258 self.autotimer.defaultTimer,
259 editingDefaults = True
261 elif ret == "newwizard":
262 newTimer = self.autotimer.defaultTimer.clone()
263 newTimer.id = self.autotimer.getUniqueId()
265 self.session.openWithCallback(
266 self.addCallback, # XXX: we could also use importCallback... dunno what seems more natural
270 elif ret == "newplain":
271 newTimer = self.autotimer.defaultTimer.clone()
272 newTimer.id = self.autotimer.getUniqueId()
274 self.session.openWithCallback(
281 # Just close here, saving will be done by cb
282 self.close(self.session)