fix automatic scan
[enigma2.git] / lib / python / Components / ServiceList.py
1 from HTMLComponent import *
2 from GUIComponent import *
3
4 from enigma import *
5
6 class ServiceList(HTMLComponent, GUIComponent):
7
8         MODE_NORMAL = 0
9         MODE_FAVOURITES = 1
10
11         def __init__(self):
12                 GUIComponent.__init__(self)
13                 self.l = eListboxServiceContent()
14                 self.root = None
15
16         def getCurrent(self):
17                 r = eServiceReference()
18                 self.l.getCurrent(r)
19                 return r
20
21         def moveUp(self):
22                 self.instance.moveSelection(self.instance.moveUp)
23
24         def moveDown(self):
25                 self.instance.moveSelection(self.instance.moveDown)
26
27         def GUIcreate(self, parent):
28                 self.instance = eListbox(parent)
29                 self.instance.setContent(self.l)
30         
31         def GUIdelete(self):
32                 self.instance = None
33
34         def getRoot(self):
35                 return self.root
36
37         def getRootServices(self):
38                 serviceHandler = eServiceCenter.getInstance()
39                 list = serviceHandler.list(self.root)
40                 dest = [ ]
41                 if list is not None:
42                         while 1:
43                                 s = list.getNext()
44                                 if s.valid():
45                                         dest.append(s.toString())
46                                 else:
47                                         break
48                 return dest
49
50         def setRoot(self, root):
51                 self.root = root
52                 self.l.setRoot(root)
53                 self.l.sort()
54
55 # stuff for multiple marks (edit mode / later multiepg)
56         def clearMarks(self):
57                 self.l.initMarked()
58
59         def isMarked(self, ref):
60                 return self.l.isMarked(ref)
61
62         def addMarked(self, ref):
63                 self.l.addMarked(ref)
64
65         def removeMarked(self, ref):
66                 self.l.removeMarked(ref)
67
68         def getMarked(self):
69                 i = self.l
70                 i.markedQueryStart()
71                 ref = eServiceReference()
72                 marked = [ ]
73                 while i.markedQueryNext(ref) == 0:
74                         marked.append(ref.toString())
75                         ref = eServiceReference()
76                 return marked
77
78 #just for movemode.. only one marked entry..
79         def setCurrentMarked(self, state):
80                 self.l.setCurrentMarked(state)
81
82         def setMode(self, mode):
83                 if mode == self.MODE_NORMAL:
84                         self.instance.setItemHeight(25)
85                         self.l.setVisualMode(eListboxServiceContent.visModeSimple)
86                 else:
87                         self.instance.setItemHeight(40)
88                         self.l.setElementFont(self.l.celServiceName, gFont("Arial", 30))
89                         self.l.setElementPosition(self.l.celServiceName, eRect(40, 0, self.instance.size().width(), 40))
90                         self.l.setElementFont(self.l.celServiceNumber, gFont("Arial", 20))
91                         self.l.setElementPosition(self.l.celServiceNumber, eRect(0, 10, 40, 30))
92                         self.l.setVisualMode(eListboxServiceContent.visModeComplex)