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 EPGRefreshChannelEditor(Screen, ConfigListScreen):
33 """Edit Services to be refreshed by EPGRefresh"""
35 skin = """<screen name="EPGRefreshChannelEditor" 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 self.services = services
56 self.typeSelection = ConfigSelection(choices = [("channels", _("Channels")), ("bouquets", _("Bouquets"))])
57 self.typeSelection.addNotifier(self.refresh, initial_call = False)
61 ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changed)
64 self["key_red"] = Button(_("Cancel"))
65 self["key_green"] = Button(_("OK"))
66 self["key_yellow"] = Button(_("delete"))
67 self["key_blue"] = Button(_("New"))
70 self["actions"] = ActionMap(["SetupActions", "ColorActions"],
72 "cancel": self.cancel,
74 "yellow": self.removeChannel,
75 "blue": self.newChannel
82 def saveCurrent(self):
83 del self.services[self.idx][:]
85 # Warning, accessing a ConfigListEntry directly might be considered evil!
87 myl = self["config"].getList()
90 self.services[self.idx].append(item[1].value)
92 def refresh(self, value):
96 self["config"].setList(self.list)
100 getConfigListEntry(_("Editing"), self.typeSelection)
103 if self.typeSelection.value == "channels":
106 getConfigListEntry(_("Refreshing"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
107 for x in self.services[0]
109 else: # self.typeSelection.value == "bouquets":
112 getConfigListEntry(_("Refreshing"), ConfigSelection(choices = [(str(x), ServiceReference(str(x)).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))]))
113 for x in self.services[1]
117 for x in self.onChangedEntry:
123 def getCurrentEntry(self):
124 cur = self["config"].getCurrent()
129 def getCurrentValue(self):
130 cur = self["config"].getCurrent()
132 return str(cur[1].getText())
135 def createSummary(self):
138 def removeChannel(self):
139 cur = self["config"].getCurrent()
141 list = self["config"].getList()
143 self["config"].setList(list)
145 def newChannel(self):
146 if self.typeSelection.value == "channels":
147 self.session.openWithCallback(
148 self.finishedChannelSelection,
149 SimpleChannelSelection,
150 _("Select channel to refresh")
152 else: # self.typeSelection.value == "bouquets":
153 self.session.openWithCallback(
154 self.finishedChannelSelection,
155 SimpleBouquetSelection,
156 _("Select bouquet to refresh")
159 def finishedChannelSelection(self, *args):
161 list = self["config"].getList()
162 list.append(getConfigListEntry(_("Refreshing"), ConfigSelection(choices = [(args[0].toString(), ServiceReference(args[0]).getServiceName().replace('\xc2\x86', '').replace('\xc2\x87', ''))])))
163 self["config"].setList(list)
171 self.close(self.services)