show real satellite name in satellite list
[enigma2.git] / lib / python / Components / ServiceList.py
1 from HTMLComponent import *
2 from GUIComponent import *
3
4 from enigma import *
5
6 from string import upper
7
8 class ServiceList(HTMLComponent, GUIComponent):
9
10         MODE_NORMAL = 0
11         MODE_FAVOURITES = 1
12
13         def __init__(self):
14                 GUIComponent.__init__(self)
15                 self.l = eListboxServiceContent()
16                 self.root = None
17                 
18                 self.mode = self.MODE_NORMAL
19
20         def setCurrent(self, ref):
21                 self.l.setCurrent(ref)
22
23         def getCurrent(self):
24                 r = eServiceReference()
25                 self.l.getCurrent(r)
26                 return r
27
28         def moveUp(self):
29                 self.instance.moveSelection(self.instance.moveUp)
30
31         def moveDown(self):
32                 self.instance.moveSelection(self.instance.moveDown)
33                 
34         def moveToChar(self, char):
35                 # TODO fill with life
36                 print "Next char: "
37                 index = self.l.getNextBeginningWithChar(char)
38                 indexup = self.l.getNextBeginningWithChar(upper(char))
39                 if indexup != 0:
40                         if (index > indexup or index == 0):
41                                 index = indexup
42
43                 self.instance.moveSelectionTo(index)
44                 print "Moving to character " + str(char)
45
46         def moveToIndex(self, index):
47                 self.instance.moveSelectionTo(index)
48
49         def getCurrentIndex(self):
50                 return self.instance.getCurrentIndex()
51
52         def GUIcreate(self, parent):
53                 self.instance = eListbox(parent)
54                 self.instance.setContent(self.l)
55                 self.setMode(self.mode)
56         
57         def GUIdelete(self):
58                 self.instance = None
59
60         def getRoot(self):
61                 return self.root
62
63         def getRootServices(self):
64                 serviceHandler = eServiceCenter.getInstance()
65                 list = serviceHandler.list(self.root)
66                 dest = [ ]
67                 if list is not None:
68                         while 1:
69                                 s = list.getNext()
70                                 if s.valid():
71                                         dest.append(s.toString())
72                                 else:
73                                         break
74                 return dest
75
76         def setNumberOffset(self, offset):
77                 self.l.setNumberOffset(offset)
78
79         def setPlayableIgnoreService(self, ref):
80                 self.l.setIgnoreService(ref)
81
82         def setRoot(self, root, justSet=False):
83                 self.root = root
84                 self.l.setRoot(root, justSet)
85                 if not justSet:
86                         self.l.sort()
87
88         def addService(self, service):
89                 self.l.addService(service)
90
91         def finishFill(self):
92                 self.l.FillFinished()
93                 self.l.sort()
94
95 # stuff for multiple marks (edit mode / later multiepg)
96         def clearMarks(self):
97                 self.l.initMarked()
98
99         def isMarked(self, ref):
100                 return self.l.isMarked(ref)
101
102         def addMarked(self, ref):
103                 self.l.addMarked(ref)
104
105         def removeMarked(self, ref):
106                 self.l.removeMarked(ref)
107
108         def getMarked(self):
109                 i = self.l
110                 i.markedQueryStart()
111                 ref = eServiceReference()
112                 marked = [ ]
113                 while i.markedQueryNext(ref) == 0:
114                         marked.append(ref.toString())
115                         ref = eServiceReference()
116                 return marked
117
118 #just for movemode.. only one marked entry..
119         def setCurrentMarked(self, state):
120                 self.l.setCurrentMarked(state)
121
122         def setMode(self, mode):
123                 self.mode = mode
124
125                 try:
126                         self.instance
127                 except:
128                         return
129                 
130                 if mode == self.MODE_NORMAL:
131                         self.instance.setItemHeight(28)
132                         self.l.setVisualMode(eListboxServiceContent.visModeSimple)
133                         self.l.setElementFont(self.l.celServiceName, gFont("Arial", 22))
134                         self.l.setElementPosition(self.l.celServiceName, eRect(0, 0, self.instance.size().width(), 28))
135                 else:
136                         self.instance.setItemHeight(28)
137                         self.l.setElementFont(self.l.celServiceNumber, gFont("Arial", 20))
138                         self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 0, 40, 28))
139                         self.l.setElementFont(self.l.celServiceName, gFont("Arial", 22))
140                         self.l.setElementPosition(self.l.celServiceName, eRect(50, 0, self.instance.size().width()-50, 28))
141                         self.l.setElementFont(self.l.celServiceInfo, gFont("Arial", 18))
142                         self.l.setVisualMode(eListboxServiceContent.visModeComplex)