mosaic/plugin.py

Mon, 16 Jan 2012 23:08:14 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Mon, 16 Jan 2012 23:08:14 +0100
changeset 23
d783b433388d
parent 21
6bb708a2265f
permissions
-rw-r--r--

Inconclusively complete possibly missing fields. This change introduces
inconsistencies difficult to correct given incomplete documentation of
IPKG and OPKG packaging standards.

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

mercurial