2 from Screens.Screen import Screen
3 from Screens.MessageBox import MessageBox
4 from Screens.ChoiceBox import ChoiceBox
5 from AutoTimerEditor import AutoTimerEditor
6 from AutoTimerConfiguration import AutoTimerConfiguration
7 from AutoTimerPreview import AutoTimerPreview
8 from AutoTimerImporter import AutoTimerImportSelector
11 from AutoTimerList import AutoTimerList
12 from Components.ActionMap import ActionMap
13 from Components.Button import Button
16 from AutoTimerComponent import AutoTimerComponent
18 class AutoTimerOverview(Screen):
19 """Overview of AutoTimers"""
21 skin = """<screen name="AutoTimerOverview" position="140,148" size="460,265" title="AutoTimer Overview">
22 <widget name="entries" position="5,5" size="450,200" scrollbarMode="showOnDemand" />
23 <ePixmap position="0,220" zPosition="1" size="140,40" pixmap="skin_default/buttons/green.png" alphatest="on" />
24 <ePixmap position="140,220" zPosition="1" size="140,40" pixmap="skin_default/buttons/yellow.png" alphatest="on" />
25 <ePixmap position="280,220" zPosition="1" size="140,40" pixmap="skin_default/buttons/blue.png" alphatest="on" />
26 <ePixmap position="422,230" zPosition="1" size="35,25" pixmap="skin_default/buttons/key_menu.png" alphatest="on" />
27 <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" />
28 <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" />
29 <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" />
32 def __init__(self, session, autotimer):
33 Screen.__init__(self, session)
36 self.autotimer = autotimer
41 self["key_green"] = Button(_("Save"))
42 self["key_yellow"] = Button(_("Delete"))
43 self["key_blue"] = Button(_("Add"))
45 # Create List of Timers
46 self["entries"] = AutoTimerList(self.autotimer.getTupleTimerList())
49 self["actions"] = ActionMap(["OkCancelActions", "MenuActions", "ColorActions"],
52 "cancel": self.cancel,
54 "yellow": self.remove,
61 newTimer = self.autotimer.defaultTimer.clone()
62 newTimer.id = self.autotimer.getUniqueId()
64 self.session.openWithCallback(
70 def editCallback(self, ret):
75 def addCallback(self, ret):
78 self.autotimer.add(ret)
81 def importCallback(self, ret):
83 self.session.openWithCallback(
89 def refresh(self, res = None):
91 self["entries"].setList(self.autotimer.getTupleTimerList())
95 current = self["entries"].getCurrent()
96 if current is not None:
97 self.session.openWithCallback(
104 # Remove selected Timer
105 cur = self["entries"].getCurrent()
107 self.session.openWithCallback(
110 _("Do you really want to delete %s?") % (cur[0].name),
113 def removeCallback(self, ret):
114 cur = self["entries"].getCurrent()
116 self.autotimer.remove(cur[0].id)
121 self.session.openWithCallback(
124 _("Really close without saving settings?")
129 def cancelConfirm(self, ret):
131 # Invalidate config mtime to force re-read on next run
132 self.autotimer.configMtime = -1
134 # Close and indicated that we canceled by returning None
138 self.session.openWithCallback(
142 (_("Preview"), "preview"),
143 (_("Import"), "import"),
144 (_("Setup"), "setup"),
145 (_("Edit new timer defaults"), "defaults")
149 def menuCallback(self, ret):
153 total, new, modified, timers = self.autotimer.parseEPG(simulateOnly = True)
158 elif ret == "import":
159 # XXX: apply defaults here too?
160 self.session.openWithCallback(
162 AutoTimerImportSelector,
164 self.autotimer.getUniqueId(), # Id
172 AutoTimerConfiguration
174 elif ret == "defaults":
177 self.autotimer.defaultTimer,
178 editingDefaults = True
182 # Just close here, saving will be done by cb
183 self.close(self.session)