follow hotplug-ng changes
[enigma2.git] / lib / python / Plugins / Extensions / PicturePlayer / plugin.py
index bb8edd6edff197a50d7e01739af99198fcffba6b..6d41305ea20cd55e56302c8354cedcddffe71146 100644 (file)
@@ -1,5 +1,4 @@
-from enigma import *
-
+from enigma import eTimer, loadPic, getExif
 from Screens.Screen import Screen
 from Screens.ServiceInfo import ServiceInfoList, ServiceInfoListEntry
 from Components.ActionMap import ActionMap, NumberActionMap
@@ -9,13 +8,12 @@ from Components.Label import Label
 from Components.ConfigList import ConfigList
 from Components.config import *
 
-from Tools.Directories import resolveFilename, pathExists, createDir, SCOPE_MEDIA
-from Components.FileList import FileEntryComponent, FileList
+from Tools.Directories import resolveFilename, fileExists, pathExists, createDir, SCOPE_MEDIA
+from Components.FileList import FileList
 from Components.AVSwitch import AVSwitch
 
 from Plugins.Plugin import PluginDescriptor
 
-
 config.pic = ConfigSubsection()
 config.pic.slidetime = ConfigInteger(default=10, limits=(5, 60))
 config.pic.resize = ConfigSelection(default="0", choices = [("0", _("simple")), ("1", _("better"))])
@@ -96,7 +94,7 @@ class ThumbView(Screen):
                        self["label0"].setText(_("no Picture found"))
                
                self.ThumbTimer = eTimer()
-               self.ThumbTimer.timeout.get().append(self.showThumb)
+               self.ThumbTimer.callback.append(self.showThumb)
 
                self.fillPage()
                
@@ -160,7 +158,7 @@ class ThumbView(Screen):
                        ptr = loadPic(self.path + self.thumblist[self.thumbindex], 180, 160, self.aspect, int(config.pic.resize.value), int(config.pic.rotate.value),1, cachefile)
                        if ptr != None:
                                self["thumb"+str(self.thumbindex)].show()
-                               self["thumb"+str(self.thumbindex)].instance.setPixmap(ptr.__deref__())
+                               self["thumb"+str(self.thumbindex)].instance.setPixmap(ptr)
                        
                        self.thumbindex += 1
                        if self.thumbindex < 6:
@@ -246,11 +244,11 @@ class PicView(Screen):
                self["pause"] = Pixmap()
                
                self.decodeTimer = eTimer()
-               self.decodeTimer.timeout.get().append(self.decodePic)
+               self.decodeTimer.callback.append(self.decodePic)
                self.decodeTimer.start(300, True)
 
                self.slideTimer = eTimer()
-               self.slideTimer.timeout.get().append(self.slidePic)
+               self.slideTimer.callback.append(self.slidePic)
                
                
        def Pause(self):
@@ -299,7 +297,7 @@ class PicView(Screen):
                if self.currPic != None:
                        self.old = self.index
                        self["file"].setText(self.list[self.old][0] + "  (" + str(self.old+1) + "/" + str(self.maxentry+1) + ")")
-                       self["picture"].instance.setPixmap(self.currPic.__deref__())
+                       self["picture"].instance.setPixmap(self.currPic)
 
                self.next()
                self["point"].show()
@@ -454,12 +452,12 @@ class picmain(Screen):
                if not pathExists(currDir):
                        currDir = "/"
 
-               self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|png|bmp)")
+               self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)")
                self["filelist"] = self.filelist
                self["thumbnail"] = Pixmap()
                
                self.ThumbTimer = eTimer()
-               self.ThumbTimer.timeout.get().append(self.showThumb)
+               self.ThumbTimer.callback.append(self.showThumb)
                self.ThumbTimer.start(500, True)
                
        def up(self):
@@ -491,7 +489,7 @@ class picmain(Screen):
                        ptr = loadPic(self.filelist.getCurrentDirectory() + self.filelist.getFilename(), 180, 160, self.aspect, int(config.pic.resize.value), 0, 0, cachefile)
                        if ptr != None:
                                self["thumbnail"].show()
-                               self["thumbnail"].instance.setPixmap(ptr.__deref__())
+                               self["thumbnail"].instance.setPixmap(ptr)
                else:
                        self["thumbnail"].hide()
 
@@ -532,5 +530,32 @@ class picmain(Screen):
 def main(session, **kwargs):
        session.open(picmain)
 
+def filescan_open(list, session, **kwargs):
+       # Recreate List as expected by PicView
+       filelist = [((file.path, False), None) for file in list]
+       session.open(PicView, filelist, "", "")
+
+def filescan(**kwargs):
+       from Components.Scanner import Scanner, ScanPath
+
+       # Overwrite checkFile to only detect local
+       class LocalScanner(Scanner):
+               def checkFile(self, file):
+                       return fileExists(file.path)
+
+       return \
+               LocalScanner(mimetypes = ["image/jpeg", "image/png", "image/gif", "image/bmp"],
+                       paths_to_scan = 
+                               [
+                                       ScanPath(path = "DCIM", with_subdirs = True),
+                                       ScanPath(path = "", with_subdirs = False),
+                               ],
+                       name = "Pictures", 
+                       description = "View Photos...",
+                       openfnc = filescan_open,
+               )
+
 def Plugins(**kwargs):
-       return PluginDescriptor(name="PicturePlayer", description="Picture Viewer (BMP, PNG, JPG)", icon="pictureplayer.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main)
+       return \
+               [PluginDescriptor(name="PicturePlayer", description="Picture Viewer (BMP, PNG, JPG)", icon="pictureplayer.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main),
+                PluginDescriptor(name="PicturePlayer", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)]