plugin.py split up,\nfeed overview and single feed view in different screens,\nyellow...
[enigma2-plugins.git] / simplerss / src / RSSList.py
1 from Components.GUIComponent import GUIComponent
2 from Components.MultiContent import MultiContentEntryText
3 from enigma import eListboxPythonMultiContent, eListbox, gFont, RT_HALIGN_LEFT, RT_WRAP
4
5 class RSSList(GUIComponent):
6         def __init__(self, entries):
7                 GUIComponent.__init__(self)
8                 self.list = entries
9                 self.l = eListboxPythonMultiContent()
10                 self.l.setFont(0, gFont("Regular", 22))
11                 self.l.setFont(1, gFont("Regular", 18))
12                 self.l.setBuildFunc(self.buildListboxEntry)
13                 self.l.setList(entries)
14                 
15                 self.onSelectionChanged = [ ]
16                 
17         def connectSelChanged(self, fnc):
18                 if not fnc in self.onSelectionChanged:
19                         self.onSelectionChanged.append(fnc)
20
21         def disconnectSelChanged(self, fnc):
22                 if fnc in self.onSelectionChanged:
23                         self.onSelectionChanged.remove(fnc)
24
25         def selectionChanged(self):
26                 for x in self.onSelectionChanged:
27                         x()
28
29         GUI_WIDGET = eListbox
30
31         def postWidgetCreate(self, instance):
32                 instance.setContent(self.l)
33                 instance.setItemHeight(100)
34                 instance.selectionChanged.get().append(self.selectionChanged)
35
36         def buildListboxEntry(self, title, link, summary, enclosures):
37                 res = [ None ]
38                 width = self.l.getItemSize().width()
39                 res.append(MultiContentEntryText(pos=(0, 0), size=(width, 75), font=0, flags = RT_HALIGN_LEFT|RT_WRAP, text = title))
40                 res.append(MultiContentEntryText(pos=(0, 75), size=(width, 20), font=1, flags = RT_HALIGN_LEFT, text = link))
41                 return res
42
43         def getCurrentEntry(self):
44                 return self.l.getCurrentSelection()
45
46         def getCurrentIndex(self):
47                 return self.instance.getCurrentIndex()
48
49         def moveToIndex(self, index):
50                 self.instance.moveSelectionTo(index)
51
52         def moveToEntry(self, entry):
53                 if entry is None:
54                         return
55
56                 count = 0
57                 for x in self.list:
58                         if entry[0] == x[0]:
59                                 self.instance.moveSelectionTo(count)
60                                 break
61                         count += 1
62
63         def moveDown(self):
64                 self.instance.moveSelection(self.instance.moveDown)
65
66         def moveUp(self):
67                 self.instance.moveSelection(self.instance.moveUp)