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"].text = 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 <ePixmap position="0,0" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
55 <ePixmap position="140,0" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
56 <ePixmap position="280,0" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
57 <ePixmap position="422,10" zPosition="1" size="35,25" pixmap="skin_default/buttons/key_menu.png" alphatest="on" />
58 <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" />
59 <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" />
60 <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" />
61 <widget name="entries" position="5,45" size="450,225" scrollbarMode="showOnDemand" />
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["entries"].onSelectionChanged.append(self.selectionChanged)
86 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
88 "ok": (self.ok, _("Edit selected AutoTimer")),
89 "cancel": (self.cancel, _("Close and forget changes")),
93 self["MenuActions"] = HelpableActionMap(self, "MenuActions",
95 "menu": (self.menu, _("Open Context Menu"))
99 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
101 "green": (self.save, _("Close and save changes")),
102 "yellow": (self.remove, _("Remove selected AutoTimer")),
103 "blue": (self.add, _("Add new AutoTimer")),
107 self.onLayoutFinish.append(self.setCustomTitle)
109 def setCustomTitle(self):
110 self.setTitle(_("AutoTimer overview"))
112 def createSummary(self):
113 return AutoTimerOverviewSummary
115 def selectionChanged(self):
116 sel = self["entries"].getCurrent()
117 text = sel and sel.name or ""
118 for x in self.onChangedEntry:
125 newTimer = self.autotimer.defaultTimer.clone()
126 newTimer.id = self.autotimer.getUniqueId()
128 if config.plugins.autotimer.editor.value == "wizard":
129 self.session.openWithCallback(
135 self.session.openWithCallback(
141 def editCallback(self, ret):
146 def addCallback(self, ret):
149 self.autotimer.add(ret)
152 def importCallback(self, ret):
154 self.session.openWithCallback(
160 def refresh(self, res = None):
162 cur = self["entries"].getCurrent()
163 self["entries"].setList(self.autotimer.getSortedTupleTimerList())
164 self["entries"].moveToEntry(cur)
167 # Edit selected Timer
168 current = self["entries"].getCurrent()
169 if current is not None:
170 self.session.openWithCallback(
177 # Remove selected Timer
178 cur = self["entries"].getCurrent()
180 self.session.openWithCallback(
183 _("Do you really want to delete %s?") % (cur.name),
186 def removeCallback(self, ret):
187 cur = self["entries"].getCurrent()
189 self.autotimer.remove(cur.id)
194 self.session.openWithCallback(
197 _("Really close without saving settings?")
202 def cancelConfirm(self, ret):
204 # Invalidate config mtime to force re-read on next run
205 self.autotimer.configMtime = -1
207 # Close and indicated that we canceled by returning None
212 (_("Preview"), "preview"),
213 (_("Import existing Timer"), "import"),
214 (_("Import from EPG"), "import_epg"),
215 (_("Setup"), "setup"),
216 (_("Edit new timer defaults"), "defaults"),
219 if config.plugins.autotimer.editor.value == "wizard":
220 list.append((_("Create a new timer using the classic editor"), "newplain"))
222 list.append((_("Create a new timer using the wizard"), "newwizard"))
224 self.session.openWithCallback(
230 def menuCallback(self, ret):
234 total, new, modified, timers = self.autotimer.parseEPG(simulateOnly = True)
239 elif ret == "import":
240 newTimer = self.autotimer.defaultTimer.clone()
241 newTimer.id = self.autotimer.getUniqueId()
243 self.session.openWithCallback(
245 AutoTimerImportSelector,
248 elif ret == "import_epg":
249 self.session.openWithCallback(
251 AutoTimerChannelSelection,
258 elif ret == "defaults":
261 self.autotimer.defaultTimer,
262 editingDefaults = True
264 elif ret == "newwizard":
265 newTimer = self.autotimer.defaultTimer.clone()
266 newTimer.id = self.autotimer.getUniqueId()
268 self.session.openWithCallback(
269 self.addCallback, # XXX: we could also use importCallback... dunno what seems more natural
273 elif ret == "newplain":
274 newTimer = self.autotimer.defaultTimer.clone()
275 newTimer.id = self.autotimer.getUniqueId()
277 self.session.openWithCallback(
284 # Just close here, saving will be done by cb
285 self.close(self.session)