[EasyInfo] - fix for not shown text
[enigma2-plugins.git] / easyinfo / src / plugin.py
1 #######################################################################
2 #
3 #    EasyInfo for Dreambox-Enigma2
4 #    Coded by Vali (c)2011
5 #    Re-worked by dre (c) 2019
6 #
7 #  This plugin is licensed under the Creative Commons 
8 #  Attribution-NonCommercial-ShareAlike 3.0 Unported License.
9 #  To view a copy of this license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
10 #  or send a letter to Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
11 #
12 #  Alternatively, this plugin may be distributed and executed on hardware which
13 #  is licensed by Dream Property GmbH.
14 #
15 #  This plugin is NOT free software. It is open source, you are allowed to
16 #  modify it (if you keep the license), but it may not be commercially 
17 #  distributed other than under the conditions noted above.
18 #
19 #######################################################################
20
21
22
23 from Plugins.Plugin import PluginDescriptor
24 from Screens.Screen import Screen
25 from Screens.MessageBox import MessageBox
26 from Screens.InfoBarGenerics import InfoBarPlugins
27 from Screens.TimerEdit import TimerEditList
28 from Screens.EpgSelection import EPGSelection
29 from Screens.EventView import EventViewSimple, EventViewBase
30 from Screens.ServiceInfo import ServiceInfo
31 from Screens.ChannelSelection import BouquetSelector
32 from Screens.TimeDateInput import TimeDateInput
33 from Components.ActionMap import ActionMap
34 from Components.MenuList import MenuList
35 from Components.Label import Label
36 from Components.EpgList import EPGList, EPG_TYPE_MULTI
37 from Components.ConfigList import ConfigListScreen
38 from Components.config import config, getConfigListEntry, ConfigSubsection, ConfigSelection, ConfigClock, ConfigYesNo
39 from Components.Sources.StaticText import StaticText
40 from Tools.Directories import fileExists, pathExists
41 from Tools.LoadPixmap import LoadPixmap
42 from Tools.PiconResolver import PiconResolver
43 from ServiceReference import ServiceReference
44 from enigma import eListboxPythonMultiContent, gFont, eTimer, eServiceReference, RT_HALIGN_LEFT, RT_HALIGN_CENTER, RT_VALIGN_CENTER, RT_WRAP, RT_HALIGN_RIGHT, RT_VALIGN_TOP
45 from time import localtime, time, mktime
46 from skin import TemplatedListFonts, componentSizes
47
48 EasyInfoBaseInfoBarPlugins__init__ = None
49 EasyInfoStartOnlyOnce = False
50 EasyInfoSession = None
51 EINposition = 0
52 InfoBar_instance = None
53
54 CHOICELIST=[("no", _("Disabled")),
55                         ("eventinfo", _("Event info")),
56                         ("singleepg", _("Single EPG")),
57                         ("multiepg", _("Multi EPG")),
58                         ("easypg", _("EasyPG")),
59                         ("easysel", _("EasySelection")),
60                         ("graphepg", _("Graphik multi-EPG")),
61                         ("merlinepg", _("Merlin EPG")),
62                         ("cooltv", _("Cool-TV")),
63                         ("timers", _("Timerlist")),
64                         ("epgsearch", _("EPG search")),
65                         ("autotimer", _("Autotimer")),
66                         ("channelinfo", _("Channel info")),
67                         ("imdbinfo", _("IMDB info")),
68                         ("epgrefresh", _("EPG refresh")),
69                         ("sleep", _("Sleep timer")),
70                         ]
71
72 COLORCHOICELIST = [("singleepg", _("Single EPG")),("multiepg", _("Multi EPG")),("easypg", _("Easy-PG")),("graphepg", _("Graphik multi-EPG")),("merlinepg", _("Merlin EPG")),("cooltv", _("Cool-TV")),("imdbinfo", _("IMDB info"))]
73 config.plugins.EasyInfo  = ConfigSubsection()
74 config.plugins.EasyInfo.pos1 = ConfigSelection(default="eventinfo", choices = CHOICELIST)
75 config.plugins.EasyInfo.pos2 = ConfigSelection(default="singleepg", choices = CHOICELIST)
76 config.plugins.EasyInfo.pos3 = ConfigSelection(default="merlinepg", choices = CHOICELIST)
77 config.plugins.EasyInfo.pos4 = ConfigSelection(default="timers", choices = CHOICELIST)
78 config.plugins.EasyInfo.pos5 = ConfigSelection(default="channelinfo", choices = CHOICELIST)
79 config.plugins.EasyInfo.pos6 = ConfigSelection(default="no", choices = CHOICELIST)
80 config.plugins.EasyInfo.pos7 = ConfigSelection(default="no", choices = CHOICELIST)
81 config.plugins.EasyInfo.pos8 = ConfigSelection(default="no", choices = CHOICELIST)
82 config.plugins.EasyInfo.pos9 = ConfigSelection(default="no", choices = CHOICELIST)
83 config.plugins.EasyInfo.pos10 = ConfigSelection(default="no", choices = CHOICELIST)
84 config.plugins.EasyInfo.pos11 = ConfigSelection(default="no", choices = CHOICELIST)
85 config.plugins.EasyInfo.showEventInfoFirst = ConfigYesNo(default=False)
86 config.plugins.EasyInfo.eventViewYellow = ConfigSelection(default="singleepg", choices= COLORCHOICELIST)
87 config.plugins.EasyInfo.eventViewBlue = ConfigSelection(default="multiepg", choices= COLORCHOICELIST)
88 config.plugins.EasyInfo.piconPath = ConfigSelection(default="/data/picon_50x30/", choices = [("/data/picon_50x30/", "/data/picon_50x30/"), ("/usr/share/enigma2/picon_50x30/", "/usr/share/enigma2/picon_50x30/"),("/data/picon/", "/data/picon/"), ("/usr/share/enigma2/picon/", "/usr/share/enigma2/picon/")])
89 config.plugins.EasyInfo.easyPGOK = ConfigSelection(default="info", choices = [("info", _("Event info")), ("zap", _("Just zap")),("exitzap", _("Zap and Exit"))])
90 config.plugins.EasyInfo.primeTime1 = ConfigClock(default = 63000)
91 config.plugins.EasyInfo.primeTime2 = ConfigClock(default = 69300)
92 config.plugins.EasyInfo.primeTime3 = ConfigClock(default = 75600)
93 config.plugins.EasyInfo.buttonTV = ConfigSelection(default="easysel", choices = [("no", _("Disabled")), ("easysel", _("Easy-Selection")), ("easypg", _("Easy-PG"))])
94
95
96
97 def Plugins(**kwargs):
98         return [PluginDescriptor(where = PluginDescriptor.WHERE_SESSIONSTART, fnc = EasyInfoAutostart)]
99
100 def EasyInfoAutostart(reason, **kwargs):
101         global EasyInfoBaseInfoBarPlugins__init__
102         if "session" in kwargs:
103                 global EasyInfoSession
104                 EasyInfoSession = kwargs["session"]
105                 if EasyInfoBaseInfoBarPlugins__init__ is None:
106                         EasyInfoBaseInfoBarPlugins__init__ = InfoBarPlugins.__init__
107                 InfoBarPlugins.__init__ = InfoBarPlugins__init__
108                 InfoBarPlugins.showInfo = showInfo
109                 if config.plugins.EasyInfo.buttonTV.value != "no":
110                         InfoBarPlugins.buttonTV = buttonTV
111
112 def InfoBarPlugins__init__(self):
113         global EasyInfoStartOnlyOnce
114         if not EasyInfoStartOnlyOnce: 
115                 EasyInfoStartOnlyOnce = True
116                 global InfoBar_instance
117                 InfoBar_instance = self
118                 if config.plugins.EasyInfo.buttonTV.value != "no":
119                         self["EasyInfoActions"] = ActionMap(["EasyInfoActions"],
120                                 {"info_but": self.showInfo, "tv_but": self.buttonTV}, -1)
121                 else:
122                         self["EasyInfoActions"] = ActionMap(["EasyInfoActionsALT"],
123                                 {"info_but": self.showInfo}, -1)
124         else:
125                 InfoBarPlugins.__init__ = InfoBarPlugins.__init__
126                 InfoBarPlugins.info = None
127                 if config.plugins.EasyInfo.buttonTV.value != "no":
128                         InfoBarPlugins.buttonTV = None
129         EasyInfoBaseInfoBarPlugins__init__(self)
130
131 def showInfo(self):
132         if not config.plugins.EasyInfo.showEventInfoFirst.value:
133                 epglist = [ ]
134                 service = self.session.nav.getCurrentService()
135                 ref = self.session.nav.getCurrentlyPlayingServiceReference()
136                 info = service.info()
137                 ptr=info.getEvent(0)
138                 if ptr:
139                         epglist.append(ptr)
140                 ptr=info.getEvent(1)
141                 if ptr:
142                         epglist.append(ptr)
143                 if epglist:
144                         self.session.open(EasyInfoEventView, epglist[0], ServiceReference(ref))
145                 else:
146                         self.session.open(EasyInfo)
147         else:
148                 self.session.open(EasyInfo)
149
150 def buttonTV(self):
151         currentService = self.session.nav.getCurrentService()
152         currentServiceTimeShift = currentService and currentService.timeshift()
153         if currentServiceTimeShift is not None:
154                 if currentServiceTimeShift.isTimeshiftActive():
155                         InfoBar_instance.stopTimeshift()
156                         return
157         if InfoBar_instance.servicelist.mode == 1:
158                 del currentService
159                 del currentServiceTimeShift
160                 InfoBar_instance.showTv()
161                 return
162         bouquets = InfoBar_instance.servicelist.getBouquetList()
163         if bouquets is None:
164                 cnt = 0
165         else:
166                 cnt = len(bouquets)
167                 InfoBarServices = InfoBar_instance.getBouquetServices(InfoBar_instance.servicelist.getRoot())
168         if cnt > 1:
169                 if config.plugins.EasyInfo.buttonTV.value == "easysel":
170                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasySelection, InfoBarServices, EasyInfoZapTo, None, EasyInfoChangeBouquetCB))
171                 elif config.plugins.EasyInfo.buttonTV.value == "easypg":
172                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasyPG, InfoBarServices, EasyInfoZapTo, None, EasyInfoChangeBouquetCB))
173         elif cnt == 1:
174                 if config.plugins.EasyInfo.buttonTV.value == "easysel":
175                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasySelection, InfoBarServices, EasyInfoZapTo, None, None))
176                 if config.plugins.EasyInfo.buttonTV.value == "easypg":
177                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasyPG, InfoBarServices, EasyInfoZapTo, None, EasyInfoChangeBouquetCB))
178
179 def getPluginByName(sstr):
180         sret = " "
181         for xs in CHOICELIST:
182                 if sstr == xs[0]:
183                         sret = xs[1]
184                         break
185         return sret
186
187 class EasyInfoPanelList(MenuList):
188         SKIN_COMPONENT_KEY = "EasyInfoPanelList"
189         SKIN_COMPONENT_ITEM_HEIGHT = "itemHeight"
190         SKIN_COMPONENT_TEXT_WIDTH = "textWidth"
191         SKIN_COMPONENT_TEXT_HEIGHT = "textHeight"
192         SKIN_COMPONENT_TEXT_XOFFSET = "textXOffset"
193         SKIN_COMPONENT_TEXT_YOFFSET = "textYOffset"
194         SKIN_COMPONENT_ICON_WIDTH = "iconWidth"
195         SKIN_COMPONENT_ICON_HEIGHT = "iconHeight"
196         SKIN_COMPONENT_ICON_XOFFSET = "iconXOffset"
197         SKIN_COMPONENT_ICON_YOFFSET = "iconYOffset"
198         SKIN_COMPONENT_KEYICON_WIDTH = "keyIconWidth"
199         SKIN_COMPONENT_KEYICON_HEIGHT = "keyIconHeight"
200         SKIN_COMPONENT_KEYICON_XOFFSET = "keyIconXOffset"
201         SKIN_COMPONENT_KEYICON_YOFFSET = "keyIconYOffset"
202                         
203         def __init__(self, list, enableWrapAround=True):
204                 MenuList.__init__(self, list, enableWrapAround, eListboxPythonMultiContent)
205
206                 if pathExists('/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/icons/'):
207                         self.easyInfoIconsPath = '/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/icons/'
208                 else:
209                         self.easyInfoIconsPath = '/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/'
210                 
211                 sizes = componentSizes[EasyInfoPanelList.SKIN_COMPONENT_KEY]
212                 self.itemHeight = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_ITEM_HEIGHT, 60)
213                 self.textWidth = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_TEXT_WIDTH, 300)
214                 self.textHeight = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_TEXT_HEIGHT, 60)
215                 self.textXOffset = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_TEXT_XOFFSET, 115)
216                 self.textYOffset = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_TEXT_YOFFSET, 0)          
217                 self.iconWidth = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_ICON_WIDTH, 100)
218                 self.iconHeight = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_ICON_HEIGHT, 50)
219                 self.iconXOffset = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_ICON_XOFFSET, 5)
220                 self.iconYOffset = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_ICON_YOFFSET, 5)
221                 self.keyIconWidth = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_KEYICON_WIDTH, 5)
222                 self.keyIconHeight = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_KEYICON_HEIGHT, 50)
223                 self.keyIconXOffset = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_KEYICON_XOFFSET, 0)
224                 self.keyIconYOffset = sizes.get(EasyInfoPanelList.SKIN_COMPONENT_KEYICON_YOFFSET, 5)
225                 
226                 tlf = TemplatedListFonts()
227                 self.l.setFont(0, gFont(tlf.face(tlf.MEDIUM), tlf.size(tlf.MEDIUM)))
228                 self.l.setItemHeight(self.itemHeight)
229                 self.l.setBuildFunc(self.buildEntry)
230                 
231         def buildEntry(self, func, key):
232                 res = [ None ]
233                 
234                 text = getPluginByName(func)
235                 
236                 bpng = LoadPixmap(self.easyInfoIconsPath + "key-" + key + ".png")
237                 if bpng is not None:
238                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, self.keyIconXOffset, self.keyIconYOffset, self.keyIconWidth, self.keyIconHeight, bpng))
239                 png = LoadPixmap(self.easyInfoIconsPath + func + ".png")
240                 if png is not None:
241                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, self.iconXOffset, self.iconYOffset, self.iconWidth, self.iconHeight, png))                
242                 if not config.plugins.EasyInfo.showEventInfoFirst.value:
243                         res.append((eListboxPythonMultiContent.TYPE_TEXT, self.textXOffset, self.textYOffset, self.textWidth, self.textHeight, 0, RT_HALIGN_LEFT|RT_VALIGN_CENTER, text))
244                 return res      
245
246 class EasyInfoConfig(ConfigListScreen, Screen):
247         skin = """
248                 <screen name="EasyInfoConfig" position="center,center" size="700,530" title="EasyInfo settings...">
249                         <widget name="config" position="5,5" scrollbarMode="showOnDemand" size="690,475"/>
250                         <eLabel font="Regular;20" foregroundColor="#00ff4A3C" halign="center" position="20,490" size="140,26" text="Cancel"/>
251                         <eLabel font="Regular;20" foregroundColor="#0056C856" halign="center" position="165,490" size="140,26" text="Save"/>
252                 </screen>"""
253         def __init__(self, session):
254                 Screen.__init__(self, session)
255                 self.setTitle(_("EasyInfo settings..."))
256                 self.session = session
257                 self.oldsetting = [config.plugins.EasyInfo.showEventInfoFirst.value, config.plugins.EasyInfo.buttonTV.value]
258                 list = []
259                 list.append(getConfigListEntry(_("Replace event info with EasyInfo:"), config.plugins.EasyInfo.showEventInfoFirst ))
260                 list.append(getConfigListEntry(_("Replace TV-button function:"), config.plugins.EasyInfo.buttonTV ))
261                 list.append(getConfigListEntry(_("EventInfo yellow button:"), config.plugins.EasyInfo.eventViewYellow ))
262                 list.append(getConfigListEntry(_("EventInfo blue button:"), config.plugins.EasyInfo.eventViewBlue ))
263                 list.append(getConfigListEntry(_("OK function in Easy-PG:"), config.plugins.EasyInfo.easyPGOK))
264                 list.append(getConfigListEntry(_("Easy-PG picons path:"), config.plugins.EasyInfo.piconPath))
265                 list.append(getConfigListEntry(_("Easy-PG Primetime 1:"), config.plugins.EasyInfo.primeTime1))
266                 list.append(getConfigListEntry(_("Easy-PG Primetime 2 (main):"), config.plugins.EasyInfo.primeTime2))
267                 list.append(getConfigListEntry(_("Easy-PG Primetime 3:"), config.plugins.EasyInfo.primeTime3))
268                 list.append(getConfigListEntry(_("Position 1 (info button):"), config.plugins.EasyInfo.pos1))
269                 list.append(getConfigListEntry(_("Position 2 (red button):"), config.plugins.EasyInfo.pos2))
270                 list.append(getConfigListEntry(_("Position 3 (green button):"), config.plugins.EasyInfo.pos3))
271                 list.append(getConfigListEntry(_("Position 4 (yellow button):"), config.plugins.EasyInfo.pos4))
272                 list.append(getConfigListEntry(_("Position 5 (blue button):"), config.plugins.EasyInfo.pos5))
273                 list.append(getConfigListEntry(_("Position 6:"), config.plugins.EasyInfo.pos6))
274                 list.append(getConfigListEntry(_("Position 7:"), config.plugins.EasyInfo.pos7))
275                 list.append(getConfigListEntry(_("Position 8:"), config.plugins.EasyInfo.pos8))
276                 list.append(getConfigListEntry(_("Position 9:"), config.plugins.EasyInfo.pos9))
277                 list.append(getConfigListEntry(_("Position 10:"), config.plugins.EasyInfo.pos10))
278                 list.append(getConfigListEntry(_("Position 11:"), config.plugins.EasyInfo.pos11))
279                 ConfigListScreen.__init__(self, list)
280                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "red": self.exit, "cancel": self.exit, "yellow": self.exit}, -1)
281
282         def save(self):
283                 for x in self["config"].list:
284                         x[1].save()
285                 if self.oldsetting != [config.plugins.EasyInfo.showEventInfoFirst.value, config.plugins.EasyInfo.buttonTV.value]:
286                         self.session.open(MessageBox, text = _('You need GUI-restart to load the new settings!'), type = MessageBox.TYPE_INFO)
287                 self.close()
288
289         def exit(self):
290                 for x in self["config"].list:
291                         x[1].cancel()
292                 self.close()
293
294 class EasyInfo(Screen):
295         if not config.plugins.EasyInfo.showEventInfoFirst.value:
296                 skin = """
297                 <screen name="EasyInfo" flags="wfNoBorder" position="center,center" size="500,740" title="Easy Info">
298                         <ePixmap pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/bg.png" position="0,0" size="500,740"/>
299                         <widget name="list" position="70,40" size="360,660" scrollbarMode="showNever" transparent="1" zPosition="2"/>
300                 </screen>"""
301         else:
302                 skin = """
303                 <screen name="EventViewWithEasyInfo" backgroundColor="background" flags="wfNoBorder" position="center,0" size="1280,720" title="Easy Info">
304                         <widget name="list" position="55,30" size="110,660" scrollbarMode="showNever" transparent="1" zPosition="2"/>
305                         <eLabel backgroundColor="#666666" position="250,359" size="1280,2"/>
306                         <widget font="Regular;24" foregroundColor="#fcc000" position="630,50" render="Label" size="600,30" source="session.CurrentService" transparent="1" zPosition="1">
307                                 <convert type="ServiceName">Name</convert>
308                         </widget>
309                         <widget font="Regular;24" position="250,50" render="Label" size="100,30" source="session.Event_Now" transparent="1" zPosition="1">
310                                 <convert type="EventTime">StartTime</convert>
311                                 <convert type="ClockToText">Default</convert>
312                         </widget>
313                         <widget font="Regular;24" noWrap="1" position="250,90" render="Label" size="900,30" source="session.Event_Now" transparent="1" zPosition="1">
314                                 <convert type="EventName">Name</convert>
315                         </widget>
316                         <widget font="Regular;22" foregroundColor="#fcc000" position="350,50" halign="right" render="Label" size="130,30" source="session.Event_Now" transparent="1" zPosition="1">
317                                 <convert type="EventTime">Remaining</convert>
318                                 <convert type="RemainingToText">InMinutes</convert>
319                         </widget>
320                         <widget font="Regular;24" position="250,400" render="Label" size="100,30" source="session.Event_Next" transparent="1" zPosition="1">
321                                 <convert type="EventTime">StartTime</convert>
322                                 <convert type="ClockToText">Default</convert>
323                         </widget>
324                         <widget font="Regular;24" foregroundColor="#aaaaaa" noWrap="1" position="250,370" render="Label" size="900,30" source="session.Event_Next" transparent="1" zPosition="1">
325                                 <convert type="EventName">Name</convert>
326                         </widget>
327                         <widget font="Regular;24" foregroundColor="#aaaaaa" position="350,400" render="Label" size="130,30" source="session.Event_Next" transparent="1" zPosition="1">
328                                 <convert type="EventTime">Duration</convert>
329                                 <convert type="ClockToText">InMinutes</convert>
330                         </widget>
331                         <widget backgroundColor="#555555" borderColor="#555555" borderWidth="4" position="490,57" render="Progress" size="120,14" source="session.Event_Now" zPosition="2">
332                                 <convert type="EventTime">Progress</convert>
333                         </widget>
334                         <widget font="Regular;22" position="250,127" render="Label" size="950,225" source="session.Event_Now" transparent="1" valign="top" zPosition="5">
335                                 <convert type="EventName">ExtendedDescription</convert>
336                         </widget>
337                         <widget font="Regular;22" foregroundColor="#aaaaaa" position="250,437" render="Label" size="950,225" source="session.Event_Next" transparent="1" valign="top" zPosition="5">
338                                 <convert type="EventName">ExtendedDescription</convert>
339                         </widget>
340                 </screen>"""
341
342         def __init__(self, session):
343                 Screen.__init__(self, session)
344                 self.session = session
345                 self.list = []
346                 self.__keys = []
347                 EasyInfoPluginsList = []
348                 
349                 if not config.plugins.EasyInfo.showEventInfoFirst.value:
350                         self.skinName = "EasyInfo"
351                 else:
352                         self.skinName = "EventViewWithEasyInfo"
353                 
354
355                 self["key_info"] = StaticText(" ")
356                 self["key_yellow"] = StaticText(" ")
357                 self["key_green"] = StaticText(" ")
358                 self["key_red"] = StaticText(" ")
359                 self["key_blue"] = StaticText(" ")
360                 
361                 self["list"] = EasyInfoPanelList(self.getMenuItems())
362                 self["actions"] = ActionMap(["WizardActions", "MenuActions", "ColorActions", "EPGSelectActions"],
363                 {
364                         "ok": self.okPressed,
365                         "back": self.cancel,
366                         "menu": self.openConfig,
367                         "green": self.greenPressed,
368                         "red": self.redPressed,
369                         "blue": self.bluePressed,
370                         "yellow": self.yellowPressed,
371                         "info": self.infoPressed
372                 }, -1)
373
374         def getMenuItems(self):
375                 list = []
376                 if config.plugins.EasyInfo.pos1.value != "no":
377                         self["key_info"].setText(_(getPluginByName(config.plugins.EasyInfo.pos1.value)))
378                         list.append((config.plugins.EasyInfo.pos1.value,"info"))
379                 if config.plugins.EasyInfo.pos2.value != "no":
380                         self["key_red"].setText(_(getPluginByName(config.plugins.EasyInfo.pos2.value)))
381                         list.append((config.plugins.EasyInfo.pos2.value,"red"))
382                 if config.plugins.EasyInfo.pos3.value != "no":
383                         self["key_green"].setText(_(getPluginByName(config.plugins.EasyInfo.pos3.value)))
384                         list.append((config.plugins.EasyInfo.pos3.value,"green"))
385                 if config.plugins.EasyInfo.pos4.value != "no":
386                         self["key_yellow"].setText(_(getPluginByName(config.plugins.EasyInfo.pos4.value)))
387                         list.append((config.plugins.EasyInfo.pos4.value,"yellow"))                      
388                 if config.plugins.EasyInfo.pos5.value != "no":
389                         self["key_blue"].setText(_(getPluginByName(config.plugins.EasyInfo.pos5.value)))
390                         list.append((config.plugins.EasyInfo.pos5.value,"blue"))
391                 if config.plugins.EasyInfo.pos6.value != "no":
392                         list.append((config.plugins.EasyInfo.pos6.value,"x"))
393                 if config.plugins.EasyInfo.pos7.value != "no":
394                         list.append((config.plugins.EasyInfo.pos7.value,"x"))
395                 if config.plugins.EasyInfo.pos8.value != "no":
396                         list.append((config.plugins.EasyInfo.pos8.value,"x"))
397                 if config.plugins.EasyInfo.pos9.value != "no":
398                         list.append((config.plugins.EasyInfo.pos9.value,"x"))
399                 if config.plugins.EasyInfo.pos10.value != "no":
400                         list.append((config.plugins.EasyInfo.pos10.value,"x"))
401                 if config.plugins.EasyInfo.pos11.value != "no":
402                         list.append((config.plugins.EasyInfo.pos11.value,"x"))  
403                         
404                 return list
405
406         def cancel(self):
407                 self.close(None)
408
409         def okPressed(self):
410                 currentSelection = self["list"].l.getCurrentSelection()
411                 print "answer", currentSelection
412                 if currentSelection:
413                         EasyInfoCallbackFunc(currentSelection[0])
414
415         def openConfig(self):
416                 self.session.openWithCallback(self.configCallback, EasyInfoConfig)
417
418         def configCallback(self):
419                 self["list"].setList(self.getMenuItems())
420
421         def infoPressed(self):
422                 self["list"].moveToIndex(0)
423                 self.okPressed()
424
425         def redPressed(self):
426                 self["list"].moveToIndex(1)
427                 self.okPressed()
428
429         def greenPressed(self):
430                 self["list"].moveToIndex(2)
431                 self.okPressed()
432
433         def yellowPressed(self):
434                 self["list"].moveToIndex(3)
435                 self.okPressed()
436
437         def bluePressed(self):
438                 self["list"].moveToIndex(4)
439                 self.okPressed()
440
441 def EasyInfoChangeBouquetCB(direction, epg):
442         global EINposition
443         IBbouquets = InfoBar_instance.servicelist.getBouquetList()
444         if EINposition>0 and direction<0:
445                 EINposition = EINposition - 1
446         elif EINposition==0 and direction<0:
447                 EINposition = len(IBbouquets) - 1
448         elif EINposition<(len(IBbouquets)-1) and direction>0:
449                 EINposition = EINposition + 1
450         elif EINposition==(len(IBbouquets)-1) and direction>0:
451                 EINposition = 0
452         InfoBarServices = InfoBar_instance.getBouquetServices(IBbouquets[EINposition][1])
453         if InfoBarServices:
454                 epg.setServices(InfoBarServices)
455
456 def EasyInfoZapTo(NewService):
457         IBbouquets = InfoBar_instance.servicelist.getBouquetList()
458         NewBbouquet = IBbouquets[EINposition][1]
459         InfoBar_instance.servicelist.clearPath()
460         if InfoBar_instance.servicelist.bouquet_root != NewBbouquet:
461                 InfoBar_instance.servicelist.enterPath(InfoBar_instance.servicelist.bouquet_root)
462         InfoBar_instance.servicelist.enterPath(NewBbouquet)
463         InfoBar_instance.servicelist.setCurrentSelection(NewService)
464         InfoBar_instance.servicelist.zap()
465
466 def EasyInfoCallbackFunc(answer):
467         if answer is None: return
468         
469         if EasyInfoSession is None: return
470         
471         if not InfoBar_instance: return
472         
473         if answer == "singleepg":
474                 ref=InfoBar_instance.servicelist.getCurrentSelection()
475                 if ref:
476                         InfoBar_instance.servicelist.savedService = ref
477                         EasyInfoSession.openWithCallback(InfoBar_instance.servicelist.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB = InfoBar_instance.servicelist.changeServiceCB)
478         elif answer == "easypg":
479                 bouquets = InfoBar_instance.servicelist.getBouquetList()
480                 if bouquets is None:
481                         cnt = 0
482                 else:
483                         cnt = len(bouquets)
484                         InfoBarServices = InfoBar_instance.getBouquetServices(InfoBar_instance.servicelist.getRoot())
485                 if cnt > 1:
486                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasyPG, InfoBarServices, EasyInfoZapTo, None, EasyInfoChangeBouquetCB))
487                 elif cnt == 1:
488                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasyPG, InfoBarServices, EasyInfoZapTo, None, None))
489         elif answer == "easysel":
490                 bouquets = InfoBar_instance.servicelist.getBouquetList()
491                 if bouquets is None:
492                         cnt = 0
493                 else:
494                         cnt = len(bouquets)
495                         InfoBarServices = InfoBar_instance.getBouquetServices(InfoBar_instance.servicelist.getRoot())
496                 if cnt > 1:
497                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasySelection, InfoBarServices, EasyInfoZapTo, None, EasyInfoChangeBouquetCB))
498                 elif cnt == 1:
499                         InfoBar_instance.dlg_stack.append(InfoBar_instance.session.open(EasySelection, InfoBarServices, EasyInfoZapTo, None, None))
500         elif answer == "timers":
501                 EasyInfoSession.open(TimerEditList)
502         elif answer == "multiepg":
503                 bouquets = InfoBar_instance.servicelist.getBouquetList()
504                 if bouquets is None:
505                         cnt = 0
506                 else:
507                         cnt = len(bouquets)
508                 if cnt > 1:
509                         InfoBar_instance.bouquetSel = EasyInfoSession.openWithCallback(InfoBar_instance.closed, BouquetSelector, bouquets, InfoBar_instance.openBouquetEPG, enableWrapAround=True)
510                         InfoBar_instance.dlg_stack.append(InfoBar_instance.bouquetSel)
511                 elif cnt == 1:
512                         InfoBar_instance.openBouquetEPG(bouquets[0][1], True)
513         elif answer == "eventinfo":
514                 epglist = [ ]
515                 InfoBar_instance.epglist = epglist
516                 service = EasyInfoSession.nav.getCurrentService()
517                 ref = EasyInfoSession.nav.getCurrentlyPlayingServiceReference()
518                 info = service.info()
519                 ptr=info.getEvent(0)
520                 if ptr:
521                         epglist.append(ptr)
522                 ptr=info.getEvent(1)
523                 if ptr:
524                         epglist.append(ptr)
525                 if epglist:
526                         EasyInfoSession.open(EventViewSimple, epglist[0], ServiceReference(ref), InfoBar_instance.eventViewCallback)
527         elif answer == "merlinepg":
528                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/MerlinEPG/plugin.pyo"):
529                         from Plugins.Extensions.MerlinEPG.plugin import Merlin_PGII, Merlin_PGd
530                         if config.plugins.MerlinEPG.Columns.value:
531                                 EasyInfoSession.open(Merlin_PGII, InfoBar_instance.servicelist)
532                         else:
533                                 EasyInfoSession.open(Merlin_PGd, InfoBar_instance.servicelist)
534                 else:
535                         EasyInfoSession.open(MessageBox, text = _('MerlinEPG is not installed!'), type = MessageBox.TYPE_INFO)
536         elif answer == "autotimer":
537                 try:
538                         from Plugins.Extensions.AutoTimer.plugin import main as AutoTimerView
539                         AutoTimerView(EasyInfoSession)
540                 except ImportError as ie:
541                         EasyInfoSession.open(MessageBox, text = _('Autotimer is not installed!'), type = MessageBox.TYPE_INFO)
542         elif answer == "epgsearch":
543                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/EPGSearch/plugin.pyo"):
544                         from Plugins.Extensions.EPGSearch.EPGSearch import EPGSearch
545                         service = EasyInfoSession.nav.getCurrentService()
546                         info = service.info()
547                         epg_event=info.getEvent(0)
548                         if epg_event:
549                                 epg_name = epg_event and epg_event.getEventName() or ''
550                                 EasyInfoSession.open(EPGSearch, epg_name, False)
551                 else:
552                         EasyInfoSession.open(MessageBox, text = _('EPGsearch is not installed!'), type = MessageBox.TYPE_INFO)
553         elif answer == "channelinfo":
554                 EasyInfoSession.open(ServiceInfo, InfoBar_instance.servicelist.getCurrentSelection())
555         elif answer == "imdbinfo":
556                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/IMDb/plugin.pyo"):
557                         from Plugins.Extensions.IMDb.plugin import IMDB
558                         service = EasyInfoSession.nav.getCurrentService()
559                         info = service.info()
560                         epg_event=info.getEvent(0)
561                         if epg_event:
562                                 IeventName = epg_event.getEventName()
563                                 EasyInfoSession.open(IMDB, IeventName)
564                 else:
565                         EasyInfoSession.open(MessageBox, text = _('IMDB is not installed!'), type = MessageBox.TYPE_INFO)
566         elif answer == "graphepg":
567                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/GraphMultiEPG/plugin.pyo"):
568                         from Plugins.Extensions.GraphMultiEPG.plugin import main as gmepgmain
569                         gmepgmain(EasyInfoSession, InfoBar_instance.servicelist)
570                 else:
571                         EasyInfoSession.open(MessageBox, text = _('GraphMultiEPG is not installed!'), type = MessageBox.TYPE_INFO)
572         elif answer == "epgrefresh":
573                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/EPGRefresh/plugin.pyo"):
574                         from Plugins.Extensions.EPGRefresh.plugin import main as epgrefmain
575                         epgrefmain(EasyInfoSession)
576                 else:
577                         EasyInfoSession.open(MessageBox, text = _('EPGRefresh is not installed!'), type = MessageBox.TYPE_INFO)
578         elif answer == "cooltv":
579                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/CoolTVGuide/plugin.pyo"):
580                         from Plugins.Extensions.CoolTVGuide.plugin import main as ctvmain
581                         ctvmain(EasyInfoSession, InfoBar_instance.servicelist)
582                 else:
583                         EasyInfoSession.open(MessageBox, text = _('CoolTVGuide is not installed!'), type = MessageBox.TYPE_INFO)
584         elif answer == "sleep":
585                 from Screens.SleepTimerEdit import SleepTimerEdit
586                 EasyInfoSession.open(SleepTimerEdit)
587         else:
588                 EasyInfoSession.open(MessageBox, text = _('This function is yet not available!'), type = MessageBox.TYPE_INFO)
589
590 class EasyInfoEventView(Screen, EventViewBase):
591         def __init__(self, session, Event, Ref, callback=None, singleEPGCB=None, multiEPGCB=None):
592                 Screen.__init__(self, session)
593                 self.session = session
594                 self.skinName = "EventView"
595                 
596                 EventViewBase.__init__(self, Event, Ref, callback=InfoBar_instance.eventViewCallback)
597                 
598                 self["key_yellow"].setText(_(getPluginByName(config.plugins.EasyInfo.eventViewYellow.value)))
599                 self["key_blue"].setText(_(getPluginByName(config.plugins.EasyInfo.eventViewBlue.value)))
600                 self["key_red"].setText(_("Similar"))
601                 
602                 self["epgactions"] = ActionMap(["EventViewEPGActions", "EPGSelectActions",  "EventViewActions"],
603                         {
604                                 "openSingleServiceEPG": self.singleEPGCB,
605                                 "openMultiServiceEPG": self.multiEPGCB,
606                                 "openSimilarList": self.openSimilarList,
607                                 "info": self.exit,
608                                 "pageUp": self.pageUp,
609                                 "pageDown": self.pageDown,
610                                 "prevEvent": self.prevEvent,
611                                 "nextEvent": self.nextEvent
612                         },-1)
613
614         def openSimilarList(self):
615                 self.hide()
616                 EasyInfoCallbackFunc("epgsearch")
617                 self.close()
618
619         def singleEPGCB(self):
620                 self.hide()
621                 EasyInfoCallbackFunc(config.plugins.EasyInfo.eventViewYellow.value)
622                 self.close()
623
624         def multiEPGCB(self):
625                 self.hide()
626                 EasyInfoCallbackFunc(config.plugins.EasyInfo.eventViewBlue.value)
627                 self.close()
628
629         def setEvent(self, event):
630                 self.event = event
631                 if event is None:
632                         return
633                 text = event.getEventName()
634                 short = event.getShortDescription()
635                 ext = event.getExtendedDescription()
636                 if short and short != text:
637                         text += '\n\n' + short
638                 if ext:
639                         if text:
640                                 text += '\n\n'
641                         text += ext
642                 self.setTitle(event.getEventName())
643                 self["epg_description"].setText(text)
644                 self["datetime"].setText(event.getBeginTimeString())
645                 self["duration"].setText(_("%d min")%(event.getDuration()/60))
646                 self["key_red"].setText(_("Similar"))
647                 serviceref = self.currentService
648                 eventid = self.event.getEventId()
649                 refstr = serviceref.ref.toString()
650                 isRecordEvent = False
651                 for timer in self.session.nav.RecordTimer.timer_list:
652                         if timer.eit == eventid and timer.service_ref.ref.toString() == refstr:
653                                 isRecordEvent = True
654                                 break
655                 if isRecordEvent and self.key_green_choice != self.REMOVE_TIMER:
656                         self["key_green"].setText(_("Remove timer"))
657                         self.key_green_choice = self.REMOVE_TIMER
658                 elif not isRecordEvent and self.key_green_choice != self.ADD_TIMER:
659                         self["key_green"].setText(_("Add timer"))
660                         self.key_green_choice = self.ADD_TIMER
661
662         def exit(self):
663                 self.hide()
664                 self.session.open(EasyInfo)
665                 self.close()
666
667 class EasyInfoEventList(EPGList):
668         SKIN_COMPONENT_KEY = "EasyInfoEventList"
669         SKIN_COMPONENT_CHANNEL_WIDTH = "ChannelWidth" # width for the first column with channelname or picon
670         SKIN_COMPONENT_TIME_WIDTH = "TimeWidth" # width for the time information
671         SKIN_COMPONENT_TIME_FUTURE_INDICATOR_WIDTH = "TimeFutureIndicatorWidth" # width for the ">"
672         SKIN_COMPONENT_TIME_OFFSET = "TimeOffset" # y position of time information including indicator
673         SKIN_COMPONENT_REMAINING_TIME_WIDTH = "RemainingTimeWidth" # width of remaining time information (below progress bar)
674         SKIN_COMPONENT_EVENTNAME_WIDTH = "EventNameWidth" # width of eventname
675         SKIN_COMPONENT_EVENTNAME_OFFSET = "EventNameOffset" # y position of eventname
676         SKIN_COMPONENT_ITEM_HEIGHT = "ItemHeight" # height of row
677         SKIN_COMPONENT_PROGRESSBAR_WIDTH = "ProgressBarWidth" # width of progress bar
678         SKIN_COMPONENT_PROGRESSBAR_HEIGHT = "ProgressBarHeight" # height of progress bar
679         SKIN_COMPONENT_CHANNEL_OFFSET = "ChannelOffset" # offset applied to the first event column
680         SKIN_COMPONENT_REC_OFFSET = "RecOffset" # offset applied when a timer exists for the event
681         SKIN_COMPONENT_REC_ICON_SIZE = "RecIconSize" # size of record icon
682
683         def __init__(self, type=EPG_TYPE_MULTI, selChangedCB=None, timer = None, hasChannelInfo=True):
684                 EPGList.__init__(self, type, selChangedCB, timer)
685                 
686                 sizes = componentSizes[EasyInfoEventList.SKIN_COMPONENT_KEY]
687                 self.channelWidth = sizes.get(EasyInfoEventList.SKIN_COMPONENT_CHANNEL_WIDTH, 120)
688                 self.timeWidth = sizes.get(EasyInfoEventList.SKIN_COMPONENT_TIME_WIDTH, 70)
689                 self.timeIndicatorWidth = sizes.get(EasyInfoEventList.SKIN_COMPONENT_TIME_FUTURE_INDICATOR_WIDTH, 10)
690                 self.eventNameWidth = sizes.get(EasyInfoEventList.SKIN_COMPONENT_EVENTNAME_WIDTH, 460)
691                 self.eventNameYOffset = sizes.get(EasyInfoEventList.SKIN_COMPONENT_EVENTNAME_OFFSET, 1)
692                 self.timeYOffset = sizes.get(EasyInfoEventList.SKIN_COMPONENT_TIME_OFFSET, 3)
693                 self.itemHeight = sizes.get(EasyInfoEventList.SKIN_COMPONENT_ITEM_HEIGHT, 50)
694                 self.recOffset = sizes.get(EasyInfoEventList.SKIN_COMPONENT_REC_OFFSET, 25)
695                 self.channelOffset = sizes.get(EasyInfoEventList.SKIN_COMPONENT_CHANNEL_OFFSET, 120)
696                 self.progressBarWidth = sizes.get(EasyInfoEventList.SKIN_COMPONENT_PROGRESSBAR_WIDTH, 40)
697                 self.progressBarHeight = sizes.get(EasyInfoEventList.SKIN_COMPONENT_PROGRESSBAR_HEIGHT, 8)
698                 self.remainingTimeWidth = sizes.get(EasyInfoEventList.SKIN_COMPONENT_REMAINING_TIME_WIDTH, 70)
699                 self.recIconSize = sizes.get(EasyInfoEventList.SKIN_COMPONENT_REC_ICON_SIZE, 16)
700                 self.piconWidth = 0
701                 self.piconHeight = 0
702
703                 tlf = TemplatedListFonts()
704                 self.l.setFont(0, gFont(tlf.face(tlf.MEDIUM), tlf.size(tlf.MEDIUM)))
705                 self.l.setFont(1, gFont(tlf.face(tlf.SMALL), tlf.size(tlf.SMALL)))
706                 self.l.setFont(2, gFont(tlf.face(tlf.SMALLER), tlf.size(tlf.SMALLER)))
707                 
708                 self.l.setItemHeight(self.itemHeight)
709                 self.l.setBuildFunc(self.buildMultiEntry)
710                 
711                 self.hasChannelInfo = hasChannelInfo
712                 self.nameCache = { }
713
714         def getPicon(self, sRef):
715                 pngname = PiconResolver.getPngName(sRef, self.nameCache, self.findPicon)
716                 if fileExists(pngname):
717                         return LoadPixmap(cached = True, path = pngname)
718                 else:
719                         return None
720                         
721         def findPicon(self, sRef):
722                 pngname = "%s%s.png" % (config.plugins.EasyInfo.piconPath.value, sRef)
723                 if not fileExists(pngname):
724                         pngname = ""
725                 return pngname
726
727         def buildMultiEntry(self, changecount, service, eventId, beginTime, duration, EventName, nowTime, service_name):
728                 (clock_pic, rec) = self.getPixmapForEntry(service, eventId, beginTime, duration)
729                 res = [ None ]
730                 
731                 channelOffset = 0
732                 recOffset = 0
733                 
734                 flagValue = RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP
735                 if self.hasChannelInfo:
736                         channelOffset = self.channelOffset
737                         
738                 if EventName is not None and len(EventName) > 60:
739                         flagValue = RT_HALIGN_LEFT|RT_VALIGN_TOP|RT_WRAP
740                 
741                 if self.hasChannelInfo:
742                         picon = self.getPicon(service)
743                         if picon is not None:
744                                 if self.piconWidth == 0:
745                                         self.piconWidth = picon.size().width()
746                                 if self.piconHeight == 0:
747                                         self.piconHeight = picon.size().height()
748                                 res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHABLEND, (self.channelWidth-self.piconWidth)/2, (self.itemHeight-self.piconHeight)/2, self.piconWidth, self.piconHeight, picon))
749                         else:
750                                 res.append((eListboxPythonMultiContent.TYPE_TEXT, 0, 0, self.channelWidth, self.itemHeight, 1, RT_HALIGN_CENTER|RT_VALIGN_CENTER|RT_WRAP, service_name))
751                 
752                 if rec:
753                         res.append((eListboxPythonMultiContent.TYPE_PIXMAP_ALPHATEST, self.timeIndicatorWidth+self.timeWidth+channelOffset, (self.itemHeight-self.recIconSize)/2, self.recIconSize, self.recIconSize, clock_pic)) 
754                         recOffset = self.recOffset
755                                 
756                 if beginTime is not None:
757                         if nowTime < beginTime:
758                                 begin = localtime(beginTime)
759                                 end = localtime(beginTime+duration)
760                                 
761                                 res.extend((
762                                         (eListboxPythonMultiContent.TYPE_TEXT, channelOffset, self.timeYOffset, self.timeIndicatorWidth, self.itemHeight-2*self.timeYOffset, 1, RT_HALIGN_RIGHT, '>'),
763                                         (eListboxPythonMultiContent.TYPE_TEXT, self.timeIndicatorWidth+channelOffset, self.timeYOffset, self.timeWidth, self.itemHeight-2*self.timeYOffset, 1, RT_HALIGN_LEFT, "%02d.%02d\n%02d.%02d"%(begin[3],begin[4],end[3],end[4])),
764                                         (eListboxPythonMultiContent.TYPE_TEXT, self.timeIndicatorWidth+self.timeWidth+channelOffset+recOffset, self.eventNameYOffset, self.eventNameWidth-recOffset, self.itemHeight-2*self.eventNameYOffset, 0, flagValue, EventName)
765                                 ))
766                         else:
767                                 percent = (nowTime - beginTime)*100/duration
768                                 remaining = ((beginTime+duration)-nowTime)
769                                 
770                                 res.extend((
771                                         (eListboxPythonMultiContent.TYPE_PROGRESS, (self.remainingTimeWidth-self.progressBarWidth)/2+channelOffset, (self.itemHeight/2-self.progressBarHeight)/2, self.progressBarWidth, self.progressBarHeight, percent),
772                                         (eListboxPythonMultiContent.TYPE_TEXT, self.timeIndicatorWidth+channelOffset, self.itemHeight/2, self.remainingTimeWidth, self.itemHeight/2, 1, RT_HALIGN_LEFT, "+%d:%02d" % (remaining/3600, (remaining/60)-((remaining /3600)*60))),
773                                         (eListboxPythonMultiContent.TYPE_TEXT, self.timeIndicatorWidth+self.timeWidth+channelOffset+recOffset, self.eventNameYOffset, self.eventNameWidth-recOffset, self.itemHeight-2*self.eventNameYOffset, 0, flagValue, EventName)
774                                 ))
775                 return res
776
777         def moveToService(self,serviceref):
778                 if not serviceref:
779                         return
780                 index = 0
781                 refstr = serviceref.toString()
782                 for x in self.list:
783                         if x[1] == refstr:
784                                 self.instance.moveSelectionTo(index)
785                                 break
786                         index += 1
787                 if x[1] != refstr:
788                         self.instance.moveSelectionTo(0)
789                         
790 class EasyPG(EPGSelection, Screen):
791         skin = """
792                 <screen name="NewEasyPG" backgroundColor="#101220" flags="wfNoBorder" position="center,0" size="1280,720" title="Easy PG">
793                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="60,35" size="660,650" zPosition="-1"/>
794                         <widget font="Regular;20" position="785,30" render="Label" size="202,25" source="global.CurrentTime" transparent="1" zPosition="1">
795                                 <convert type="ClockToText">Format:%a %d. %b   %H:%M</convert>
796                         </widget>
797                         <widget backgroundColor="#ff000000" position="755,125" render="Pig" size="497,280" source="session.VideoPicture" zPosition="1"/>
798                         <widget foregroundColor="#fcc000" font="Regular;20" name="date" position="755,415" size="100,25" transparent="1"/>
799                         <widget name="list" position="60,35" scrollbarMode="showNever" size="660,650" transparent="1"/>
800                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-red.png" position="785,65" size="5,20"/>
801                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-green.png" position="785,90" size="5,20"/>
802                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-yellow.png" position="1005,65" size="5,20"/>
803                         <ePixmap alphatest="blend" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/key-blue.png" position="1005,90" size="5,20"/>
804                         <eLabel font="Regular;18" position="800,63" size="150,25" text="Similar" transparent="1"/>
805                         <eLabel font="Regular;18" position="800,90" size="150,25" text="Timer" transparent="1"/>
806                         <eLabel font="Regular;18" position="1015,63" size="150,25" text="Back" transparent="1"/>
807                         <eLabel font="Regular;18" position="1015,90" size="150,25" text="Next" transparent="1"/>
808                         <widget font="Regular;20" halign="right" position="870,415" render="Label" size="70,25" source="Event" transparent="1" zPosition="1">
809                                 <convert type="EventTime">StartTime</convert>
810                                 <convert type="ClockToText">Default</convert>
811                         </widget>
812                         <eLabel font="Regular;18" position="945,415" size="10,25" text="-" transparent="1"/>
813                         <widget font="Regular;20" position="955,415" render="Label" size="70,25" source="Event" transparent="1" zPosition="1">
814                                 <convert type="EventTime">EndTime</convert>
815                                 <convert type="ClockToText">Default</convert>
816                         </widget>
817                         <widget font="Regular;20" position="1050,415" render="Label" size="171,25" source="Event" transparent="1" zPosition="1">
818                         <convert type="EventTime">Duration</convert>
819                                 <convert type="ClockToText">InMinutes</convert>
820                         </widget>
821                         <widget font="Regular;20" position="755,445" render="Label" size="480,25" source="Event" transparent="1" zPosition="2" noWrap="1">
822                                 <convert type="EventName">ShortDescription</convert>
823                         </widget>
824                         <widget font="Regular;18" position="755,475" render="Label" size="480,210" source="Event" transparent="1" zPosition="3">
825                                 <convert type="EventName">ExtendedDescription</convert>
826                         </widget>
827                 </screen>"""
828
829         def __init__(self, session, service, zapFunc=None, eventid=None, bouquetChangeCB=None, serviceChangeCB=None):
830                 Screen.__init__(self, session)
831                 EPGSelection.__init__(self, session, service, zapFunc, eventid, bouquetChangeCB, serviceChangeCB)
832                 EPGSelection.skinName = "NewEasyPG"
833                 self.skinName = "NewEasyPG"
834                 
835                 global EINposition
836                 EINposition = 0
837                 allbouq = InfoBar_instance.servicelist.getBouquetList()
838                 for newpos in range(0, len(allbouq)):
839                         if InfoBar_instance.servicelist.getRoot() == allbouq[newpos][1]:
840                                 EINposition = newpos
841                                 break
842                 
843                 self.initPrimeTime = False
844                 self.session = session
845
846                 self.primeTimeHour = config.plugins.EasyInfo.primeTime2.value[0]
847                 self.primeTimeMinute = config.plugins.EasyInfo.primeTime2.value[1]
848                 
849                 self["list"] = EasyInfoEventList(type = EPG_TYPE_MULTI, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
850
851                 self.refreshTimer = eTimer()
852                 self.refreshTimer_conn = self.refreshTimer.timeout.connect(self.refreshEPG)
853                 
854                 self["actions"] = ActionMap(["EPGSelectActions", "OkCancelActions", "NumberActions", "InfobarActions"],
855                         {
856                                 "cancel": self.closeScreen,
857                                 "ok": self.okPressed,
858                                 "timerAdd": self.timerAdd,
859                                 "yellow": self.yellowButtonPressed,
860                                 "blue": self.blueButtonPressed,
861                                 "info": self.infoKeyPressed,
862                                 "red": self.redButtonPressed,
863                                 "input_date_time": self.openContextMenu,
864                                 "nextBouquet": self.nextBouquet,
865                                 "prevBouquet": self.prevBouquet,
866                                 "nextService": self.goToPrimeTimeNextDay,
867                                 "prevService": self.goToPrimeTimePreviousDay,
868                                 "showMovies": self.enterDateTime,
869                                 "showTv": self.zapTo,
870                                 "showRadio": self.zapAndRefresh,
871                                 "0": self.goToCurrentTime,
872                                 "1": self.setPrimeTime1,
873                                 "2": self.setPrimeTime2,
874                                 "3": self.setPrimeTime3
875                         },-1)
876
877         def closeScreen(self):
878                 self.close(True)
879
880         def goToCurrentTime(self):
881                 self["list"].fillMultiEPG(self.services, -1)
882                 self.initPrimeTime = False
883
884         def setNewPrimeTime(self):
885                 today = localtime()
886                 primetime = (today[0],today[1],today[2],self.primeTimeHour,self.primeTimeMinute,0,today[6],today[7],0)
887                 self.ask_time = int(mktime(primetime))
888                 self.initPrimeTime = True
889                 if self.ask_time > int(mktime(today)):
890                         self["list"].fillMultiEPG(self.services, self.ask_time)
891
892         def okPressed(self):
893                 if  config.plugins.EasyInfo.easyPGOK.value == "exitzap":
894                         self.zapTo()
895                         self.close(True)
896                 elif config.plugins.EasyInfo.easyPGOK.value == "zap":
897                         self.zapTo()
898                 else:
899                         self.infoKeyPressed()
900
901         def redButtonPressed(self):
902                 if fileExists("/usr/lib/enigma2/python/Plugins/Extensions/EPGSearch/plugin.pyo"):
903                         from Plugins.Extensions.EPGSearch.EPGSearch import EPGSearch
904                         epg_event = self["list"].getCurrent()[0]
905                         if epg_event:
906                                 epg_name = epg_event and epg_event.getEventName() or ''
907                                 self.session.open(EPGSearch, epg_name, False)
908                 else:
909                         self.session.open(MessageBox, text = _('EPGsearch is not installed!'), type = MessageBox.TYPE_INFO)
910
911         def goToPrimeTimeNextDay(self):
912                 if not self["list"].getCurrent()[0]:
913                         return
914                 today = localtime()
915                 if not self.initPrimeTime:
916                         primetime = (today[0],today[1],today[2],self.primeTimeHour,self.primeTimeMinute,0,today[6],today[7],0)
917                         self.ask_time = int(mktime(primetime))
918                         self.initPrimeTime = True
919                         if self.ask_time < int(mktime(today)):
920                                 self.ask_time = self.ask_time + 86400
921                 else:
922                         self.ask_time = self.ask_time + 86400
923                 self["list"].fillMultiEPG(self.services, self.ask_time)
924
925         def goToPrimeTimePreviousDay(self):
926                 today = localtime()
927                 if not self.initPrimeTime:
928                         primetime = (today[0],today[1],today[2],self.primeTimeHour,self.primeTimeMinute,0,today[6],today[7],0)
929                         self.ask_time = int(mktime(primetime))
930                         self.initPrimeTime = True
931                 else:
932                         self.ask_time = self.ask_time - 86400
933                 if self.ask_time > int(mktime(today)):
934                         self["list"].fillMultiEPG(self.services, self.ask_time)
935                 else:
936                         self["list"].fillMultiEPG(self.services, -1)
937                         self.initPrimeTime = False
938
939         def setPrimeTime1(self):
940                 self.primeTimeHour = config.plugins.EasyInfo.primeTime1.value[0]
941                 self.primeTimeMinute = config.plugins.EasyInfo.primeTime1.value[1]
942                 self.setNewPrimeTime()
943
944         def setPrimeTime2(self):
945                 self.primeTimeHour = config.plugins.EasyInfo.primeTime2.value[0]
946                 self.primeTimeMinute = config.plugins.EasyInfo.primeTime2.value[1]
947                 self.setNewPrimeTime()
948
949         def setPrimeTime3(self):
950                 self.primeTimeHour = config.plugins.EasyInfo.primeTime3.value[0]
951                 self.primeTimeMinute = config.plugins.EasyInfo.primeTime3.value[1]
952                 self.setNewPrimeTime()
953
954         def openContextMenu(self):
955                 self.session.open(EasyInfoConfig)
956
957         def zapAndRefresh(self):
958                 self.zapTo()
959                 self.refreshTimer.start(4000, True)
960
961         def refreshEPG(self):
962                 self.refreshTimer.stop()
963                 self.GoFirst()
964
965 class EasySelection(EPGSelection, Screen):
966         skin = """
967                 <screen name="NewEasySelection" backgroundColor="background" flags="wfNoBorder" position="center,0" size="1240,720" title="Easy Selection">
968                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="20,35" size="660,650" zPosition="-1" scale="stretch" />
969                         <ePixmap alphatest="on" pixmap="/usr/lib/enigma2/python/Plugins/Extensions/EasyInfo/lines.png" position="680,35" size="540,650" zPosition="-1" scale="stretch" />
970                         <widget name="list" position="20,35" scrollbarMode="showNever" size="660,650" transparent="1"/>
971                         <widget name="listNext" position="680,35" scrollbarMode="showNever" size="540,650" transparent="1"/>
972                 </screen>"""
973
974         def __init__(self, session, service, zapFunc=None, eventid=None, bouquetChangeCB=None, serviceChangeCB=None):
975                 Screen.__init__(self, session)
976                 EPGSelection.__init__(self, session, service, zapFunc, eventid, bouquetChangeCB, serviceChangeCB)
977                 EPGSelection.skinName = "NewEasySelection"
978                 self.skinName = "NewEasySelection"
979                 
980                 global EINposition
981                 EINposition = 0
982                 bouquets = InfoBar_instance.servicelist.getBouquetList()
983                 for pos in range(0, len(bouquets)):
984                         if InfoBar_instance.servicelist.getRoot() == bouquets[pos][1]:
985                                 EINposition = pos
986                                 break
987                 
988                 self.session = session
989
990                 self["list"] = EasyInfoEventList(type = EPG_TYPE_MULTI, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer)
991                 self["listNext"] = EasyInfoEventList(type = EPG_TYPE_MULTI, selChangedCB = self.onSelectionChanged, timer = session.nav.RecordTimer, hasChannelInfo=False)
992
993                 self["actions"] = ActionMap(["EPGSelectActions", "OkCancelActions", "DirectionActions"],
994                         {
995                                 "cancel": self.closeScreen,
996                                 "ok": self.okPressed,
997                                 "info": self.infoKeyPressed,
998                                 "nextBouquet": self.nextBouquet,
999                                 "prevBouquet": self.prevBouquet,
1000                                 "right": self.rightPressed,
1001                                 "rightRepeated": self.rightPressed,
1002                                 "left": self.leftPressed,
1003                                 "leftRepeated": self.leftPressed,
1004                                 "up": self.upPressed,
1005                                 "upRepeated": self.upPressed,
1006                                 "down": self.downPressed,
1007                                 "downRepeated": self.downPressed,
1008                                 "nextService": self.setModePrimeTime,
1009                                 "prevService": self.setModeNowNext,
1010                         },-1)
1011                 
1012                 self.onLayoutFinish.append(self.layoutFinished)
1013
1014         def layoutFinished(self):
1015                 self["listNext"].fillMultiEPG(self.services, -1)
1016                 self["listNext"].moveToService(self.session.nav.getCurrentlyPlayingServiceReference())
1017                 self["listNext"].updateMultiEPG(1)
1018
1019         def closeScreen(self):
1020                 self.close(True)
1021
1022         def okPressed(self):
1023                 self.zapTo()
1024                 self.close(True)
1025
1026         def leftPressed(self):
1027                 self["list"].instance.moveSelection(self["list"].instance.pageUp)
1028                 self["listNext"].instance.moveSelection(self["list"].instance.pageUp)
1029
1030         def rightPressed(self):
1031                 self["list"].instance.moveSelection(self["list"].instance.pageDown)
1032                 self["listNext"].instance.moveSelection(self["list"].instance.pageDown)
1033
1034         def upPressed(self):
1035                 self["list"].moveUp()
1036                 self["listNext"].moveUp()
1037
1038         def downPressed(self):
1039                 self["list"].moveDown()
1040                 self["listNext"].moveDown()
1041
1042         def nextBouquet(self):
1043                 if self.bouquetChangeCB:
1044                         self.bouquetChangeCB(1, self)
1045                         self.layoutFinished()
1046
1047         def prevBouquet(self):
1048                 if self.bouquetChangeCB:
1049                         self.bouquetChangeCB(-1, self)
1050                         self.layoutFinished()
1051
1052         def setModePrimeTime(self):
1053                 today = localtime()
1054                 pt = (today[0],today[1],today[2],config.plugins.EasyInfo.primeTime2.value[0],config.plugins.EasyInfo.primeTime2.value[1],0,today[6],today[7],0)
1055                 ask_time = int(mktime(pt))
1056                 if ask_time > int(mktime(today)):
1057                         self["list"].fillMultiEPG(self.services, ask_time)
1058                         pt = (today[0],today[1],today[2],config.plugins.EasyInfo.primeTime3.value[0],config.plugins.EasyInfo.primeTime3.value[1],0,today[6],today[7],0)
1059                         ask_time = int(mktime(pt))
1060                         self["listNext"].fillMultiEPG(self.services, ask_time)
1061
1062         def setModeNowNext(self):
1063                 self["list"].fillMultiEPG(self.services, -1)
1064                 self["listNext"].fillMultiEPG(self.services, -1)
1065                 self["listNext"].updateMultiEPG(1)
1066
1067         def infoKeyPressed(self):
1068                 cur = self["list"].getCurrent()
1069                 service = cur[1].ref.toString()
1070                 ref = eServiceReference(service)
1071                 if ref:
1072                         InfoBar_instance.servicelist.savedService = ref
1073                         self.session.openWithCallback(InfoBar_instance.servicelist.SingleServiceEPGClosed, EPGSelection, ref, serviceChangeCB = InfoBar_instance.servicelist.changeServiceCB)