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