mosaic/plugin.py

Mon, 16 Jan 2012 22:56:52 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 16 Jan 2012 22:56:52 +0100
changeset 21
6bb708a2265f
child 22
61eb8a9b53a6
permissions
-rw-r--r--

Import original vendor code for correction and improvement.

michael@21 1 # -*- coding: UTF-8 -*-
michael@21 2 # Mosaic by AliAbdul
michael@21 3 from Components.ActionMap import NumberActionMap
michael@21 4 from Components.config import config, ConfigSubsection, ConfigInteger
michael@21 5 from Components.Console import Console
michael@21 6 from Components.Label import Label
michael@21 7 from Components.Language import language
michael@21 8 from Components.Pixmap import Pixmap
michael@21 9 from Components.VideoWindow import VideoWindow
michael@21 10 from enigma import eServiceCenter, eServiceReference, eTimer, getDesktop, loadPNG
michael@21 11 from os import environ
michael@21 12 from Plugins.Plugin import PluginDescriptor
michael@21 13 from Screens.ChannelSelection import BouquetSelector
michael@21 14 from Screens.MessageBox import MessageBox
michael@21 15 from Screens.Screen import Screen
michael@21 16 from Tools.Directories import resolveFilename, SCOPE_SKIN_IMAGE, SCOPE_LANGUAGE, SCOPE_PLUGINS
michael@21 17 from Tools.LoadPixmap import LoadPixmap
michael@21 18 import gettext
michael@21 19
michael@21 20 ################################################
michael@21 21
michael@21 22 grab_binary = "/usr/bin/grab"
michael@21 23 grab_picture = "/tmp/mosaic.jpg"
michael@21 24 grab_errorlog = "/tmp/mosaic.log"
michael@21 25
michael@21 26 config_limits = (3, 30)
michael@21 27 config.plugins.Mosaic = ConfigSubsection()
michael@21 28 config.plugins.Mosaic.countdown = ConfigInteger(default=5, limits=config_limits)
michael@21 29
michael@21 30 playingIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/icons/ico_mp_play.png'))
michael@21 31 pausedIcon = loadPNG(resolveFilename(SCOPE_SKIN_IMAGE, 'skin_default/icons/ico_mp_pause.png'))
michael@21 32
michael@21 33 ################################################
michael@21 34
michael@21 35 lang = language.getLanguage()
michael@21 36 environ["LANGUAGE"] = lang[:2]
michael@21 37 gettext.bindtextdomain("enigma2", resolveFilename(SCOPE_LANGUAGE))
michael@21 38 gettext.textdomain("enigma2")
michael@21 39 gettext.bindtextdomain("Mosaic", "%s%s" % (resolveFilename(SCOPE_PLUGINS), "Extensions/Mosaic/locale/"))
michael@21 40
michael@21 41 def _(txt):
michael@21 42 t = gettext.dgettext("Mosaic", txt)
michael@21 43 if t == txt:
michael@21 44 t = gettext.gettext(txt)
michael@21 45 return t
michael@21 46
michael@21 47 ################################################
michael@21 48
michael@21 49 class Mosaic(Screen):
michael@21 50 PLAY = 0
michael@21 51 PAUSE = 1
michael@21 52
michael@21 53 desktop = getDesktop(0)
michael@21 54 size = desktop.size()
michael@21 55 width = size.width()
michael@21 56 height = size.height()
michael@21 57 windowWidth = width / 4
michael@21 58 windowHeight = height / 4
michael@21 59
michael@21 60 positions = []
michael@21 61 x = 80
michael@21 62 y = 50
michael@21 63 for i in range(1, 10):
michael@21 64 positions.append([x, y])
michael@21 65 x += windowWidth
michael@21 66 x += ((width - 160) - (windowWidth * 3)) / 2
michael@21 67 if (i == 3) or (i == 6):
michael@21 68 y = y + windowHeight + 20
michael@21 69 x = 80
michael@21 70
michael@21 71 skin = ""
michael@21 72 skin += """<screen position="0,0" size="%d,%d" title="Mosaic" flags="wfNoBorder" backgroundColor="#ffffff" >""" % (width, height)
michael@21 73 skin += """<widget name="playState" position="55,55" size="16,16" alphatest="on" />"""
michael@21 74 skin += """<eLabel position="%d,%d" size="%d,%d" />""" % (positions[0][0]-2, positions[0][1]-1, windowWidth, windowHeight)
michael@21 75 skin += """<eLabel position="%d,%d" size="%d,%d" />""" % (positions[1][0]-2, positions[1][1]-1, windowWidth, windowHeight)
michael@21 76 skin += """<eLabel position="%d,%d" size="%d,%d" />""" % (positions[2][0]-2, positions[2][1]-1, windowWidth, windowHeight)
michael@21 77 skin += """<eLabel position="%d,%d" size="%d,%d" />""" % (positions[3][0]-2, positions[3][1]-1, windowWidth, windowHeight)
michael@21 78 skin += """<eLabel position="%d,%d" size="%d,%d" />""" % (positions[4][0]-2, positions[4][1]-1, windowWidth, windowHeight)
michael@21 79 skin += """<eLabel position="%d,%d" size="%d,%d" />""" % (positions[5][0]-2, positions[5][1]-1, windowWidth, windowHeight)
michael@21 80 skin += """<eLabel position="%d,%d" size="%d,%d" />""" % (positions[6][0]-2, positions[6][1]-1, windowWidth, windowHeight)
michael@21 81 skin += """<eLabel position="%d,%d" size="%d,%d" />""" % (positions[7][0]-2, positions[7][1]-1, windowWidth, windowHeight)
michael@21 82 skin += """<eLabel position="%d,%d" size="%d,%d" />""" % (positions[8][0]-2, positions[8][1]-1, windowWidth, windowHeight)
michael@21 83 skin += """<widget name="channel1" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (positions[0][0], positions[0][1]-18, windowWidth-4)
michael@21 84 skin += """<widget name="channel2" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (positions[1][0], positions[1][1]-18, windowWidth-4)
michael@21 85 skin += """<widget name="channel3" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (positions[2][0], positions[2][1]-18, windowWidth-4)
michael@21 86 skin += """<widget name="channel4" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (positions[3][0], positions[3][1]-18, windowWidth-4)
michael@21 87 skin += """<widget name="channel5" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (positions[4][0], positions[4][1]-18, windowWidth-4)
michael@21 88 skin += """<widget name="channel6" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (positions[5][0], positions[5][1]-18, windowWidth-4)
michael@21 89 skin += """<widget name="channel7" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (positions[6][0], positions[6][1]-18, windowWidth-4)
michael@21 90 skin += """<widget name="channel8" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (positions[7][0], positions[7][1]-18, windowWidth-4)
michael@21 91 skin += """<widget name="channel9" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (positions[8][0], positions[8][1]-18, windowWidth-4)
michael@21 92 skin += """<widget name="window1" position="%d,%d" zPosition="1" size="%d,%d" />""" % (positions[0][0]-2, positions[0][1]-1, windowWidth, windowHeight)
michael@21 93 skin += """<widget name="window2" position="%d,%d" zPosition="1" size="%d,%d" />""" % (positions[1][0]-2, positions[1][1]-1, windowWidth, windowHeight)
michael@21 94 skin += """<widget name="window3" position="%d,%d" zPosition="1" size="%d,%d" />""" % (positions[2][0]-2, positions[2][1]-1, windowWidth, windowHeight)
michael@21 95 skin += """<widget name="window4" position="%d,%d" zPosition="1" size="%d,%d" />""" % (positions[3][0]-2, positions[3][1]-1, windowWidth, windowHeight)
michael@21 96 skin += """<widget name="window5" position="%d,%d" zPosition="1" size="%d,%d" />""" % (positions[4][0]-2, positions[4][1]-1, windowWidth, windowHeight)
michael@21 97 skin += """<widget name="window6" position="%d,%d" zPosition="1" size="%d,%d" />""" % (positions[5][0]-2, positions[5][1]-1, windowWidth, windowHeight)
michael@21 98 skin += """<widget name="window7" position="%d,%d" zPosition="1" size="%d,%d" />""" % (positions[6][0]-2, positions[6][1]-1, windowWidth, windowHeight)
michael@21 99 skin += """<widget name="window8" position="%d,%d" zPosition="1" size="%d,%d" />""" % (positions[7][0]-2, positions[7][1]-1, windowWidth, windowHeight)
michael@21 100 skin += """<widget name="window9" position="%d,%d" zPosition="1" size="%d,%d" />""" % (positions[8][0]-2, positions[8][1]-1, windowWidth, windowHeight)
michael@21 101 skin += """<widget name="video1" position="%d,%d" zPosition="2" size="%d,%d" backgroundColor="#ffffffff" />""" % (positions[0][0]-2, positions[0][1]-1, windowWidth, windowHeight)
michael@21 102 skin += """<widget name="video2" position="%d,%d" zPosition="2" size="%d,%d" backgroundColor="#ffffffff" />""" % (positions[1][0]-2, positions[1][1]-1, windowWidth, windowHeight)
michael@21 103 skin += """<widget name="video3" position="%d,%d" zPosition="2" size="%d,%d" backgroundColor="#ffffffff" />""" % (positions[2][0]-2, positions[2][1]-1, windowWidth, windowHeight)
michael@21 104 skin += """<widget name="video4" position="%d,%d" zPosition="2" size="%d,%d" backgroundColor="#ffffffff" />""" % (positions[3][0]-2, positions[3][1]-1, windowWidth, windowHeight)
michael@21 105 skin += """<widget name="video5" position="%d,%d" zPosition="2" size="%d,%d" backgroundColor="#ffffffff" />""" % (positions[4][0]-2, positions[4][1]-1, windowWidth, windowHeight)
michael@21 106 skin += """<widget name="video6" position="%d,%d" zPosition="2" size="%d,%d" backgroundColor="#ffffffff" />""" % (positions[5][0]-2, positions[5][1]-1, windowWidth, windowHeight)
michael@21 107 skin += """<widget name="video7" position="%d,%d" zPosition="2" size="%d,%d" backgroundColor="#ffffffff" />""" % (positions[6][0]-2, positions[6][1]-1, windowWidth, windowHeight)
michael@21 108 skin += """<widget name="video8" position="%d,%d" zPosition="2" size="%d,%d" backgroundColor="#ffffffff" />""" % (positions[7][0]-2, positions[7][1]-1, windowWidth, windowHeight)
michael@21 109 skin += """<widget name="video9" position="%d,%d" zPosition="2" size="%d,%d" backgroundColor="#ffffffff" />""" % (positions[8][0]-2, positions[8][1]-1, windowWidth, windowHeight)
michael@21 110 skin += """<widget name="event1" position="%d,%d" size="%d,20" zPosition="3" font="Regular;18" backgroundColor="#000000" foregroundColor="#ffffff" />""" % (positions[0][0]-2, positions[0][1]-1, windowWidth)
michael@21 111 skin += """<widget name="event2" position="%d,%d" size="%d,20" zPosition="3" font="Regular;18" backgroundColor="#000000" foregroundColor="#ffffff" />""" % (positions[1][0]-2, positions[1][1]-1, windowWidth)
michael@21 112 skin += """<widget name="event3" position="%d,%d" size="%d,20" zPosition="3" font="Regular;18" backgroundColor="#000000" foregroundColor="#ffffff" />""" % (positions[2][0]-2, positions[2][1]-1, windowWidth)
michael@21 113 skin += """<widget name="event4" position="%d,%d" size="%d,20" zPosition="3" font="Regular;18" backgroundColor="#000000" foregroundColor="#ffffff" />""" % (positions[3][0]-2, positions[3][1]-1, windowWidth)
michael@21 114 skin += """<widget name="event5" position="%d,%d" size="%d,20" zPosition="3" font="Regular;18" backgroundColor="#000000" foregroundColor="#ffffff" />""" % (positions[4][0]-2, positions[4][1]-1, windowWidth)
michael@21 115 skin += """<widget name="event6" position="%d,%d" size="%d,20" zPosition="3" font="Regular;18" backgroundColor="#000000" foregroundColor="#ffffff" />""" % (positions[5][0]-2, positions[5][1]-1, windowWidth)
michael@21 116 skin += """<widget name="event7" position="%d,%d" size="%d,20" zPosition="3" font="Regular;18" backgroundColor="#000000" foregroundColor="#ffffff" />""" % (positions[6][0]-2, positions[6][1]-1, windowWidth)
michael@21 117 skin += """<widget name="event8" position="%d,%d" size="%d,20" zPosition="3" font="Regular;18" backgroundColor="#000000" foregroundColor="#ffffff" />""" % (positions[7][0]-2, positions[7][1]-1, windowWidth)
michael@21 118 skin += """<widget name="event9" position="%d,%d" size="%d,20" zPosition="3" font="Regular;18" backgroundColor="#000000" foregroundColor="#ffffff" />""" % (positions[8][0]-2, positions[8][1]-1, windowWidth)
michael@21 119
michael@21 120 skin += """<widget name="countdown" position="80,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" />""" % (height-50, windowWidth)
michael@21 121 skin += """<widget name="count" position="%d,%d" size="%d,20" font="Regular;18" backgroundColor="#ffffff" foregroundColor="#000000" halign="right" />
michael@21 122 </screen>""" % (positions[2][0] ,height-50, windowWidth)
michael@21 123
michael@21 124 def __init__(self, session, services):
michael@21 125 Screen.__init__(self, session)
michael@21 126
michael@21 127 self.session = session
michael@21 128 self.oldService = self.session.nav.getCurrentlyPlayingServiceReference()
michael@21 129 self.consoleCmd = ""
michael@21 130 self.Console = Console()
michael@21 131 self.serviceHandler = eServiceCenter.getInstance()
michael@21 132 self.ref_list = services
michael@21 133 self.window_refs = [None, None, None, None, None, None, None, None, None]
michael@21 134 self.current_refidx = 0
michael@21 135 self.current_window = 1
michael@21 136 self.countdown = config.plugins.Mosaic.countdown.value
michael@21 137 self.working = False
michael@21 138 self.state = self.PLAY
michael@21 139
michael@21 140 self["playState"] = Pixmap()
michael@21 141 for i in range(1, 10):
michael@21 142 self["window" + str(i)] = Pixmap()
michael@21 143 self["video" + str(i)] = VideoWindow(decoder=0, fb_width=self.width, fb_height=self.height)
michael@21 144 self["video" + str(i)].hide()
michael@21 145 self["channel" + str(i)] = Label("")
michael@21 146 self["event" + str(i)] = Label("")
michael@21 147 self["event" + str(i)].hide()
michael@21 148 self["video1"].decoder = 0
michael@21 149 self["video1"].show()
michael@21 150 self["countdown"] = Label()
michael@21 151 self.updateCountdownLabel()
michael@21 152 self["count"] = Label()
michael@21 153
michael@21 154 self["actions"] = NumberActionMap(["MosaicActions"],
michael@21 155 {
michael@21 156 "ok": self.exit,
michael@21 157 "cancel": self.closeWithOldService,
michael@21 158 "green": self.play,
michael@21 159 "yellow": self.pause,
michael@21 160 "channelup": self.countdownPlus,
michael@21 161 "channeldown": self.countdownMinus,
michael@21 162 "1": self.numberPressed,
michael@21 163 "2": self.numberPressed,
michael@21 164 "3": self.numberPressed,
michael@21 165 "4": self.numberPressed,
michael@21 166 "5": self.numberPressed,
michael@21 167 "6": self.numberPressed,
michael@21 168 "7": self.numberPressed,
michael@21 169 "8": self.numberPressed,
michael@21 170 "9": self.numberPressed
michael@21 171 }, prio=-1)
michael@21 172
michael@21 173 self.updateTimer = eTimer()
michael@21 174 self.updateTimer.callback.append(self.updateCountdown)
michael@21 175 self.checkTimer = eTimer()
michael@21 176 self.checkTimer.callback.append(self.checkGrab)
michael@21 177 self.checkTimer.start(500, 1)
michael@21 178
michael@21 179 def checkGrab(self):
michael@21 180 # Start the first service in the bouquet and show the service-name
michael@21 181 ref = self.ref_list[0]
michael@21 182 self.window_refs[0] = ref
michael@21 183 info = self.serviceHandler.info(ref)
michael@21 184 name = info.getName(ref).replace('\xc2\x86', '').replace('\xc2\x87', '')
michael@21 185 event_name = self.getEventName(info, ref)
michael@21 186 self["channel1"].setText(name)
michael@21 187 self["event1"].setText(event_name)
michael@21 188 self.session.nav.playService(ref)
michael@21 189 self["count"].setText(_("Channel: ") + "1 / " + str(len(self.ref_list)))
michael@21 190 self["playState"].instance.setPixmap(playingIcon)
michael@21 191 # Start updating the video-screenshots
michael@21 192 self.updateTimer.start(1, 1)
michael@21 193
michael@21 194 def exit(self, callback=None):
michael@21 195 self.deleteConsoleCallbacks()
michael@21 196 self.close()
michael@21 197
michael@21 198 def deleteConsoleCallbacks(self):
michael@21 199 if self.Console.appContainers.has_key(self.consoleCmd):
michael@21 200 del self.Console.appContainers[self.consoleCmd].dataAvail[:]
michael@21 201 del self.Console.appContainers[self.consoleCmd].appClosed[:]
michael@21 202 del self.Console.appContainers[self.consoleCmd]
michael@21 203 del self.Console.extra_args[self.consoleCmd]
michael@21 204 del self.Console.callbacks[self.consoleCmd]
michael@21 205
michael@21 206 def closeWithOldService(self):
michael@21 207 self.session.nav.playService(self.oldService)
michael@21 208 self.deleteConsoleCallbacks()
michael@21 209 self.close()
michael@21 210
michael@21 211 def numberPressed(self, number):
michael@21 212 ref = self.window_refs[number-1]
michael@21 213 if ref is not None:
michael@21 214 self.session.nav.playService(ref)
michael@21 215 self.deleteConsoleCallbacks()
michael@21 216 self.close()
michael@21 217
michael@21 218 def play(self):
michael@21 219 if self.working == False and self.state == self.PAUSE:
michael@21 220 self.state = self.PLAY
michael@21 221 self.updateTimer.start(1000, 1)
michael@21 222 self["playState"].instance.setPixmap(playingIcon)
michael@21 223
michael@21 224 def pause(self):
michael@21 225 if self.working == False and self.state == self.PLAY:
michael@21 226 self.state = self.PAUSE
michael@21 227 self.updateTimer.stop()
michael@21 228 self["playState"].instance.setPixmap(pausedIcon)
michael@21 229
michael@21 230 def countdownPlus(self):
michael@21 231 self.changeCountdown(1)
michael@21 232
michael@21 233 def countdownMinus(self):
michael@21 234 self.changeCountdown(-1)
michael@21 235
michael@21 236 def changeCountdown(self, direction):
michael@21 237 if self.working == False:
michael@21 238 configNow = config.plugins.Mosaic.countdown.value
michael@21 239 configNow += direction
michael@21 240
michael@21 241 if configNow < config_limits[0]:
michael@21 242 configNow = config_limits[0]
michael@21 243 elif configNow > config_limits[1]:
michael@21 244 configNow = config_limits[1]
michael@21 245
michael@21 246 config.plugins.Mosaic.countdown.value = configNow
michael@21 247 config.plugins.Mosaic.countdown.save()
michael@21 248
michael@21 249 self.updateCountdownLabel()
michael@21 250
michael@21 251 def makeNextScreenshot(self):
michael@21 252 # Grab video
michael@21 253 if not self.Console:
michael@21 254 self.Console = Console()
michael@21 255 self.consoleCmd = "%s -v -r %d -l -j 100 %s" % (grab_binary, self.windowWidth, grab_picture)
michael@21 256 self.Console.ePopen(self.consoleCmd, self.showNextScreenshot)
michael@21 257
michael@21 258 def showNextScreenshot(self, result, retval, extra_args):
michael@21 259 if retval == 0:
michael@21 260 # Show screenshot in the current window
michael@21 261 pic = LoadPixmap(grab_picture)
michael@21 262 self["window" + str(self.current_window)].instance.setPixmap(pic)
michael@21 263
michael@21 264 # Hide current video-window and show the running event-name
michael@21 265 self["video" + str(self.current_window)].hide()
michael@21 266 self["event" + str(self.current_window)].show()
michael@21 267
michael@21 268 # Get next ref
michael@21 269 self.current_refidx += 1
michael@21 270 if self.current_refidx > (len(self.ref_list) -1):
michael@21 271 self.current_refidx = 0
michael@21 272
michael@21 273 # Play next ref
michael@21 274 ref = self.ref_list[self.current_refidx]
michael@21 275 info = self.serviceHandler.info(ref)
michael@21 276 name = info.getName(ref).replace('\xc2\x86', '').replace('\xc2\x87', '')
michael@21 277 event_name = self.getEventName(info, ref)
michael@21 278 self.session.nav.playService(ref)
michael@21 279
michael@21 280 # Get next window index
michael@21 281 self.current_window += 1
michael@21 282 if self.current_window > 9:
michael@21 283 self.current_window = 1
michael@21 284
michael@21 285 # Save the ref
michael@21 286 self.window_refs[self.current_window-1] = ref
michael@21 287
michael@21 288 # Save the event-name and hide the label
michael@21 289 self["event" + str(self.current_window)].hide()
michael@21 290 self["event" + str(self.current_window)].setText(event_name)
michael@21 291
michael@21 292 # Show the new video-window
michael@21 293 self["video" + str(self.current_window)].show()
michael@21 294 self["video" + str(self.current_window)].decoder = 0
michael@21 295
michael@21 296 # Show the servicename
michael@21 297 self["channel" + str(self.current_window)].setText(name)
michael@21 298 self["count"].setText(_("Channel: ") + str(self.current_refidx + 1) + " / " + str(len(self.ref_list)))
michael@21 299
michael@21 300 # Restart timer
michael@21 301 self.working = False
michael@21 302 self.updateTimer.start(1, 1)
michael@21 303 else:
michael@21 304 print "[Mosaic] retval: %d result: %s" % (retval, result)
michael@21 305
michael@21 306 try:
michael@21 307 f = open(grab_errorlog, "w")
michael@21 308 f.write("retval: %d\nresult: %s" % (retval, result))
michael@21 309 f.close()
michael@21 310 except:
michael@21 311 pass
michael@21 312
michael@21 313 self.session.openWithCallback(self.exit, MessageBox, _("Error while creating screenshot. You need grab version 0.8 or higher!"), MessageBox.TYPE_ERROR, timeout=5)
michael@21 314
michael@21 315 def updateCountdown(self, callback=None):
michael@21 316 self.countdown -= 1
michael@21 317 self.updateCountdownLabel()
michael@21 318 if self.countdown == 0:
michael@21 319 self.countdown = config.plugins.Mosaic.countdown.value
michael@21 320 self.working = True
michael@21 321 self.makeNextScreenshot()
michael@21 322 else:
michael@21 323 self.updateTimer.start(1000, 1)
michael@21 324
michael@21 325 def updateCountdownLabel(self):
michael@21 326 self["countdown"].setText("%s %s / %s" % (_("Countdown:"), str(self.countdown), str(config.plugins.Mosaic.countdown.value)))
michael@21 327
michael@21 328 def getEventName(self, info, ref):
michael@21 329 event = info.getEvent(ref)
michael@21 330 if event is not None:
michael@21 331 eventName = event.getEventName()
michael@21 332 if eventName is None:
michael@21 333 eventName = ""
michael@21 334 else:
michael@21 335 eventName = ""
michael@21 336 return eventName
michael@21 337
michael@21 338 ################################################
michael@21 339 # Most stuff stolen from the GraphMultiEPG
michael@21 340
michael@21 341 Session = None
michael@21 342 Servicelist = None
michael@21 343 BouquetSelectorScreen = None
michael@21 344
michael@21 345 def getBouquetServices(bouquet):
michael@21 346 services = []
michael@21 347 Servicelist = eServiceCenter.getInstance().list(bouquet)
michael@21 348 if Servicelist is not None:
michael@21 349 while True:
michael@21 350 service = Servicelist.getNext()
michael@21 351 if not service.valid():
michael@21 352 break
michael@21 353 if service.flags & (eServiceReference.isDirectory | eServiceReference.isMarker):
michael@21 354 continue
michael@21 355 services.append(service)
michael@21 356 return services
michael@21 357
michael@21 358 def closeBouquetSelectorScreen(ret=None):
michael@21 359 if BouquetSelectorScreen is not None:
michael@21 360 BouquetSelectorScreen.close()
michael@21 361
michael@21 362 def openMosaic(bouquet):
michael@21 363 if bouquet is not None:
michael@21 364 services = getBouquetServices(bouquet)
michael@21 365 if len(services):
michael@21 366 Session.openWithCallback(closeBouquetSelectorScreen, Mosaic, services)
michael@21 367
michael@21 368 def main(session, servicelist, **kwargs):
michael@21 369 global Session
michael@21 370 Session = session
michael@21 371 global Servicelist
michael@21 372 Servicelist = servicelist
michael@21 373 global BouquetSelectorScreen
michael@21 374
michael@21 375 bouquets = Servicelist.getBouquetList()
michael@21 376 if bouquets is not None:
michael@21 377 if len(bouquets) == 1:
michael@21 378 openMosaic(bouquets[0][1])
michael@21 379 elif len(bouquets) > 1:
michael@21 380 BouquetSelectorScreen = Session.open(BouquetSelector, bouquets, openMosaic, enableWrapAround=True)
michael@21 381
michael@21 382 def Plugins(**kwargs):
michael@21 383 return PluginDescriptor(name=_("Mosaic"), where=PluginDescriptor.WHERE_EXTENSIONSMENU, fnc=main)

mercurial