-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
from Components.ConfigList import ConfigList
from Components.config import *
-from Tools.Directories import resolveFilename, 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
-import os
-
config.pic = ConfigSubsection()
config.pic.slidetime = ConfigInteger(default=10, limits=(5, 60))
config.pic.resize = ConfigSelection(default="0", choices = [("0", _("simple")), ("1", _("better"))])
count += 1
self.maxentry = len(self.list)-1
+ if self.maxentry < 0:
+ self["label0"].setText(_("no Picture found"))
+
self.ThumbTimer = eTimer()
self.ThumbTimer.timeout.get().append(self.showThumb)
self.fillPage()
def fillPage(self):
+ if self.maxentry < 0:
+ return
+
self["frame"].moveTo(self.poslist[self.list[self.index][3]][0], self.poslist[self.list[self.index][3]][1], 1)
self["frame"].startMoving()
cachefile = ""
if config.pic.cache.value:
cachedir = self.path + ".Thumbnails/"
- if not os.path.exists(cachedir):
- os.mkdir(cachedir)
cachefile = cachedir + self.thumblist[self.thumbindex] + str(180) + str(160) + str(self.aspect)
+ if not pathExists(cachedir):
+ if not createDir(cachedir):
+ cachefile = ""
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:
self.thumbindex = 0
def StartExif(self):
+ if self.maxentry < 0:
+ return
+
self.session.open(ExifView, self.list[self.index][1], self.list[self.index][0])
def KeyOk(self):
+ if self.maxentry < 0:
+ return
+
self.old_index = self.index
self.session.openWithCallback(self.returnView ,PicView, self.filelist, self.list[self.index][0], self.path)
self.slideOn = False
self.pauseOn = False
self.index = 0
+ self.old = 0
self.list = []
count=0
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()
}, -1)
self.aspect = getAspect()
- self.currDir = config.pic.lastDir.value
- if not os.path.exists(self.currDir):
- self.currDir = "/"
-
- self.filelist = FileList(self.currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|png|bmp)")
+ currDir = config.pic.lastDir.value
+ if not pathExists(currDir):
+ currDir = "/"
+
+ self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp)")
self["filelist"] = self.filelist
self["thumbnail"] = Pixmap()
if not self.filelist.canDescent():
cachefile = ""
if config.pic.cache.value:
- cachedir = self.currDir + ".Thumbnails/"
- if not os.path.exists(cachedir):
- os.mkdir(cachedir)
- cachefile = cachedir + self.filelist.getSelection()[0] + str(180) + str(160) + str(self.aspect)
+ cachedir = self.filelist.getCurrentDirectory() + ".Thumbnails/"
+ cachefile = cachedir + self.filelist.getFilename() + str(180) + str(160) + str(self.aspect)
+ if not pathExists(cachedir):
+ if not createDir(cachedir):
+ cachefile = ""
- ptr = loadPic(self.currDir + self.filelist.getSelection()[0], 180, 160, self.aspect, int(config.pic.resize.value), 0, 0, cachefile)
+ 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()
def KeyOk(self):
if self.filelist.canDescent():
- self.currDir = self.filelist.getSelection()[0]
self.filelist.descent()
else:
- self.session.openWithCallback(self.returnVal, PicView, self.filelist.getFileList(), self.filelist.getSelection()[0], self.currDir)
+ self.session.openWithCallback(self.returnVal, PicView, self.filelist.getFileList(), self.filelist.getFilename(), self.filelist.getCurrentDirectory())
def StartThumb(self):
- self.session.openWithCallback(self.returnVal, ThumbView, self.filelist.getFileList(), self.filelist.getSelection()[0], self.currDir)
+ self.session.openWithCallback(self.returnVal, ThumbView, self.filelist.getFileList(), self.filelist.getFilename(), self.filelist.getCurrentDirectory())
def returnVal(self, val=0):
- print val
+ if val > 0:
+ for x in self.filelist.getFileList():
+ if x[0][1] == True:
+ val += 1
+ self.filelist.moveToIndex(val)
def StartExif(self):
if not self.filelist.canDescent():
- self.session.open(ExifView, self.currDir + self.filelist.getSelection()[0], self.filelist.getSelection()[0])
+ self.session.open(ExifView, self.filelist.getCurrentDirectory() + self.filelist.getFilename(), self.filelist.getFilename())
def Settings(self):
self.session.open(PicSetup)
def Exit(self):
- config.pic.lastDir.value = self.currDir
+ if self.filelist.getCurrentDirectory() is None:
+ config.pic.lastDir.value = "/"
+ else:
+ config.pic.lastDir.value = self.filelist.getCurrentDirectory()
+
config.pic.save()
self.close()
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)]