1 # for localized messages
5 from Screens.Screen import Screen
6 from Components.ConfigList import ConfigListScreen
7 from EPGRefreshChannelEditor import EPGRefreshServiceEditor
10 from Screens.Setup import SetupSummary
13 from Components.ActionMap import ActionMap
14 from Components.Sources.StaticText import StaticText
17 from Components.config import config, getConfigListEntry
19 from EPGRefresh import epgrefresh
20 from Components.SystemInfo import SystemInfo
22 class EPGRefreshConfiguration(Screen, ConfigListScreen):
23 """Configuration of EPGRefresh"""
25 skin = """<screen name="EPGRefreshConfiguration" title="Configure EPGRefresh" position="center,center" size="565,370">
26 <ePixmap position="0,5" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
27 <ePixmap position="140,5" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
28 <ePixmap position="280,5" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
29 <ePixmap position="420,5" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
30 <widget source="key_red" render="Label" position="0,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
31 <widget source="key_green" render="Label" position="140,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
32 <widget source="key_yellow" render="Label" position="280,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
33 <widget source="key_blue" render="Label" position="420,5" zPosition="1" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
34 <widget name="config" position="5,50" size="555,250" scrollbarMode="showOnDemand" />
35 <ePixmap pixmap="skin_default/div-h.png" position="0,301" zPosition="1" size="565,2" />
36 <widget source="help" render="Label" position="5,305" size="555,63" font="Regular;21" />
39 def __init__(self, session):
40 Screen.__init__(self, session)
43 self.setup_title = _("EPGRefresh Configuration")
44 self.onChangedEntry = []
46 # Although EPGRefresh keeps services in a Set we prefer a list
48 [x for x in epgrefresh.services[0]],
49 [x for x in epgrefresh.services[1]]
53 getConfigListEntry(_("Refresh EPG automatically"), config.plugins.epgrefresh.enabled, _("Unless this is enabled, EPGRefresh won't automatically run but needs to be explicitly started by the yellow button in this menu.")),
54 getConfigListEntry(_("Show popup when refresh starts and ends"), config.plugins.epgrefresh.enablemessage, _("This setting controls whether or not an informational message will be shown at start and completion of refresh.")),
55 getConfigListEntry(_("Wake up from deep standby for EPG refresh"), config.plugins.epgrefresh.wakeup, _("If this is enabled, the plugin will wake up the receiver from deep standby if possible. Otherwise it needs to be switched on already.")),
56 getConfigListEntry(_("Duration to stay on service-channels (minutes)"), config.plugins.epgrefresh.interval, _("This is the duration each service/channel will stay active during a refresh.")),
57 getConfigListEntry(_("EPG refresh auto-start earliest (hh:mm)"), config.plugins.epgrefresh.begin, _("An automated refresh will start after this time of day, but before the time specified in next setting.")),
58 getConfigListEntry(_("EPG refresh auto-start latest (hh:mm)"), config.plugins.epgrefresh.end, _("An automated refresh will start before this time of day, but after the time specified in previous setting.")),
59 getConfigListEntry(_("Delay if not in standby (minutes)"), config.plugins.epgrefresh.delay_standby, _("If the receiver currently isn't in standby, this is the duration which EPGRefresh will wait before retry.")),
60 getConfigListEntry(_("Force scan even if receiver is in use"), config.plugins.epgrefresh.force, _("This setting controls whether or not the refresh will be initiated even though the receiver is active (either not in standby or currently recording).")),
61 getConfigListEntry(_("Shutdown after EPG refresh"), config.plugins.epgrefresh.afterevent, _("This setting controls whether the receiver should be set to deep standby after refresh is completed.")),
63 if SystemInfo.get("NumVideoDecoders", 1) > 1:
64 self.list.insert(2, getConfigListEntry(_("Refresh EPG using"), config.plugins.epgrefresh.adapter, _("If you want to refresh the EPG in background, you can choose a way that better suits your needs here, e.g. hidden, fake recording or regular Picture in Picture.")))
67 # try to import autotimer module to check for its existence
68 from Plugins.Extensions.AutoTimer.AutoTimer import AutoTimer
70 self.list.append(getConfigListEntry(_("Inherit Services from AutoTimer"), config.plugins.epgrefresh.inherit_autotimer, _("Extend the list of services to refresh by those your AutoTimers use?")))
71 self.list.append(getConfigListEntry(_("Run AutoTimer after refresh"), config.plugins.epgrefresh.parse_autotimer, _("After a successful refresh the AutoTimer will automatically search for new matches if this is enabled.")))
72 except ImportError, ie:
73 print "[EPGRefresh] AutoTimer Plugin not installed:", ie
75 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
76 def selectionChanged():
77 if self["config"].current:
78 self["config"].current[1].onDeselect(self.session)
79 self["config"].current = self["config"].getCurrent()
80 if self["config"].current:
81 self["config"].current[1].onSelect(self.session)
82 for x in self["config"].onSelectionChanged:
84 self["config"].selectionChanged = selectionChanged
85 self["config"].onSelectionChanged.append(self.updateHelp)
88 self["key_red"] = StaticText(_("Cancel"))
89 self["key_green"] = StaticText(_("OK"))
90 self["key_yellow"] = StaticText(_("Refresh now"))
91 self["key_blue"] = StaticText(_("Edit Services"))
93 self["help"] = StaticText()
96 self["actions"] = ActionMap(["SetupActions", "ColorActions", "ChannelSelectEPGActions"],
98 "cancel": self.keyCancel,
100 "yellow": self.forceRefresh,
101 "blue": self.editServices,
102 "showEPGList": self.keyInfo,
109 self.onLayoutFinish.append(self.setCustomTitle)
111 def setCustomTitle(self):
112 self.setTitle(_("Configure EPGRefresh"))
114 def updateHelp(self):
115 cur = self["config"].getCurrent()
117 self["help"].text = cur[2]
119 def forceRefresh(self):
120 epgrefresh.services = (set(self.services[0]), set(self.services[1]))
121 epgrefresh.forceRefresh(self.session)
123 def editServices(self):
124 self.session.openWithCallback(
125 self.editServicesCallback,
126 EPGRefreshServiceEditor,
130 def editServicesCallback(self, ret):
135 for x in self.onChangedEntry:
141 def getCurrentEntry(self):
142 return self["config"].getCurrent()[0]
144 def getCurrentValue(self):
145 return str(self["config"].getCurrent()[1].getText())
147 def createSummary(self):
150 def cancelConfirm(self, result):
154 for x in self["config"].list:
157 self.close(self.session)
160 from Screens.MessageBox import MessageBox
162 lastscan = config.plugins.epgrefresh.lastscan.value
164 from Tools.FuzzyDate import FuzzyTime
165 scanDate = ', '.join(FuzzyTime(lastscan))
167 scanDate = _("never")
171 _("Last refresh was %s") % (scanDate,),
172 type=MessageBox.TYPE_INFO
176 if self["config"].isChanged():
177 from Screens.MessageBox import MessageBox
179 self.session.openWithCallback(
182 _("Really close without saving settings?")
185 self.close(self.session)
188 epgrefresh.services = (set(self.services[0]), set(self.services[1]))
189 epgrefresh.saveConfiguration()
191 for x in self["config"].list:
194 self.close(self.session)