Podcast: added plugin icon
[enigma2-plugins.git] / ftpbrowser / src / FTPQueueManager.py
1 # for localized messages
2 from . import _
3
4 # GUI (Screens)
5 from Screens.Screen import Screen
6
7 # GUI (Components)
8 from Components.ActionMap import ActionMap
9 from Components.Sources.List import List
10 from Components.Sources.StaticText import StaticText
11
12 # Tools
13 from Tools.LoadPixmap import LoadPixmap
14 from Tools.Directories import resolveFilename, SCOPE_PLUGINS
15
16 class FTPQueueManagerSummary(Screen):
17         skin = """
18         <screen position="0,0" size="132,64">
19                 <widget source="parent.Title" render="Label" position="6,4" size="120,21" font="Regular;18" />
20                 <widget source="parent.list" render="Label" position="6,25" size="120,21" font="Regular;16">
21                         <convert type="StringListSelection" />
22                 </widget>
23                 <widget source="global.CurrentTime" render="Label" position="56,46" size="82,18" font="Regular;16" >
24                         <convert type="ClockToText">WithSeconds</convert>
25                 </widget>
26         </screen>"""
27
28 class FTPQueueManager(Screen):
29         skin = """
30                 <screen position="center,center" size="560,420" title="FTP Queue Manager" >
31                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />
32                         <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />
33                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
34                         <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />
35                         <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
36                         <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
37                         <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
38                         <widget source="key_blue" render="Label"  position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
39                         <widget source="list" render="Listbox" position="0,50" size="560,360" scrollbarMode="showAlways">
40                                 <convert type="TemplatedMultiContent">
41                                         {"template": [
42                                                         MultiContentEntryText(pos=(35,1), size=(510,19), text = 0, font = 0, flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER),
43                                                         MultiContentEntryText(pos=(35,20), size=(510,18), text = 1, font = 0, flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER),
44                                                         MultiContentEntryPixmapAlphaTest(pos=(2,2), size=(32,32), png = 2),
45                                                 ],
46                                           "fonts": [gFont("Regular", 18)],
47                                           "itemHeight": 37
48                                          }
49                                 </convert>
50                         </widget>
51                 </screen>"""
52
53         def __init__(self, session, queue):
54                 Screen.__init__(self, session)
55                 self.queue = queue or []
56                 
57                 self["key_red"] = StaticText("")
58                 self["key_green"] = StaticText("")
59                 self["key_yellow"] = StaticText("")
60                 self["key_blue"] = StaticText("")
61                 self['list'] = List([])
62
63                 self.pixmaps = (
64                         LoadPixmap(resolveFilename(SCOPE_PLUGINS, "Extensions/FTPBrowser/images/up.png")),
65                         LoadPixmap(resolveFilename(SCOPE_PLUGINS, "Extensions/FTPBrowser/images/down.png"))
66                 )
67
68                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
69                         {
70                                 "cancel": self.exit,
71                                 "ok": self.ok,
72                         }, -1)
73                 
74                 self.onLayoutFinish.extend((
75                         self.layoutFinished,
76                         self.updateList,
77                 ))
78
79         def createSummary(self):
80                 return FTPQueueManagerSummary
81
82         def updateList(self, queue = None):
83                 if not queue:
84                         queue = self.queue
85
86                 pixmaps = self.pixmaps
87
88                 list = [(item[1], "-> " + item[2], pixmaps[item[0]]) for item in queue]
89
90                 # XXX: this is a little ugly but this way we have the least
91                 # visible distortion :-)
92                 index = min(self['list'].index, len(list)-1)
93                 self['list'].setList(list)
94                 self['list'].index = index
95
96         def layoutFinished(self):
97                 self.setTitle(_("FTP Queue Manager"))
98
99         def exit(self):
100                 self.close()
101
102         def ok(self):
103                 pass
104