2 from Screens.Screen import Screen
3 from Components.ConfigList import ConfigListScreen
4 from Screens.ChannelSelection import SimpleChannelSelection
7 from Screens.Setup import SetupSummary
10 from Components.ActionMap import ActionMap
11 from Components.Button import Button
14 from Components.config import getConfigListEntry, ConfigSelection
16 # Show ServiceName instead of ServiceReference
17 from ServiceReference import ServiceReference
19 class SimpleBouquetSelection(SimpleChannelSelection):
20 def __init__(self, session, title):
21 SimpleChannelSelection.__init__(self, session, title)
22 self.skinName = "SimpleChannelSelection"
24 def channelSelected(self): # just return selected service
25 ref = self.getCurrentSelection()
26 if (ref.flags & 7) == 7:
29 # We return the currently active path here
30 # Asking the user if this is what he wants might be better though
31 self.close(self.servicePath[-1])
33 class EPGRefreshServiceEditor(Screen, ConfigListScreen):
34 """Edit Services to be refreshed by EPGRefresh"""
36 skin = """<screen name="EPGRefreshServiceEditor" title="Edit Services to refresh" position="75,150" size="565,245">
37 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
38 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/key-red.png" transparent="1" alphatest="on" />
39 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/key-green.png" transparent="1" alphatest="on" />
40 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/key-yellow.png" transparent="1" alphatest="on" />
41 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/key-blue.png" transparent="1" alphatest="on" />
42 <widget name="key_red" position="5,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
43 <widget name="key_green" position="145,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
44 <widget name="key_yellow" position="285,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
45 <widget name="key_blue" position="425,205" zPosition="5" size="140,40" valign="center" halign="center" font="Regular;21" transparent="1" foregroundColor="white" shadowColor="black" shadowOffset="-1,-1" />
48 def __init__(self, session, services):
49 Screen.__init__(self, session)
52 self.setup_title = "EPGRefresh Services"
53 self.onChangedEntry = []
55 # We need to copy the list to be able to ignore changes
61 self.typeSelection = ConfigSelection(choices = [("channels", _("Channels")), ("bouquets", _("Bouquets"))])
62 self.typeSelection.addNotifier(self.refresh, initial_call = False)
66 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
69 self["key_red"] = Button(_("Cancel"))
70 self["key_green"] = Button(_("OK"))
71 self["key_yellow"] = Button(_("delete"))
72 self["key_blue"] = Button(_("New"))
75 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
77 "cancel": self.cancel,
79 "yellow": self.removeService,
80 "blue": self.newService
87 def saveCurrent(self):
88 del self.services[self.idx][:]
90 # Warning, accessing a ConfigListEntry directly might be considered evil!
92 myl = self["config"].getList()
95 self.services[self.idx].append(item[1].value)
97 def refresh(self, value):
101 self["config"].setList(self.list)
103 def reloadList(self):
105 getConfigListEntry(_("Editing"), self.typeSelection)
108 if self.typeSelection.value == "channels":
110 else: # self.typeSelection.value == "bouquets":
114 getConfigListEntry(_("Refreshing"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
115 for x in self.services[self.idx]
119 for x in self.onChangedEntry:
125 def getCurrentEntry(self):
126 cur = self["config"].getCurrent()
131 def getCurrentValue(self):
132 cur = self["config"].getCurrent()
134 return str(cur[1].getText())
137 def createSummary(self):
140 def removeService(self):
141 cur = self["config"].getCurrent()
143 list = self["config"].getList()
145 self["config"].setList(list)
147 def newService(self):
148 if self.typeSelection.value == "channels":
149 self.session.openWithCallback(
150 self.finishedServiceSelection,
151 SimpleChannelSelection,
152 _("Select channel to refresh")
154 else: # self.typeSelection.value == "bouquets":
155 self.session.openWithCallback(
156 self.finishedServiceSelection,
157 SimpleBouquetSelection,
158 _("Select bouquet to refresh")
161 def finishedServiceSelection(self, *args):
163 list = self["config"].getList()
164 list.append(getConfigListEntry(
166 ConfigSelection(choices = [(args[0].toString(), ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))])
168 self["config"].setList(list)
176 self.close(self.services)