1 from Screen import Screen
2 from Components.Button import Button
3 from Components.ServiceList import ServiceList
4 from Components.ActionMap import ActionMap
6 from enigma import eServiceReference
8 from Screens.FixedMenu import FixedMenu
10 import xml.dom.minidom
12 class ChannelContextMenu(FixedMenu):
13 def __init__(self, session, csel):
16 menu = [("back", self.close)]
19 menu.append(("disable move mode", self.moveMode))
21 menu.append(("enable move mode", self.moveMode))
23 if csel.bouquet_mark_edit:
24 menu.append(("end bouquet edit", self.bouquetMarkEnd))
25 menu.append(("abort bouquet edit", self.bouquetMarkAbort))
27 menu.append(("edit bouquet...", self.bouquetMarkStart))
29 FixedMenu.__init__(self, session, "Channel Selection", menu)
30 self.skinName = "Menu"
33 self.csel.setMoveMode(self.csel.movemode)
36 def bouquetMarkStart(self):
37 self.csel.startMarkedEdit()
40 def bouquetMarkEnd(self):
41 self.csel.endMarkedEdit(abort=False)
44 def bouquetMarkAbort(self):
45 self.csel.endMarkedEdit(abort=True)
48 class ChannelSelection(Screen):
49 def __init__(self, session):
50 Screen.__init__(self, session)
52 self.entry_marked = False
54 self.bouquet_mark_edit = False
59 self["key_red"] = Button("All")
60 self["key_green"] = Button("Provider")
61 self["key_yellow"] = Button("Satellite")
62 self["key_blue"] = Button("Favourites")
64 self["list"] = ServiceList()
65 self["list"].setRoot(eServiceReference("""1:0:1:0:0:0:0:0:0:0:(type == 1)"""))
67 #self["okbutton"] = Button("ok", [self.channelSelected])
69 class ChannelActionMap(ActionMap):
70 def action(self, contexts, action):
71 if action[:7] == "bouquet":
73 l.setMode(l.MODE_NORMAL)
74 l.setRoot(eServiceReference("1:0:1:0:0:0:0:0:0:0:" + action[8:]))
76 ActionMap.action(self, contexts, action)
78 self["actions"] = ChannelActionMap(["ChannelSelectActions", "OkCancelActions"],
81 "ok": self.channelSelected,
83 "contextMenu": self.doContext,
84 "showFavourites": self.showFavourites
86 self["actions"].csel = self
90 def startMarkedEdit(self):
91 self.bouquet_mark_edit = True
95 marked = self.__marked
101 def endMarkedEdit(self, abort):
102 self.bouquet_mark_edit = True
103 new_marked = self["list"].getMarked()
104 self.__marked = new_marked
106 self.bouquet_mark_edit = False
108 def clearMarks(self):
109 self["list"].clearMarks()
112 if not self.bouquet_mark_edit:
115 ref = self["list"].getCurrent()
116 if self["list"].isMarked(ref):
117 self["list"].removeMarked(ref)
119 self["list"].addMarked(ref)
122 def channelSelected(self):
123 ref = self["list"].getCurrent()
125 if self.entry_marked:
126 self["list"].setCurrentMarked(False)
127 self.entry_marked = False
129 self["list"].setCurrentMarked(True)
130 self.entry_marked = True
131 elif (ref.flags & 7) == 7:
133 l.setMode(l.MODE_NORMAL)
136 self.session.nav.playService(ref)
141 self.session.nav.playService(self["list"].getCurrent())
144 self["list"].moveUp()
147 self["list"].moveDown()
150 self.session.open(ChannelContextMenu, self)
152 def setMoveMode(self, mode):
154 self.movemode = False
158 def getCurrent(self):
159 return self["list"].getCurrent()
161 def showFavourites(self):
163 l.setRoot(eServiceReference('1:0:1:0:0:0:0:0:0:0:(provider == "fav")'))
164 l.setMode(l.MODE_FAVOURITES)