rely solely on our localization
[vuplus_dvbapp-plugin] / autotimer / src / AutoTimerList.py
1 # -*- coding: UTF-8 -*-
2 # for localized messages
3 from . import _
4
5 # GUI (Components)
6 from Components.MenuList import MenuList
7 from enigma import eListboxPythonMultiContent, gFont, RT_HALIGN_LEFT
8
9 from skin import parseColor, parseFont
10
11 class AutoTimerList(MenuList):
12         """Defines a simple Component to show Timer name"""
13
14         def __init__(self, entries):
15                 MenuList.__init__(self, entries, False, content = eListboxPythonMultiContent)
16
17                 self.l.setFont(0, gFont("Regular", 22))
18                 self.l.setBuildFunc(self.buildListboxEntry)
19                 self.l.setItemHeight(25)
20                 self.colorDisabled = 12368828
21
22         def applySkin(self, desktop, parent):
23                 attribs = [ ] 
24                 if self.skinAttributes is not None:
25                         for (attrib, value) in self.skinAttributes:
26                                 if attrib == "font":
27                                         self.l.setFont(0, parseFont(value, ((1,1),(1,1))))
28                                 elif attrib == "itemHeight":
29                                         self.l.setItemHeight(int(value))
30                                 elif attrib == "colorDisabled":
31                                         self.colorDisabled = int(parseColor(value))
32                                 else:
33                                         attribs.append((attrib, value))
34                 self.skinAttributes = attribs
35                 return MenuList.applySkin(self, desktop, parent)
36
37         #
38         #  | <Name of AutoTimer> |
39         #
40         def buildListboxEntry(self, timer):
41                 size = self.l.getItemSize()
42
43                 color = None
44                 if not timer.enabled:
45                         color = self.colorDisabled
46
47                 return [
48                         None,
49                         (eListboxPythonMultiContent.TYPE_TEXT, 5, 0, size.width() - 5, size.height(), 0, RT_HALIGN_LEFT, timer.name, color, color)
50                 ]
51
52         def getCurrent(self):
53                 cur = self.l.getCurrentSelection()
54                 return cur and cur[0]
55
56         def moveToEntry(self, entry):
57                 if entry is None:
58                         return
59
60                 idx = 0
61                 for x in self.list:
62                         if x[0] == entry:
63                                 self.instance.moveSelectionTo(idx)
64                                 break
65                         idx += 1
66