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.Button import Button
19 from Components.config import config
22 from AutoTimerComponent import AutoTimerComponent
24 class AutoTimerOverview(Screen, HelpableScreen):
25 """Overview of AutoTimers"""
27 skin = """<screen name="AutoTimerOverview" position="140,148" size="460,265" title="AutoTimer Overview">
28 <widget name="entries" position="5,5" size="450,200" scrollbarMode="showOnDemand" />
29 <ePixmap position="0,220" zPosition="1" size="140,40" pixmap="skin_default/buttons/green.png" alphatest="on" />
30 <ePixmap position="140,220" zPosition="1" size="140,40" pixmap="skin_default/buttons/yellow.png" alphatest="on" />
31 <ePixmap position="280,220" zPosition="1" size="140,40" pixmap="skin_default/buttons/blue.png" alphatest="on" />
32 <ePixmap position="422,230" zPosition="1" size="35,25" pixmap="skin_default/buttons/key_menu.png" alphatest="on" />
33 <widget name="key_green" position="0,220" zPosition="2" size="140,40" halign="center" valign="center" font="Regular;21" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
34 <widget name="key_yellow" position="140,220" zPosition="2" size="140,40" halign="center" valign="center" font="Regular;21" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
35 <widget name="key_blue" position="280,220" zPosition="2" size="140,40" halign="center" valign="center" font="Regular;21" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
38 def __init__(self, session, autotimer):
39 Screen.__init__(self, session)
40 HelpableScreen.__init__(self)
43 self.autotimer = autotimer
48 self["key_green"] = Button(_("Save"))
49 self["key_yellow"] = Button(_("Delete"))
50 self["key_blue"] = Button(_("Add"))
52 # Create List of Timers
53 self["entries"] = AutoTimerList(self.autotimer.getTupleTimerList())
56 self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
58 "ok": (self.ok, _("Edit selected AutoTimer")),
59 "cancel": (self.cancel, _("Close and forget changes")),
63 self["MenuActions"] = HelpableActionMap(self, "MenuActions",
65 "menu": (self.menu, _("Open Context Menu"))
69 self["ColorActions"] = HelpableActionMap(self, "ColorActions",
71 "green": (self.save, _("Close and save changes")),
72 "yellow": (self.remove, _("Remove selected AutoTimer")),
73 "blue": (self.add, _("Add new AutoTimer")),
77 self.onLayoutFinish.append(self.setCustomTitle)
79 def setCustomTitle(self):
80 self.setTitle(_("AutoTimer Overview"))
83 newTimer = self.autotimer.defaultTimer.clone()
84 newTimer.id = self.autotimer.getUniqueId()
86 if config.plugins.autotimer.editor.value == "wizard":
87 self.session.openWithCallback(
93 self.session.openWithCallback(
99 def editCallback(self, ret):
104 def addCallback(self, ret):
107 self.autotimer.add(ret)
110 def importCallback(self, ret):
112 self.session.openWithCallback(
118 def refresh(self, res = None):
120 cur = self["entries"].getCurrent()
121 self["entries"].setList(self.autotimer.getSortedTupleTimerList())
122 self["entries"].moveToEntry(cur)
125 # Edit selected Timer
126 current = self["entries"].getCurrent()
127 if current is not None:
128 self.session.openWithCallback(
135 # Remove selected Timer
136 cur = self["entries"].getCurrent()
138 self.session.openWithCallback(
141 _("Do you really want to delete %s?") % (cur.name),
144 def removeCallback(self, ret):
145 cur = self["entries"].getCurrent()
147 self.autotimer.remove(cur.id)
152 self.session.openWithCallback(
155 _("Really close without saving settings?")
160 def cancelConfirm(self, ret):
162 # Invalidate config mtime to force re-read on next run
163 self.autotimer.configMtime = -1
165 # Close and indicated that we canceled by returning None
170 (_("Preview"), "preview"),
171 (_("Import existing Timer"), "import"),
172 (_("Import from EPG"), "import_epg"),
173 (_("Setup"), "setup"),
174 (_("Edit new timer defaults"), "defaults"),
177 if config.plugins.autotimer.editor.value == "wizard":
178 list.append((_("Create a new timer using the classic editor"), "newplain"))
180 list.append((_("Create a new timer using the wizard"), "newwizard"))
182 self.session.openWithCallback(
188 def menuCallback(self, ret):
192 total, new, modified, timers = self.autotimer.parseEPG(simulateOnly = True)
197 elif ret == "import":
198 newTimer = self.autotimer.defaultTimer.clone()
199 newTimer.id = self.autotimer.getUniqueId()
201 self.session.openWithCallback(
203 AutoTimerImportSelector,
206 elif ret == "import_epg":
208 AutoTimerChannelSelection,
215 elif ret == "defaults":
218 self.autotimer.defaultTimer,
219 editingDefaults = True
221 elif ret == "newwizard":
222 newTimer = self.autotimer.defaultTimer.clone()
223 newTimer.id = self.autotimer.getUniqueId()
225 self.session.openWithCallback(
226 self.addCallback, # XXX: we could also use importCallback... dunno what seems more natural
230 elif ret == "newplain":
231 newTimer = self.autotimer.defaultTimer.clone()
232 newTimer.id = self.autotimer.getUniqueId()
234 self.session.openWithCallback(
241 # Just close here, saving will be done by cb
242 self.close(self.session)