fix filelist crash, add necessary import for hotplug
[enigma2.git] / lib / python / Plugins / Extensions / PicturePlayer / plugin.py
1 from enigma import ePicLoad, eTimer, getDesktop
2
3 from Screens.Screen import Screen
4 from Tools.Directories import resolveFilename, pathExists, fileExists, SCOPE_MEDIA
5 from Plugins.Plugin import PluginDescriptor
6
7 from Components.Pixmap import Pixmap, MovingPixmap
8 from Components.ActionMap import ActionMap, NumberActionMap
9 from Components.Label import Label
10 from Components.Button import Button
11 from Components.FileList import FileList
12 from Components.AVSwitch import AVSwitch
13 from Components.Sources.List import List
14 from Components.ConfigList import ConfigList
15
16 from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigText, ConfigEnableDisable, KEY_LEFT, KEY_RIGHT, KEY_0, getConfigListEntry
17
18 def getScale():
19         return AVSwitch().getFramebufferScale()
20
21 config.pic = ConfigSubsection()
22 config.pic.framesize = ConfigInteger(default=30, limits=(5, 99))
23 config.pic.slidetime = ConfigInteger(default=10, limits=(10, 60))
24 config.pic.resize = ConfigSelection(default="1", choices = [("0", _("simple")), ("1", _("better"))])
25 config.pic.cache = ConfigEnableDisable(default=True)
26 config.pic.lastDir = ConfigText(default=resolveFilename(SCOPE_MEDIA))
27 config.pic.infoline = ConfigEnableDisable(default=True)
28 config.pic.loop = ConfigEnableDisable(default=True)
29 config.pic.bgcolor = ConfigSelection(default="#00000000", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
30 config.pic.textcolor = ConfigSelection(default="#0038FF48", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))])
31
32 class picshow(Screen):
33         def __init__(self, session):
34                 self.skin = """<screen position="80,80" size="560,440" title="PicturePlayer" >
35                         <ePixmap position="0,0" size="140,40" pixmap="skin_default/buttons/red.png" alphatest="on" />
36                         <ePixmap position="140,0" size="140,40" pixmap="skin_default/buttons/green.png" alphatest="on" />
37                         <ePixmap position="280,0" size="140,40" pixmap="skin_default/buttons/yellow.png" alphatest="on" />
38                         <ePixmap position="420,0" size="140,40" pixmap="skin_default/buttons/blue.png" alphatest="on" />
39                         <widget name="key_red" position="0,0" size="140,40" font="Regular;20" backgroundColor="#9f1313" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
40                         <widget name="key_green" position="140,0" size="140,40" font="Regular;20" backgroundColor="#1f771f" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
41                         <widget name="key_yellow" position="280,0" size="140,40" font="Regular;20" backgroundColor="#a08500" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
42                         <widget name="key_blue" position="420,0" size="140,40" font="Regular;20" backgroundColor="#18188b" zPosition="2" transparent="1" shadowColor="black" shadowOffset="-1,-1" />
43                         <widget name="label" position="5,55" size="350,140" font="Regular;19" />
44                         <widget name="thn" position="360,40" size="180,160" alphatest="on" />
45                         <widget name="filelist" position="5,205" zPosition="2" size="550,230" scrollbarMode="showOnDemand" />
46                         </screen>"""
47
48                 Screen.__init__(self, session)
49
50                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions"],
51                 {
52                         "cancel": self.KeyExit,
53                         "red": self.KeyRed,
54                         "yellow": self.KeyYellow,
55                         "blue": self.KeyBlue,
56                         "ok": self.KeyOk
57                 }, -1)
58
59                 self["key_red"] = Button(_("Thumbnails"))
60                 self["key_green"] = Button()
61                 self["key_yellow"] = Button(_("Exif"))
62                 self["key_blue"] = Button(_("Setup"))
63                 self["label"] = Label()
64                 self["thn"] = Pixmap()
65
66                 currDir = config.pic.lastDir.value
67                 if not pathExists(currDir):
68                         currDir = "/"
69
70                 self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)")
71                 self["filelist"] = self.filelist
72                 self["filelist"].onSelectionChanged.append(self.selectionChanged)
73                 
74                 self.ThumbTimer = eTimer()
75                 self.ThumbTimer.callback.append(self.showThumb)
76
77                 self.picload = ePicLoad()
78                 self.picload.PictureData.get().append(self.showPic)
79                 
80                 self.onLayoutFinish.append(self.setConf)
81
82         def showPic(self, picInfo=""):
83                 ptr = self.picload.getData()
84                 if ptr != None:
85                         self["thn"].instance.setPixmap(ptr.__deref__())
86                         self["thn"].show()
87
88                 text = picInfo.split('\n',1)
89                 self["label"].setText(text[1])
90                 self["label"].show()
91                 
92         def showThumb(self):
93                 if not self.filelist.canDescent():
94                         if self.filelist.getCurrentDirectory() and self.filelist.getFilename():
95                                 if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1:
96                                         self.ThumbTimer.start(500, True)
97
98         def selectionChanged(self):
99                 if not self.filelist.canDescent():
100                         self.ThumbTimer.start(500, True)
101                 else:
102                         self["label"].hide()
103                         self["thn"].hide()
104                 
105         def KeyRed(self):
106                 #if not self.filelist.canDescent():
107                 self.session.openWithCallback(self.callbackView, Pic_Thumb, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory())
108         
109         def KeyYellow(self):
110                 if not self.filelist.canDescent():
111                         self.session.open(Pic_Exif, self.picload.getInfo(self.filelist.getCurrentDirectory() + self.filelist.getFilename()))
112         
113         def KeyBlue(self):
114                 self.session.openWithCallback(self.setConf ,Pic_Setup)
115
116         def KeyOk(self):
117                 if self.filelist.canDescent():
118                         self.filelist.descent()
119                 else:
120                         self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory())
121
122         def setConf(self):
123                 sc = getScale()
124                 #0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB)
125                 self.picload.setPara((self["thn"].instance.size().width(), self["thn"].instance.size().height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), "#00000000"))
126                 
127         def callbackView(self, val=0):
128                 if val > 0:
129                         self.filelist.moveToIndex(val)
130
131         def KeyExit(self):
132                 del self.picload
133
134                 if self.filelist.getCurrentDirectory() is None:
135                         config.pic.lastDir.value = "/"
136                 else:
137                         config.pic.lastDir.value = self.filelist.getCurrentDirectory()
138
139                 config.pic.save()
140                 self.close()
141
142 #------------------------------------------------------------------------------------------
143
144 class Pic_Setup(Screen):
145         def __init__(self, session):
146                 self.skin = """<screen position="120,180" size="480,210" title="Settings" >
147                                         <widget name="liste" position="5,5" size="470,200" />
148                                 </screen>"""
149                 Screen.__init__(self, session)
150
151                 self["actions"] = NumberActionMap(["SetupActions"],
152                 {
153                         "cancel": self.close,
154                         "left": self.keyLeft,
155                         "right": self.keyRight,
156                         "0": self.keyNumber,
157                         "1": self.keyNumber,
158                         "2": self.keyNumber,
159                         "3": self.keyNumber,
160                         "4": self.keyNumber,
161                         "5": self.keyNumber,
162                         "6": self.keyNumber,
163                         "7": self.keyNumber,
164                         "8": self.keyNumber,
165                         "9": self.keyNumber
166                 }, -1)
167                 
168                 list = []
169                 self["liste"] = ConfigList(list)
170                 list.append(getConfigListEntry(_("Slideshow Interval (sec.)"), config.pic.slidetime))
171                 list.append(getConfigListEntry(_("Scaling Mode"), config.pic.resize))
172                 list.append(getConfigListEntry(_("Cache Thumbnails"), config.pic.cache))
173                 list.append(getConfigListEntry(_("show Infoline"), config.pic.infoline))
174                 list.append(getConfigListEntry(_("Frame size in full view"), config.pic.framesize))
175                 list.append(getConfigListEntry(_("slide picture in loop"), config.pic.loop))
176                 list.append(getConfigListEntry(_("backgroundcolor"), config.pic.bgcolor))
177                 list.append(getConfigListEntry(_("textcolor"), config.pic.textcolor))
178                 
179         def keyLeft(self):
180                 self["liste"].handleKey(KEY_LEFT)
181
182         def keyRight(self):
183                 self["liste"].handleKey(KEY_RIGHT)
184                 
185         def keyNumber(self, number):
186                 self["liste"].handleKey(KEY_0 + number)
187
188 #---------------------------------------------------------------------------
189
190 class Pic_Exif(Screen):
191         def __init__(self, session, exiflist):
192                 self.skin = """<screen position="80,120" size="560,360" title="Info" >
193                                 <widget source="menu" render="Listbox" position="0,0" size="560,360" scrollbarMode="showOnDemand" selectionDisabled="1" >
194                                 <convert type="TemplatedMultiContent">
195                                         {"template": [  MultiContentEntryText(pos = (5, 5), size = (250, 30), flags = RT_HALIGN_LEFT, text = 0), MultiContentEntryText(pos = (260, 5), size = (290, 30), flags = RT_HALIGN_LEFT, text = 1)], "fonts": [gFont("Regular", 20)], "itemHeight": 30 }
196                                 </convert>
197                                 </widget>
198                         </screen>"""
199                 Screen.__init__(self, session)
200
201                 self["actions"] = ActionMap(["OkCancelActions"],
202                 {
203                         "cancel": self.close
204                 }, -1)
205                 
206                 exifdesc = [_("filename")+':', "EXIF-Version:", "Make:", "Camera:", "Date/Time:", "Width / Height:", "Flash used:", "Orientation:", "User Comments:", "Metering Mode:", "Exposure Program:", "Light Source:", "CompressedBitsPerPixel:", "ISO Speed Rating:", "X-Resolution:", "Y-Resolution:", "Resolution Unit:", "Brightness:", "Exposure Time:", "Exposure Bias:", "Distance:", "CCD-Width:", "ApertureFNumber:"]
207                 list = []
208
209                 for x in range(len(exiflist)):
210                         if x>0:
211                                 list.append((exifdesc[x], exiflist[x]))
212                         else:
213                                 name = exiflist[x].split('/')[-1]
214                                 list.append((exifdesc[x], name))
215                 self["menu"] = List(list)
216
217 #----------------------------------------------------------------------------------------
218
219 T_INDEX = 0
220 T_FRAME_POS = 1
221 T_PAGE = 2
222 T_NAME = 3
223 T_FULL = 4
224
225 class Pic_Thumb(Screen):
226         def __init__(self, session, piclist, lastindex, path):
227
228                 self.textcolor = config.pic.textcolor.value
229                 self.color = config.pic.bgcolor.value
230                 textsize = 20
231                 self.spaceX = 35
232                 self.picX = 190
233                 self.spaceY = 30
234                 self.picY = 200
235                 
236                 size_w = getDesktop(0).size().width()
237                 size_h = getDesktop(0).size().height()
238                 self.thumbsX = size_w / (self.spaceX + self.picX) # thumbnails in X
239                 self.thumbsY = size_h / (self.spaceY + self.picY) # thumbnails in Y
240                 self.thumbsC = self.thumbsX * self.thumbsY # all thumbnails
241                 
242                 self.positionlist = []
243                 skincontent = ""
244
245                 posX = -1
246                 for x in range(self.thumbsC):
247                         posY = x / self.thumbsX
248                         posX += 1
249                         if posX >= self.thumbsX:
250                                 posX = 0
251                         
252                         absX = self.spaceX + (posX*(self.spaceX + self.picX))
253                         absY = self.spaceY + (posY*(self.spaceY + self.picY))
254                         self.positionlist.append((absX, absY))
255                         skincontent += "<widget name=\"label" + str(x) + "\" position=\"" + str(absX+5) + "," + str(absY+self.picY-textsize) + "\" size=\"" + str(self.picX - 10) + ","  + str(textsize) + "\" font=\"Regular;14\" zPosition=\"2\" transparent=\"1\" noWrap=\"1\" foregroundColor=\"" + self.textcolor + "\" />"
256                 
257                         skincontent += "<widget name=\"thumb" + str(x) + "\" position=\"" + str(absX+5)+ "," + str(absY+5) + "\" size=\"" + str(self.picX -10) + "," + str(self.picY - (textsize*2)) + "\" zPosition=\"2\" transparent=\"1\" alphatest=\"on\" />"
258                 
259                 
260                 # Screen, backgroundlabel and MovingPixmap
261                 self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
262                         <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\"" + self.color + "\" /><widget name=\"frame\" position=\"35,30\" size=\"190,200\" pixmap=\"pic_frame.png\" zPosition=\"1\" alphatest=\"on\" />"  + skincontent + "</screen>"
263                 
264                 Screen.__init__(self, session)
265                 
266                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
267                 {
268                         "cancel": self.Exit,
269                         "ok": self.KeyOk,
270                         "left": self.key_left,
271                         "right": self.key_right,
272                         "up": self.key_up,
273                         "down": self.key_down,
274                         "showEventInfo": self.StartExif,
275                 }, -1)
276                 
277                 self["frame"] = MovingPixmap()
278                 for x in range(self.thumbsC):
279                         self["label"+str(x)] = Label()
280                         self["thumb"+str(x)] = Pixmap()
281                         
282                 self.Thumbnaillist = []
283                 self.filelist = []
284                 self.currPage = -1
285                 self.dirlistcount = 0
286                 self.path = path
287
288                 index = 0
289                 framePos = 0
290                 Page = 0
291                 for x in piclist:
292                         if x[0][1] == False:
293                                 self.filelist.append((index, framePos, Page, x[0][0],  path + x[0][0]))
294                                 index += 1
295                                 framePos += 1
296                                 if framePos > (self.thumbsC -1):
297                                         framePos = 0
298                                         Page += 1
299                         else:
300                                 self.dirlistcount += 1
301                 
302                 self.maxentry = len(self.filelist)-1
303                 self.index = lastindex - self.dirlistcount
304                 if self.index < 0:
305                         self.index = 0
306
307                 self.picload = ePicLoad()
308                 self.picload.PictureData.get().append(self.showPic)
309                 
310                 self.onLayoutFinish.append(self.setPicloadConf)
311                 
312                 self.ThumbTimer = eTimer()
313                 self.ThumbTimer.callback.append(self.showPic)
314
315         def setPicloadConf(self):
316                 sc = getScale()
317                 self.picload.setPara([self["thumb0"].instance.size().width(), self["thumb0"].instance.size().height(), sc[0], sc[1], config.pic.cache.value, int(config.pic.resize.value), self.color])
318                 self.paintFrame()
319
320         def paintFrame(self):
321                 #print "index=" + str(self.index)
322                 if self.maxentry < self.index or self.index < 0:
323                         return
324
325                 pos = self.positionlist[self.filelist[self.index][T_FRAME_POS]]
326                 self["frame"].moveTo( pos[0], pos[1], 1)
327                 self["frame"].startMoving()
328                 
329                 if self.currPage != self.filelist[self.index][T_PAGE]:
330                         self.currPage = self.filelist[self.index][T_PAGE]
331                         self.newPage()
332
333         def newPage(self):
334                 self.Thumbnaillist = []
335                 #clear Labels and Thumbnail
336                 for x in range(self.thumbsC):
337                         self["label"+str(x)].setText("")
338                         self["thumb"+str(x)].hide()
339                 #paint Labels and fill Thumbnail-List
340                 for x in self.filelist:
341                         if x[T_PAGE] == self.currPage:
342                                 self["label"+str(x[T_FRAME_POS])].setText("(" + str(x[T_INDEX]+1) + ") " + x[T_NAME])
343                                 self.Thumbnaillist.append([0, x[T_FRAME_POS], x[T_FULL]])
344                                 
345                 #paint Thumbnail start
346                 self.showPic()
347
348         def showPic(self, picInfo=""):
349                 for x in range(len(self.Thumbnaillist)):
350                         if self.Thumbnaillist[x][0] == 0:
351                                 if self.picload.getThumbnail(self.Thumbnaillist[x][2]) == 1: #zu tun probier noch mal
352                                         self.ThumbTimer.start(500, True)
353                                 else:
354                                         self.Thumbnaillist[x][0] = 1
355                                 break
356                         elif self.Thumbnaillist[x][0] == 1:
357                                 self.Thumbnaillist[x][0] = 2
358                                 ptr = self.picload.getData()
359                                 if ptr != None:
360                                         self["thumb" + str(self.Thumbnaillist[x][1])].instance.setPixmap(ptr.__deref__())
361                                         self["thumb" + str(self.Thumbnaillist[x][1])].show()
362
363         def key_left(self):
364                 self.index -= 1
365                 if self.index < 0:
366                         self.index = self.maxentry
367                 self.paintFrame()
368                 
369         def key_right(self):
370                 self.index += 1
371                 if self.index > self.maxentry:
372                         self.index = 0
373                 self.paintFrame()
374                 
375         def key_up(self):
376                 self.index -= self.thumbsX
377                 if self.index < 0:
378                         self.index =self.maxentry
379                 self.paintFrame()
380                 
381         def key_down(self):
382                 self.index += self.thumbsX
383                 if self.index > self.maxentry:
384                         self.index = 0
385                 self.paintFrame()
386
387         def StartExif(self):
388                 if self.maxentry < 0:
389                         return
390                 self.session.open(Pic_Exif, self.picload.getInfo(self.filelist[self.index][T_FULL]))
391
392         def KeyOk(self):
393                 if self.maxentry < 0:
394                         return
395                 self.old_index = self.index
396                 self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist, self.index, self.path)
397
398         def callbackView(self, val=0):
399                 self.index = val
400                 if self.old_index != self.index:
401                         self.paintFrame()
402         def Exit(self):
403                 del self.picload
404                 self.close(self.index + self.dirlistcount)
405
406 #---------------------------------------------------------------------------
407
408 class Pic_Full_View(Screen):
409         def __init__(self, session, filelist, index, path):
410
411                 self.textcolor = config.pic.textcolor.value
412                 self.bgcolor = config.pic.bgcolor.value
413                 space = config.pic.framesize.value
414                 size_w = getDesktop(0).size().width()
415                 size_h = getDesktop(0).size().height()
416                 
417                 self.skin = "<screen position=\"0,0\" size=\"" + str(size_w) + "," + str(size_h) + "\" flags=\"wfNoBorder\" > \
418                         <eLabel position=\"0,0\" zPosition=\"0\" size=\""+ str(size_w) + "," + str(size_h) + "\" backgroundColor=\""+ self.bgcolor +"\" /><widget name=\"pic\" position=\"" + str(space) + "," + str(space) + "\" size=\"" + str(size_w-(space*2)) + "," + str(size_h-(space*2)) + "\" zPosition=\"1\" alphatest=\"on\" /> \
419                         <widget name=\"point\" position=\""+ str(space+5) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/record.png\" alphatest=\"on\" /> \
420                         <widget name=\"play_icon\" position=\""+ str(space+25) + "," + str(space+2) + "\" size=\"20,20\" zPosition=\"2\" pixmap=\"skin_default/icons/ico_mp_play.png\"  alphatest=\"on\" /> \
421                         <widget name=\"file\" position=\""+ str(space+45) + "," + str(space) + "\" size=\""+ str(size_w-(space*2)-50) + ",25\" font=\"Regular;20\" halign=\"left\" foregroundColor=\"" + self.textcolor + "\" zPosition=\"2\" noWrap=\"1\" transparent=\"1\" /></screen>"
422
423                 Screen.__init__(self, session)
424                 
425                 self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"],
426                 {
427                         "cancel": self.Exit,
428                         "green": self.PlayPause,
429                         "yellow": self.PlayPause,
430                         "blue": self.nextPic,
431                         "red": self.prevPic,
432                         "left": self.prevPic,
433                         "right": self.nextPic,
434                         "showEventInfo": self.StartExif,
435                 }, -1)
436                 
437                 self["point"] = Pixmap()
438                 self["pic"] = Pixmap()
439                 self["play_icon"] = Pixmap()
440                 self["file"] = Label(_("please wait, loading picture..."))
441                 
442                 self.old_index = 0
443                 self.filelist = []
444                 self.lastindex = index
445                 self.currPic = []
446                 self.shownow = True
447                 self.dirlistcount = 0
448
449                 for x in filelist:
450                         if len(filelist[0]) == 3: #orig. filelist
451                                 if x[0][1] == False:
452                                         self.filelist.append(path + x[0][0])
453                                 else:
454                                         self.dirlistcount += 1
455                         else: # thumbnaillist
456                                 self.filelist.append(x[T_FULL])
457
458                 self.maxentry = len(self.filelist)-1
459                 self.index = index - self.dirlistcount
460                 if self.index < 0:
461                         self.index = 0
462                 
463                 self.picload = ePicLoad()
464                 self.picload.PictureData.get().append(self.finish_decode)
465                 
466                 self.slideTimer = eTimer()
467                 self.slideTimer.callback.append(self.slidePic)
468
469                 if self.maxentry >= 0:
470                         self.onLayoutFinish.append(self.setPicloadConf)
471
472         def setPicloadConf(self):
473                 sc = getScale()
474                 self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), sc[0], sc[1], 0, int(config.pic.resize.value), self.bgcolor])
475                 
476                 self["play_icon"].hide()
477                 if config.pic.infoline.value == False:
478                         self["file"].hide()
479                 self.start_decode()
480
481         def ShowPicture(self):
482                 if self.shownow and len(self.currPic):
483                         self.shownow = False
484                         self["file"].setText(self.currPic[0])
485                         self.lastindex = self.currPic[1]
486                         self["pic"].instance.setPixmap(self.currPic[2].__deref__())
487                         self.currPic = []
488                         
489                         self.next()
490                         self.start_decode()
491         
492         def finish_decode(self, picInfo=""):
493                 self["point"].hide()
494                 ptr = self.picload.getData()
495                 if ptr != None:
496                         text = ""
497                         try:
498                                 text = picInfo.split('\n',1)
499                                 text = "(" + str(self.index+1) + "/" + str(self.maxentry+1) + ") " + text[0].split('/')[-1]
500                         except:
501                                 pass
502                         self.currPic = []
503                         self.currPic.append(text)
504                         self.currPic.append(self.index)
505                         self.currPic.append(ptr)
506                         self.ShowPicture()
507
508         def start_decode(self):
509                 self.picload.startDecode(self.filelist[self.index])
510                 self["point"].show()
511
512         def next(self):
513                 self.index += 1
514                 if self.index > self.maxentry:
515                         self.index = 0
516
517         def prev(self):
518                 self.index -= 1
519                 if self.index < 0:
520                         self.index = self.maxentry
521
522         def slidePic(self):
523                 print "slide to next Picture index=" + str(self.lastindex)
524                 if config.pic.loop.value==False and self.lastindex == self.maxentry:
525                         self.PlayPause()
526                 self.shownow = True
527                 self.ShowPicture()
528
529         def PlayPause(self):
530                 if self.slideTimer.isActive():
531                         self.slideTimer.stop()
532                         self["play_icon"].hide()
533                 else:
534                         self.slideTimer.start(config.pic.slidetime.value*1000)
535                         self["play_icon"].show()
536                         self.nextPic()
537
538         def prevPic(self):
539                 self.currPic = []
540                 self.index = self.lastindex
541                 self.prev()
542                 self.start_decode()
543                 self.shownow = True
544
545         def nextPic(self):
546                 self.shownow = True
547                 self.ShowPicture()
548                 
549         def StartExif(self):
550                 if self.maxentry < 0:
551                         return
552                 self.session.open(Pic_Exif, self.picload.getInfo(self.filelist[self.lastindex]))
553
554         def Exit(self):
555                 del self.picload
556                 self.close(self.lastindex + self.dirlistcount)
557
558 #------------------------------------------------------------------------------------------
559
560 def main(session, **kwargs):
561         session.open(picshow)
562
563 def filescan_open(list, session, **kwargs):
564         # Recreate List as expected by PicView
565         filelist = [((file.path, False), None) for file in list]
566         session.open(Pic_Full_View, filelist, 0, file.path)
567
568 def filescan(**kwargs):
569         from Components.Scanner import Scanner, ScanPath
570
571         # Overwrite checkFile to only detect local
572         class LocalScanner(Scanner):
573                 def checkFile(self, file):
574                         return fileExists(file.path)
575
576         return \
577                 LocalScanner(mimetypes = ["image/jpeg", "image/png", "image/gif", "image/bmp"],
578                         paths_to_scan = 
579                                 [
580                                         ScanPath(path = "DCIM", with_subdirs = True),
581                                         ScanPath(path = "", with_subdirs = False),
582                                 ],
583                         name = "Pictures", 
584                         description = "View Photos...",
585                         openfnc = filescan_open,
586                 )
587
588 def Plugins(**kwargs):
589         return \
590                 [PluginDescriptor(name=_("PicturePlayer"), description=_("fileformats (BMP, PNG, JPG, GIF)"), icon="pictureplayer.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
591                  PluginDescriptor(name=_("PicturePlayer"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)]