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 # TODO: we could just accept the current path here....
30 print "[BouquetSelector] Dunno what to do, no directory selected:", ref," :-/"
32 class EPGRefreshServiceEditor(Screen, ConfigListScreen):
33 """Edit Services to be refreshed by EPGRefresh"""
35 skin = """<screen name="EPGRefreshServiceEditor" title="Edit Services to refresh" position="75,150" size="565,245">
36 <widget name="config" position="5,5" size="555,200" scrollbarMode="showOnDemand" />
37 <ePixmap position="5,205" zPosition="4" size="140,40" pixmap="skin_default/key-red.png" transparent="1" alphatest="on" />
38 <ePixmap position="145,205" zPosition="4" size="140,40" pixmap="skin_default/key-green.png" transparent="1" alphatest="on" />
39 <ePixmap position="285,205" zPosition="4" size="140,40" pixmap="skin_default/key-yellow.png" transparent="1" alphatest="on" />
40 <ePixmap position="425,205" zPosition="4" size="140,40" pixmap="skin_default/key-blue.png" transparent="1" alphatest="on" />
41 <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" />
42 <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" />
43 <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" />
44 <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" />
47 def __init__(self, session, services):
48 Screen.__init__(self, session)
51 self.setup_title = "EPGRefresh Services"
52 self.onChangedEntry = []
54 # We need to copy the list to be able to ignore changes
60 self.typeSelection = ConfigSelection(choices = [("channels", _("Channels")), ("bouquets", _("Bouquets"))])
61 self.typeSelection.addNotifier(self.refresh, initial_call = False)
65 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
68 self["key_red"] = Button(_("Cancel"))
69 self["key_green"] = Button(_("OK"))
70 self["key_yellow"] = Button(_("delete"))
71 self["key_blue"] = Button(_("New"))
74 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
76 "cancel": self.cancel,
78 "yellow": self.removeService,
79 "blue": self.newService
86 def saveCurrent(self):
87 del self.services[self.idx][:]
89 # Warning, accessing a ConfigListEntry directly might be considered evil!
91 myl = self["config"].getList()
94 self.services[self.idx].append(item[1].value)
96 def refresh(self, value):
100 self["config"].setList(self.list)
102 def reloadList(self):
104 getConfigListEntry(_("Editing"), self.typeSelection)
107 if self.typeSelection.value == "channels":
109 else: # self.typeSelection.value == "bouquets":
113 getConfigListEntry(_("Refreshing"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
114 for x in self.services[self.idx]
118 for x in self.onChangedEntry:
124 def getCurrentEntry(self):
125 cur = self["config"].getCurrent()
130 def getCurrentValue(self):
131 cur = self["config"].getCurrent()
133 return str(cur[1].getText())
136 def createSummary(self):
139 def removeService(self):
140 cur = self["config"].getCurrent()
142 list = self["config"].getList()
144 self["config"].setList(list)
146 def newService(self):
147 if self.typeSelection.value == "channels":
148 self.session.openWithCallback(
149 self.finishedServiceSelection,
150 SimpleChannelSelection,
151 _("Select channel to refresh")
153 else: # self.typeSelection.value == "bouquets":
154 self.session.openWithCallback(
155 self.finishedServiceSelection,
156 SimpleBouquetSelection,
157 _("Select bouquet to refresh")
160 def finishedServiceSelection(self, *args):
162 list = self["config"].getList()
163 list.append(getConfigListEntry(
165 ConfigSelection(choices = [(args[0].toString(), ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))])
167 self["config"].setList(list)
175 self.close(self.services)