add pretty basic queue manager (currently only displays queue in a not very readable...
[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.Label import Label
10 from Components.MenuList import MenuList
11
12 class FTPQueueManager(Screen):
13         skin = """
14                 <screen position="center,center" size="560,420" title="FTP Queue Manager" >
15                         <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" transparent="1" alphatest="on" />
16                         <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" transparent="1" alphatest="on" />
17                         <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" transparent="1" alphatest="on" />
18                         <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" transparent="1" alphatest="on" />
19                         <widget name="key_red" position="0,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
20                         <widget name="key_green" position="140,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
21                         <widget name="key_yellow" position="280,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
22                         <widget name="key_blue" position="420,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
23                         <widget name="list" position="0,50" size="560,360" scrollbarMode="showOnDemand" />
24                 </screen>"""
25
26         def __init__(self, session, queue):
27                 Screen.__init__(self, session)
28                 self.queue = queue or []
29                 
30                 self["key_red"] = Label("")
31                 self["key_green"] = Label("")
32                 self["key_yellow"] = Label("")
33                 self["key_blue"] = Label("")
34                 self["list"] = MenuList([])
35
36                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
37                         {
38                                 "cancel": self.exit,
39                                 "ok": self.ok,
40                         }, -1)
41                 
42                 self.onLayoutFinish.extend((
43                         self.layoutFinished,
44                         self.updateList,
45                 ))
46
47         def updateList(self, queue = None):
48                 if not queue:
49                         queue = self.queue
50
51                 list = []
52                 for item in queue:
53                         if item[0]:
54                                 text = "DOWN "
55                         else:
56                                 text = "UP   "
57
58                         text += item[1]
59                         text += " -> "
60                         text += item[2]
61
62                         list.append(text)
63
64                 self["list"].setList(list)
65
66         def layoutFinished(self):
67                 self.setTitle(_("FTP Queue Manager"))
68
69         def exit(self):
70                 self.close()
71
72         def ok(self):
73                 pass
74