Added maintainer.info files to the plugins Mosaic, PasswordChanger and ZapHistoryBrow...
[enigma2-plugins.git] / zaphistorybrowser / src / plugin.py
1 ##
2 ## Zap-History Browser
3 ## by AliAbdul
4 ##
5 from Components.ActionMap import ActionMap
6 from Components.Label import Label
7 from Components.MenuList import MenuList
8 from enigma import eServiceCenter
9 from Plugins.Plugin import PluginDescriptor
10 from Screens.Screen import Screen
11
12 ################################################
13
14 class ZapHistoryBrowser(Screen):
15         skin = """
16         <screen position="200,80" size="320,440" title="Zap-History Browser" >
17                 <ePixmap pixmap="skin_default/buttons/red.png" position="10,0" size="140,40" transparent="1" alphatest="on" />
18                 <ePixmap pixmap="skin_default/buttons/green.png" position="170,0" size="140,40" transparent="1" alphatest="on" />
19                 <widget name="key_red" position="10,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
20                 <widget name="key_green" position="170,0" zPosition="1" size="140,40" font="Regular;20" valign="center" halign="center" backgroundColor="#1f771f" transparent="1" />
21                 <widget name="list" position="0,40" size="320,400" scrollbarMode="showOnDemand" />
22         </screen>"""
23
24         def __init__(self, session, servicelist):
25                 Screen.__init__(self, session)
26                 
27                 self.servicelist = servicelist
28                 self.serviceHandler = eServiceCenter.getInstance()
29                 
30                 self["list"] = MenuList([])
31                 self["key_red"] = Label(_("Clear"))
32                 self["key_green"] = Label(_("Delete"))
33                 
34                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"],
35                         {
36                                 "ok": self.zap,
37                                 "cancel": self.close,
38                                 "red": self.clear,
39                                 "green": self.delete
40                         }, prio=-1)
41                 
42                 self.onLayoutFinish.append(self.buildList)
43
44         def buildList(self):
45                 list = []
46                 for x in self.servicelist.history:
47                         if len(x) == 2:
48                                 #print "Single-Bouquet!!!"
49                                 ref = x[1]
50                         else:
51                                 #print "Multi-Bouquet!!!"
52                                 ref = x[2]
53                         info = self.serviceHandler.info(ref)
54                         name = info.getName(ref).replace('\xc2\x86', '').replace('\xc2\x87', '')
55                         list.append(name)
56                 list.reverse()
57                 self["list"].setList(list)
58
59         def zap(self):
60                 length = len(self.servicelist.history)
61                 if length > 0:
62                         self.servicelist.history_pos = (length - self["list"].getSelectionIndex()) - 1
63                         self.servicelist.setHistoryPath()
64
65         def clear(self):
66                 for i in range(0, len(self.servicelist.history)):
67                         del self.servicelist.history[0]
68                 self.buildList()
69
70         def delete(self):
71                 length = len(self.servicelist.history)
72                 if length > 0:
73                         idx = (length - self["list"].getSelectionIndex()) - 1
74                         del self.servicelist.history[idx]
75                         self.buildList()
76
77 ################################################
78
79 def main(session, servicelist, **kwargs):
80         session.open(ZapHistoryBrowser, servicelist)
81
82 def Plugins(**kwargs):
83         return PluginDescriptor(name=_("Zap-History Browser"), where=PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)