1 from Components.GUIComponent import GUIComponent
2 from Components.MultiContent import MultiContentEntryText
3 from enigma import eListboxPythonMultiContent, eListbox, gFont, RT_HALIGN_LEFT, RT_WRAP
5 class RSSBaseList(GUIComponent):
6 """Base List Component for RSSFeeds."""
7 def __init__(self, entries, itemheight):
8 GUIComponent.__init__(self)
10 self.itemheight = itemheight
11 self.l = eListboxPythonMultiContent()
12 self.l.setFont(0, gFont("Regular", 22))
13 self.l.setFont(1, gFont("Regular", 18))
14 self.l.setList(self.list)
16 self.onSelectionChanged = [ ]
18 def connectSelChanged(self, fnc):
19 if not fnc in self.onSelectionChanged:
20 self.onSelectionChanged.append(fnc)
22 def disconnectSelChanged(self, fnc):
23 if fnc in self.onSelectionChanged:
24 self.onSelectionChanged.remove(fnc)
26 def selectionChanged(self):
27 for x in self.onSelectionChanged:
35 def postWidgetCreate(self, instance):
36 instance.setContent(self.l)
37 instance.setItemHeight(self.itemheight)
38 instance.selectionChanged.get().append(self.selectionChanged)
40 def getCurrentEntry(self):
41 return self.l.getCurrentSelection()
43 def getCurrentIndex(self):
44 return self.instance.getCurrentIndex()
46 def moveToIndex(self, index):
47 self.instance.moveSelectionTo(index)
49 def moveToEntry(self, identifier):
53 self.instance.moveSelection(self.instance.moveDown)
56 self.instance.moveSelection(self.instance.moveUp)
61 class RSSFeedList(RSSBaseList):
62 def __init__(self, entries):
63 RSSBaseList.__init__(self, entries, 100)
64 self.l.setBuildFunc(self.buildListboxEntry)
66 def moveToEntry(self, feed):
72 if feed.uri == x[0].uri:
73 self.instance.moveSelectionTo(idx)
77 def buildListboxEntry(self, feed):
79 width = self.l.getItemSize().width()
80 res.append(MultiContentEntryText(pos=(0, 0), size=(width, 75), font=0, flags = RT_HALIGN_LEFT|RT_WRAP, text = feed.title))
81 res.append(MultiContentEntryText(pos=(0, 75), size=(width, 20), font=1, flags = RT_HALIGN_LEFT, text = feed.description))
84 def getCurrentEntry(self):
85 # We know that the list will never be empty...
86 return self.l.getCurrentSelection()[0]
88 class RSSEntryList(RSSBaseList):
89 def __init__(self, entries):
90 RSSBaseList.__init__(self, entries, 50)
91 self.l.setBuildFunc(self.buildListboxEntry)
93 def moveToEntry(self, entry):
100 self.instance.moveSelectionTo(idx)
104 def buildListboxEntry(self, title, link, summary, enclosures):
106 width = self.l.getItemSize().width()
107 res.append(MultiContentEntryText(pos=(0, 0), size=(width, 50), font=0, flags = RT_HALIGN_LEFT|RT_WRAP, text = title))