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
21 class EPGRefreshConfiguration(Screen, ConfigListScreen):
22 """Configuration of EPGRefresh"""
24 skin = """<screen name="AutoTimerEditor" title="Edit AutoTimer" position="center,center" size="565,350">
25 <ePixmap position="0,5" size="140,40" pixmap="skin_default/buttons/red.png" transparent="1" alphatest="on" />
26 <ePixmap position="140,5" size="140,40" pixmap="skin_default/buttons/green.png" transparent="1" alphatest="on" />
27 <ePixmap position="280,5" size="140,40" pixmap="skin_default/buttons/yellow.png" transparent="1" alphatest="on" />
28 <ePixmap position="420,5" size="140,40" pixmap="skin_default/buttons/blue.png" transparent="1" alphatest="on" />
29 <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" />
30 <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" />
31 <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" />
32 <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" />
33 <widget name="config" position="5,50" size="555,225" scrollbarMode="showOnDemand" />
34 <ePixmap pixmap="skin_default/div-h.png" position="0,275" zPosition="1" size="565,2" />
35 <widget source="help" render="Label" position="5,280" size="555,63" font="Regular;21" />
38 def __init__(self, session):
39 Screen.__init__(self, session)
42 self.setup_title = _("EPGRefresh Configuration")
43 self.onChangedEntry = []
45 # Although EPGRefresh keeps services in a Set we prefer a list
47 [x for x in epgrefresh.services[0]],
48 [x for x in epgrefresh.services[1]]
52 getConfigListEntry(_("Refresh automatically"), config.plugins.epgrefresh.enabled, _("Unless this is enabled EPGRefresh won't automatically run but has to be explicitely started through the yellow button from this menu.")),
53 getConfigListEntry(_("Wakeup from Deep-Standby to refresh EPG"), config.plugins.epgrefresh.wakeup, _("If this is enabled, the plugin will wake the receiver up from deep-standby if possible. Otherwise it has to be turned on already.")),
54 getConfigListEntry(_("Time to stay on service (in m)"), config.plugins.epgrefresh.interval, _("This is the ammount of time a channel will be active during a refresh.")),
55 getConfigListEntry(_("Refresh EPG after"), config.plugins.epgrefresh.begin, _("An automated refresh will happen after this time of day, but before the next setting.")),
56 getConfigListEntry(_("Refresh EPG before"), config.plugins.epgrefresh.end, _("An automated refresh will happen before this time of day, but after the previous setting.")),
57 getConfigListEntry(_("Delay when not in Standby (in m)"), config.plugins.epgrefresh.delay_standby, _("If the receiver is currently not in standby this is the amount of time EPGRefresh will wait before trying again.")),
58 getConfigListEntry(_("Force scan even if receiver is in use"), config.plugins.epgrefresh.force, _("This setting controls whether or not the refresh will also be initiated when the receiver is being used (namely not in standby or currently recording).")),
59 getConfigListEntry(_("Inherit Services from AutoTimer if available"), config.plugins.epgrefresh.inherit_autotimer, _("If you're also using the AutoTimer plugin this allows to extend the list of services to refresh by the services your AutoTimers are restricted to.")),
60 getConfigListEntry(_("Make AutoTimer parse EPG if available"), config.plugins.epgrefresh.parse_autotimer, _("If you're also using the AutoTimer plugin this will initiate a scan of the EPG after a completed refresh.")),
61 getConfigListEntry(_("Shutdown after refresh"), config.plugins.epgrefresh.afterevent, _("This setting controls if the receiver should be sent to deep-standby after a completed refresh.")),
64 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
65 self["config"].onSelectionChanged.append(self.updateHelp)
68 self["key_red"] = StaticText(_("Cancel"))
69 self["key_green"] = StaticText(_("OK"))
70 self["key_yellow"] = StaticText(_("Refresh now"))
71 self["key_blue"] = StaticText(_("Edit Services"))
73 self["help"] = StaticText()
76 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
78 "cancel": self.keyCancel,
80 "yellow": self.forceRefresh,
81 "blue": self.editServices
88 self.onLayoutFinish.append(self.setCustomTitle)
90 def setCustomTitle(self):
91 self.setTitle(_("Configure EPGRefresh"))
94 cur = self["config"].getCurrent()
96 self["help"].text = cur[2]
98 def forceRefresh(self):
99 epgrefresh.services = (set(self.services[0]), set(self.services[1]))
100 epgrefresh.forceRefresh(self.session)
102 def editServices(self):
103 self.session.openWithCallback(
104 self.editServicesCallback,
105 EPGRefreshServiceEditor,
109 def editServicesCallback(self, ret):
114 for x in self.onChangedEntry:
120 def getCurrentEntry(self):
121 return self["config"].getCurrent()[0]
123 def getCurrentValue(self):
124 return str(self["config"].getCurrent()[1].getText())
126 def createSummary(self):
129 def cancelConfirm(self, result):
133 for x in self["config"].list:
136 self.close(self.session)
139 if self["config"].isChanged():
140 from Screens.MessageBox import MessageBox
142 self.session.openWithCallback(
145 _("Really close without saving settings?")
148 self.close(self.session)
151 epgrefresh.services = (set(self.services[0]), set(self.services[1]))
152 epgrefresh.saveConfiguration()
154 for x in self["config"].list:
157 self.close(self.session)