one empty line
[enigma2.git] / lib / python / Components / MovieList.py
1 from HTMLComponent import *
2 from GUIComponent import *
3
4 from enigma import eListboxPythonMultiContent, eListbox, gFont
5
6 from enigma import eServiceReference, eServiceCenter, \
7         eServiceCenterPtr, iListableServicePtr, \
8         iStaticServiceInformationPtr
9
10
11
12 RT_HALIGN_LEFT = 0
13 RT_HALIGN_RIGHT = 1
14 RT_HALIGN_CENTER = 2
15 RT_HALIGN_BLOCK = 4
16
17 RT_VALIGN_TOP = 0
18 RT_VALIGN_CENTER = 8
19 RT_VALIGN_BOTTOM = 16
20
21 RT_WRAP = 32
22
23
24 #
25 # | name of movie              |
26 #
27 def MovieListEntry(serviceref, serviceHandler):
28         res = [ serviceref ]
29
30         info = iStaticServiceInformationPtr()
31
32         if serviceHandler.info(serviceref, info):
33                 # ignore service which refuse to info
34                 del info
35                 return
36         
37         len = info.getLength(serviceref)
38         if len:
39                 len = "%d:%02d" % (len / 60, len % 60)
40         else:
41                 len = "?:??"
42         
43         res.append((0, 0, 400, 30, 0, RT_HALIGN_LEFT, info.getName(serviceref)))
44         res.append((0, 30, 200, 20, 1, RT_HALIGN_LEFT, "Toller Film"))
45         res.append((0, 50, 200, 20, 1, RT_HALIGN_LEFT, "Aufgenommen: irgendwann"))
46         res.append((200, 50, 200, 20, 1, RT_HALIGN_RIGHT, len))
47         
48         return res
49
50 class MovieList(HTMLComponent, GUIComponent):
51         def __init__(self, root):
52                 GUIComponent.__init__(self)
53                 self.l = eListboxPythonMultiContent()
54                 self.load(root)
55                 self.l.setList(self.list)
56                 self.l.setFont(0, gFont("Arial", 30))
57                 self.l.setFont(1, gFont("Arial", 18))
58         
59         def getCurrent(self):
60                 return self.l.getCurrentSelection()
61         
62         def GUIcreate(self, parent):
63                 self.instance = eListbox(parent)
64                 self.instance.setContent(self.l)
65                 self.instance.setItemHeight(75)
66         
67         def GUIdelete(self):
68                 self.instance.setContent(None)
69                 self.instance = None
70
71         def load(self, root):
72                 # this lists our root service, then building a 
73                 # nice list
74                 
75                 self.list = [ ]
76                 
77                 serviceHandler = eServiceCenterPtr()
78                 eServiceCenter.getInstance(serviceHandler)
79                 list = iListableServicePtr()
80                 
81                 if serviceHandler.list(root, list):
82                         raise "listing of movies failed"
83
84                 movieList = [ ]
85                 while 1:
86                         s = eServiceReference()
87                         if list.getNext(s):
88                                 del s
89                                 del list
90                                 break
91                         movieList.append(s)
92                 
93                 # now process them...
94                 for ref in movieList:
95                         self.list.append(MovieListEntry(ref, serviceHandler))