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
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")),
78 newTimer = self.autotimer.defaultTimer.clone()
79 newTimer.id = self.autotimer.getUniqueId()
81 if config.plugins.autotimer.editor.value == "wizard":
82 self.session.openWithCallback(
88 self.session.openWithCallback(
94 def editCallback(self, ret):
99 def addCallback(self, ret):
102 self.autotimer.add(ret)
105 def importCallback(self, ret):
107 self.session.openWithCallback(
113 def refresh(self, res = None):
115 cur = self["entries"].getCurrent()
116 self["entries"].setList(self.autotimer.getSortedTupleTimerList())
117 self["entries"].moveToEntry(cur)
120 # Edit selected Timer
121 current = self["entries"].getCurrent()
122 if current is not None:
123 self.session.openWithCallback(
130 # Remove selected Timer
131 cur = self["entries"].getCurrent()
133 self.session.openWithCallback(
136 _("Do you really want to delete %s?") % (cur.name),
139 def removeCallback(self, ret):
140 cur = self["entries"].getCurrent()
142 self.autotimer.remove(cur.id)
147 self.session.openWithCallback(
150 _("Really close without saving settings?")
155 def cancelConfirm(self, ret):
157 # Invalidate config mtime to force re-read on next run
158 self.autotimer.configMtime = -1
160 # Close and indicated that we canceled by returning None
165 (_("Preview"), "preview"),
166 (_("Import"), "import"),
167 (_("Setup"), "setup"),
168 (_("Edit new timer defaults"), "defaults"),
171 if config.plugins.autotimer.editor.value == "wizard":
172 list.append((_("Create a new timer using the classic editor"), "newplain"))
174 list.append((_("Create a new timer using the wizard"), "newwizard"))
176 self.session.openWithCallback(
182 def menuCallback(self, ret):
186 total, new, modified, timers = self.autotimer.parseEPG(simulateOnly = True)
191 elif ret == "import":
192 newTimer = self.autotimer.defaultTimer.clone()
193 newTimer.id = self.autotimer.getUniqueId()
195 self.session.openWithCallback(
197 AutoTimerImportSelector,
204 elif ret == "defaults":
207 self.autotimer.defaultTimer,
208 editingDefaults = True
210 elif ret == "newwizard":
211 newTimer = self.autotimer.defaultTimer.clone()
212 newTimer.id = self.autotimer.getUniqueId()
214 self.session.openWithCallback(
215 self.addCallback, # XXX: we could also use importCallback... dunno what seems more natural
219 elif ret == "newplain":
220 newTimer = self.autotimer.defaultTimer.clone()
221 newTimer.id = self.autotimer.getUniqueId()
223 self.session.openWithCallback(
230 # Just close here, saving will be done by cb
231 self.close(self.session)