From 94913d0f73c36623ae19916d79cee759b7f6bc98 Mon Sep 17 00:00:00 2001 From: ghost Date: Sun, 16 Nov 2008 13:14:59 +0100 Subject: change pictureplayer to use async pic loading --- .../Plugins/Extensions/PicturePlayer/plugin.py | 901 +++++++++++---------- 1 file changed, 464 insertions(+), 437 deletions(-) (limited to 'lib/python/Plugins/Extensions/PicturePlayer') diff --git a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py index ea906f0d..7d62d2be 100644 --- a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py +++ b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py @@ -1,318 +1,511 @@ -from enigma import eTimer, loadPic, getExif +from enigma import ePicLoad, eTimer, getDesktop + from Screens.Screen import Screen -from Screens.ServiceInfo import ServiceInfoList, ServiceInfoListEntry -from Components.ActionMap import ActionMap, NumberActionMap +from Tools.Directories import resolveFilename, pathExists, SCOPE_MEDIA +from Plugins.Plugin import PluginDescriptor + from Components.Pixmap import Pixmap, MovingPixmap +from Components.ActionMap import ActionMap, NumberActionMap from Components.Label import Label - -from Components.ConfigList import ConfigList -from Components.config import * - -from Tools.Directories import resolveFilename, fileExists, pathExists, createDir, SCOPE_MEDIA +from Components.Button import Button from Components.FileList import FileList from Components.AVSwitch import AVSwitch +from Components.Sources.List import List +from Components.ConfigList import ConfigList -from Plugins.Plugin import PluginDescriptor +from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigText, ConfigEnableDisable, KEY_LEFT, KEY_RIGHT, KEY_0, getConfigListEntry + +def getAspectforPic(): + return AVSwitch().getFramebufferScale() config.pic = ConfigSubsection() -config.pic.slidetime = ConfigInteger(default=10, limits=(5, 60)) -config.pic.resize = ConfigSelection(default="0", choices = [("0", _("simple")), ("1", _("better"))]) +config.pic.framesize = ConfigInteger(default=30, limits=(5, 99)) +config.pic.slidetime = ConfigInteger(default=10, limits=(10, 60)) +config.pic.resize = ConfigSelection(default="1", choices = [("0", _("simple")), ("1", _("better"))]) config.pic.cache = ConfigEnableDisable(default=True) config.pic.lastDir = ConfigText(default=resolveFilename(SCOPE_MEDIA)) -config.pic.rotate = ConfigSelection(default="0", choices = [("0", _("none")), ("1", _("manual")), ("2", _("by Exif"))]) +config.pic.infoline = ConfigEnableDisable(default=True) +config.pic.loop = ConfigEnableDisable(default=True) +config.pic.bgcolor = ConfigSelection(default="#00000000", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))]) +config.pic.textcolor = ConfigSelection(default="#0038FF48", choices = [("#00000000", _("black")),("#009eb9ff", _("blue")),("#00ff5a51", _("red")), ("#00ffe875", _("yellow")), ("#0038FF48", _("green"))]) -def getAspect(): - val = AVSwitch().getAspectRatioSetting() - return val/2 +class picshow(Screen): + def __init__(self, session): + self.skin = """ + + + + + + + + + + + + """ -#------------------------------------------------------------------------------------------ + Screen.__init__(self, session) + + self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions"], + { + "cancel": self.KeyExit, + "red": self.KeyRed, + "yellow": self.KeyYellow, + "blue": self.KeyBlue, + "ok": self.KeyOk + }, -1) + + self["key_red"] = Button(_("Thumbnails")) + self["key_green"] = Button() + self["key_yellow"] = Button(_("Exif")) + self["key_blue"] = Button(_("Setup")) + self["label"] = Label() + self["thn"] = Pixmap() -class ThumbView(Screen): - skin = """ - - - - - - - - - - - - - - - - """ + currDir = config.pic.lastDir.value + if not pathExists(currDir): + currDir = "/" + + self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)") + self["filelist"] = self.filelist + self["filelist"].onSelectionChanged.append(self.selectionChanged) + + self.ThumbTimer = eTimer() + self.ThumbTimer.callback.append(self.showThumb) + + self.picload = ePicLoad() + self.picload.PictureData.get().append(self.showPic) + + self.onLayoutFinish.append(self.setConf) + + def showPic(self, picInfo=""): + ptr = self.picload.getData() + if ptr != None: + self["thn"].instance.setPixmap(ptr.__deref__()) + self["thn"].show() + + text = picInfo.split('\n',1) + self["label"].setText(text[1]) + self["label"].show() + + def showThumb(self): + if not self.filelist.canDescent(): + if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1: + self.ThumbTimer.start(500, True) + + def selectionChanged(self): + if not self.filelist.canDescent(): + self.ThumbTimer.start(500, True) + else: + self["label"].hide() + self["thn"].hide() + + def KeyRed(self): + #if not self.filelist.canDescent(): + self.session.openWithCallback(self.callbackView, Pic_Thumb, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory()) + + def KeyYellow(self): + if not self.filelist.canDescent(): + self.session.open(Pic_Exif, self.picload.getInfo(self.filelist.getCurrentDirectory() + self.filelist.getFilename())) - def __init__(self, session, filelist, name, path): - self.skin = ThumbView.skin + def KeyBlue(self): + self.session.openWithCallback(self.setConf ,Pic_Setup) + + def KeyOk(self): + if self.filelist.canDescent(): + self.filelist.descent() + else: + self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory()) + + def setConf(self): + #0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB) + self.picload.setPara([self["thn"].instance.size().width(), self["thn"].instance.size().height(), getAspectforPic(), config.pic.cache.value, int(config.pic.resize.value), "#00000000"]) + + def callbackView(self, val=0): + if val > 0: + self.filelist.moveToIndex(val) + + def KeyExit(self): + del self.picload + + if self.filelist.getCurrentDirectory() is None: + config.pic.lastDir.value = "/" + else: + config.pic.lastDir.value = self.filelist.getCurrentDirectory() + + config.pic.save() + self.close() + +#------------------------------------------------------------------------------------------ + +class Pic_Setup(Screen): + def __init__(self, session): + self.skin = """ + + """ + Screen.__init__(self, session) + + self["actions"] = NumberActionMap(["SetupActions"], + { + "cancel": self.close, + "left": self.keyLeft, + "right": self.keyRight, + "0": self.keyNumber, + "1": self.keyNumber, + "2": self.keyNumber, + "3": self.keyNumber, + "4": self.keyNumber, + "5": self.keyNumber, + "6": self.keyNumber, + "7": self.keyNumber, + "8": self.keyNumber, + "9": self.keyNumber + }, -1) + + list = [] + self["liste"] = ConfigList(list) + list.append(getConfigListEntry(_("Slideshow Interval (sec.)"), config.pic.slidetime)) + list.append(getConfigListEntry(_("Scaling Mode"), config.pic.resize)) + list.append(getConfigListEntry(_("Cache Thumbnails"), config.pic.cache)) + list.append(getConfigListEntry(_("show Infoline"), config.pic.infoline)) + list.append(getConfigListEntry(_("Frame size in full view"), config.pic.framesize)) + list.append(getConfigListEntry(_("slide picture in loop"), config.pic.loop)) + list.append(getConfigListEntry(_("backgroundcolor"), config.pic.bgcolor)) + list.append(getConfigListEntry(_("textcolor"), config.pic.textcolor)) + + def keyLeft(self): + self["liste"].handleKey(KEY_LEFT) + + def keyRight(self): + self["liste"].handleKey(KEY_RIGHT) + + def keyNumber(self, number): + self["liste"].handleKey(KEY_0 + number) + +#--------------------------------------------------------------------------- + +class Pic_Exif(Screen): + def __init__(self, session, exiflist): + self.skin = """ + + + {"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 } + + + """ Screen.__init__(self, session) - self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "MovieSelectionActions"], + self["actions"] = ActionMap(["OkCancelActions"], + { + "cancel": self.close + }, -1) + + 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:"] + list = [] + + for x in range(len(exiflist)): + if x>0: + list.append((exifdesc[x], exiflist[x])) + else: + name = exiflist[x].split('/')[-1] + list.append((exifdesc[x], name)) + self["menu"] = List(list) + +#---------------------------------------------------------------------------------------- + +T_INDEX = 0 +T_FRAME_POS = 1 +T_PAGE = 2 +T_NAME = 3 +T_FULL = 4 + +class Pic_Thumb(Screen): + def __init__(self, session, piclist, lastindex, path): + + self.textcolor = config.pic.textcolor.value + self.color = config.pic.bgcolor.value + textsize = 20 + self.spaceX = 35 + self.picX = 190 + self.spaceY = 30 + self.picY = 200 + + size_w = getDesktop(0).size().width() + size_h = getDesktop(0).size().height() + self.thumbsX = size_w / (self.spaceX + self.picX) # thumbnails in X + self.thumbsY = size_h / (self.spaceY + self.picY) # thumbnails in Y + self.thumbsC = self.thumbsX * self.thumbsY # all thumbnails + + self.positionlist = [] + skincontent = "" + + posX = -1 + for x in range(self.thumbsC): + posY = x / self.thumbsX + posX += 1 + if posX >= self.thumbsX: + posX = 0 + + absX = self.spaceX + (posX*(self.spaceX + self.picX)) + absY = self.spaceY + (posY*(self.spaceY + self.picY)) + self.positionlist.append((absX, absY)) + skincontent += "" + + skincontent += "" + + + # Screen, backgroundlabel and MovingPixmap + self.skin = " \ + " + skincontent + "" + + Screen.__init__(self, session) + + self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"], { "cancel": self.Exit, "ok": self.KeyOk, - "showEventInfo": self.StartExif, - "right": self.key_right, "left": self.key_left, + "right": self.key_right, "up": self.key_up, - "down": self.key_down + "down": self.key_down, + "showEventInfo": self.StartExif, }, -1) - for x in range(6): + self["frame"] = MovingPixmap() + for x in range(self.thumbsC): self["label"+str(x)] = Label() self["thumb"+str(x)] = Pixmap() - self["frame"] = MovingPixmap() - - self.aspect = getAspect() - self.path = path - self.filelist = filelist + + self.Thumbnaillist = [] + self.filelist = [] self.currPage = -1 - self.index = 0 - self.old_index = 0 - self.thumblist = [] - self.thumbindex = 0 - self.list = [] - self.poslist = [[50,63],[265,63],[480,63],[50,288],[265,288],[480,288]] - - count=0 - pos=0 - for x in self.filelist: + self.dirlistcount = 0 + self.path = path + + index = 0 + framePos = 0 + Page = 0 + for x in piclist: if x[0][1] == False: - self.list.append((x[0][0], self.path + x[0][0], count/6, pos, "(" + str(count+1) + ") ")) - pos += 1 - if pos == 6: - pos = 0 - if x[0][0] == name: - self.index = count - count += 1 - self.maxentry = len(self.list)-1 + self.filelist.append((index, framePos, Page, x[0][0], path + x[0][0])) + index += 1 + framePos += 1 + if framePos > (self.thumbsC -1): + framePos = 0 + Page += 1 + else: + self.dirlistcount += 1 - if self.maxentry < 0: - self["label0"].setText(_("no Picture found")) + self.maxentry = len(self.filelist)-1 + self.index = lastindex - self.dirlistcount + if self.index < 0: + self.index = 0 + + self.picload = ePicLoad() + self.picload.PictureData.get().append(self.showPic) + + self.onLayoutFinish.append(self.setPicloadConf) self.ThumbTimer = eTimer() - self.ThumbTimer.callback.append(self.showThumb) + self.ThumbTimer.callback.append(self.showPic) - self.fillPage() + def setPicloadConf(self): + self.picload.setPara([self["thumb0"].instance.size().width(), self["thumb0"].instance.size().height(), getAspectforPic(), config.pic.cache.value, int(config.pic.resize.value), self.color]) + self.paintFrame() + + def paintFrame(self): + #print "index=" + str(self.index) + if self.maxentry < self.index or self.index < 0: + return + + pos = self.positionlist[self.filelist[self.index][T_FRAME_POS]] + self["frame"].moveTo( pos[0], pos[1], 1) + self["frame"].startMoving() + + if self.currPage != self.filelist[self.index][T_PAGE]: + self.currPage = self.filelist[self.index][T_PAGE] + self.newPage() + + def newPage(self): + self.Thumbnaillist = [] + #clear Labels and Thumbnail + for x in range(self.thumbsC): + self["label"+str(x)].setText("") + self["thumb"+str(x)].hide() + #paint Labels and fill Thumbnail-List + for x in self.filelist: + if x[T_PAGE] == self.currPage: + self["label"+str(x[T_FRAME_POS])].setText("(" + str(x[T_INDEX]+1) + ") " + x[T_NAME]) + self.Thumbnaillist.append([0, x[T_FRAME_POS], x[T_FULL]]) + + #paint Thumbnail start + self.showPic() + + def showPic(self, picInfo=""): + for x in range(len(self.Thumbnaillist)): + if self.Thumbnaillist[x][0] == 0: + if self.picload.getThumbnail(self.Thumbnaillist[x][2]) == 1: #zu tun probier noch mal + self.ThumbTimer.start(500, True) + else: + self.Thumbnaillist[x][0] = 1 + break + elif self.Thumbnaillist[x][0] == 1: + self.Thumbnaillist[x][0] = 2 + ptr = self.picload.getData() + if ptr != None: + self["thumb" + str(self.Thumbnaillist[x][1])].instance.setPixmap(ptr.__deref__()) + self["thumb" + str(self.Thumbnaillist[x][1])].show() + def key_left(self): self.index -= 1 if self.index < 0: self.index = self.maxentry - self.fillPage() + self.paintFrame() def key_right(self): self.index += 1 if self.index > self.maxentry: self.index = 0 - self.fillPage() + self.paintFrame() def key_up(self): - self.index -= 3 + self.index -= self.thumbsX if self.index < 0: - self.index = 0 - self.fillPage() + self.index =self.maxentry + self.paintFrame() def key_down(self): - self.index += 3 + self.index += self.thumbsX if self.index > self.maxentry: - self.index = self.maxentry - self.fillPage() - - def fillPage(self): - if self.maxentry < 0: - return + self.index = 0 + self.paintFrame() - self["frame"].moveTo(self.poslist[self.list[self.index][3]][0], self.poslist[self.list[self.index][3]][1], 1) - self["frame"].startMoving() - - if self.list[self.index][2] != self.currPage: - self.currPage = self.list[self.index][2] - textlist = ["","","","","",""] - self.thumblist = ["","","","","",""] - - for x in self.list: - if x[2] == self.currPage: - textlist[x[3]] = x[4] + x[0] - self.thumblist[x[3]] = x[0] - - for x in range(6): - self["label"+str(x)].setText(textlist[x]) - self["thumb"+str(x)].hide() - - self.ThumbTimer.start(500, True) - - def showThumb(self): - if self.thumblist[self.thumbindex] != "": - cachefile = "" - if config.pic.cache.value: - cachedir = self.path + ".Thumbnails/" - 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, 1) - if ptr != None: - self["thumb"+str(self.thumbindex)].show() - self["thumb"+str(self.thumbindex)].instance.setPixmap(ptr) - - self.thumbindex += 1 - if self.thumbindex < 6: - self.ThumbTimer.start(500, True) - else: - self.thumbindex = 0 - else: - 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]) + self.session.open(Pic_Exif, self.picload.getInfo(self.filelist[self.index][T_FULL])) 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) - - def returnView(self, val=0): + self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist, self.index, self.path) + + def callbackView(self, val=0): self.index = val if self.old_index != self.index: - self.fillPage() - + self.paintFrame() def Exit(self): - self.close(self.index) + del self.picload + self.close(self.index + self.dirlistcount) -#------------------------------------------------------------------------------------------ +#--------------------------------------------------------------------------- -class PicView(Screen): - skin = """ - - - - - - - - - - - """ - - def __init__(self, session, filelist, name, path): - self.skin = PicView.skin - Screen.__init__(self, session) +class Pic_Full_View(Screen): + def __init__(self, session, filelist, index, path): - self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "MovieSelectionActions"], + self.textcolor = config.pic.textcolor.value + self.bgcolor = config.pic.bgcolor.value + space = config.pic.framesize.value + size_w = getDesktop(0).size().width() + size_h = getDesktop(0).size().height() + + self.skin = " \ + \ + \ + \ + " + + Screen.__init__(self, session) + + self["actions"] = ActionMap(["OkCancelActions", "ColorActions", "DirectionActions", "MovieSelectionActions"], { "cancel": self.Exit, - "showEventInfo": self.StartExif, - "green": self.Play, - "yellow": self.Pause, + "green": self.PlayPause, + "yellow": self.PlayPause, "blue": self.nextPic, - "red": self.prevPic + "red": self.prevPic, + "left": self.prevPic, + "right": self.nextPic, + "showEventInfo": self.StartExif, }, -1) - - self.aspect = getAspect() - self.blinking = False - self.autoShow = True - self.slideOn = False - self.pauseOn = False - self.index = 0 - self.old = 0 - self.list = [] - count=0 - for x in filelist: - if x[0][1] == False: - self.list.append((x[0][0], path + x[0][0], 0)) - if x[0][0] == name: - self.index = count - count += 1 - self.maxentry = len(self.list)-1 - - self["file"] = Label(_("please wait, loading picture...")) - self["picture"] = Pixmap() self["point"] = Pixmap() - self["play"] = Pixmap() - self["pause"] = Pixmap() + self["pic"] = Pixmap() + self["play_icon"] = Pixmap() + self["file"] = Label(_("please wait, loading picture...")) - self.decodeTimer = eTimer() - self.decodeTimer.callback.append(self.decodePic) - self.decodeTimer.start(300, True) + self.old_index = 0 + self.filelist = [] + self.lastindex = index + self.currPic = [] + self.shownow = True + self.dirlistcount = 0 - self.slideTimer = eTimer() - self.slideTimer.callback.append(self.slidePic) - - - def Pause(self): - if self.slideOn: - if self.pauseOn: - self.pauseOn=False - self["pause"].show() - else: - self.pauseOn=True - self["play"].show() - self.slideValue = 0 - - def Play(self): - if self.pauseOn == False: - if self.slideOn: - self.slideOn=False - self["play"].show() - else: - self.slideOn=True - self.slideTimer.start(1000, True) - - self.slideValue = int(config.pic.slidetime.value) + for x in filelist: + if len(filelist[0]) == 3: #orig. filelist + if x[0][1] == False: + self.filelist.append(path + x[0][0]) + else: + self.dirlistcount += 1 + else: # thumbnaillist + self.filelist.append(x[T_FULL]) + + self.maxentry = len(self.filelist)-1 + self.index = index - self.dirlistcount + if self.index < 0: + self.index = 0 - def slidePic(self): - if self.slideOn == True and self.pauseOn == False: - self.blinkingWidget("play") - self.slideValue -= 1 - if self.slideValue <= 0: - self.slideValue = int(config.pic.slidetime.value) - self.nextPic() + self.picload = ePicLoad() + self.picload.PictureData.get().append(self.finish_decode) - self.slideTimer.start(1000, True) + self.slideTimer = eTimer() + self.slideTimer.callback.append(self.slidePic) - if self.pauseOn: - self.blinkingWidget("pause") - self.slideTimer.start(1000, True) + if self.maxentry >= 0: + self.onLayoutFinish.append(self.setPicloadConf) - def decodePic(self): - self.currPic = loadPic(self.list[self.index][1], 560, 450, self.aspect, int(config.pic.resize.value), int(config.pic.rotate.value),1) - self["point"].hide() - if self.autoShow: - self.showPic() - self.autoShow = False + def setPicloadConf(self): + self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), getAspectforPic(), 0, int(config.pic.resize.value), self.bgcolor]) - def showPic(self): - 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) + self["play_icon"].hide() + if config.pic.infoline.value == False: + self["file"].hide() + self.start_decode() - self.next() - self["point"].show() - self.decodeTimer.start(300, True) - - def nextPic(self): - self.showPic() - - def prevPic(self): - self.index = self.old - self.prev() - self.autoShow = True + def ShowPicture(self): + if self.shownow and len(self.currPic): + self.shownow = False + self["file"].setText(self.currPic[0]) + self.lastindex = self.currPic[1] + self["pic"].instance.setPixmap(self.currPic[2].__deref__()) + self.currPic = [] + + self.next() + self.start_decode() + + def finish_decode(self, picInfo=""): + self["point"].hide() + ptr = self.picload.getData() + if ptr != None: + text = "" + try: + text = picInfo.split('\n',1) + text = "(" + str(self.index+1) + "/" + str(self.maxentry+1) + ") " + text[0].split('/')[-1] + except: + pass + self.currPic = [] + self.currPic.append(text) + self.currPic.append(self.index) + self.currPic.append(ptr) + self.ShowPicture() + + def start_decode(self): + self.picload.startDecode(self.filelist[self.index]) self["point"].show() - self.decodeTimer.start(300, True) - + def next(self): self.index += 1 if self.index > self.maxentry: @@ -322,218 +515,52 @@ class PicView(Screen): self.index -= 1 if self.index < 0: self.index = self.maxentry - - def blinkingWidget(self, name): - if self.blinking: - self.blinking=False - self[name].show() - else: - self.blinking=True - self[name].hide() - - def StartExif(self): - if self.pauseOn == False: - self.Pause() - self.session.openWithCallback(self.StopExif ,ExifView, self.list[self.old][1], self.list[self.old][0]) - - def StopExif(self): - if self.pauseOn: - self.Pause() - - def Exit(self): - self.close(self.old) - -#------------------------------------------------------------------------------------------ -class ExifView(Screen): - skin = """ - - - """ - - def __init__(self, session, fullname, name): - self.skin = ExifView.skin - Screen.__init__(self, session) - - self["actions"] = ActionMap(["OkCancelActions"], - { - "cancel": self.close - }, -1) - - dlist = ["Name:", "EXIF-Version:", "Camera-Make:", "Camera-Model:", "Date/Time:", "User Comments:", "Width / Height:", "Orientation:", "Metering Mode:", "Exposure Program:", "Light Source:", "Flash used:", "CompressedBitsPerPixel:", "ISO Speed Rating:", "X-Resolution:", "Y-Resolution:", "Resolution Unit:", "Brightness:", "Exposure Time:", "Exposure Bias:", "Distance:", "CCD-Width:", "ApertureFNumber:"] - tlist = [ ] - self["exiflist"] = ServiceInfoList(tlist) - tlist.append(ServiceInfoListEntry(dlist[0], name)) - count=1 - for x in getExif(fullname): - tlist.append(ServiceInfoListEntry(dlist[count], x)) - count += 1 - -#------------------------------------------------------------------------------------------ - -class PicSetup(Screen): - skin = """ - - - """ - - def __init__(self, session): - self.skin = PicSetup.skin - Screen.__init__(self, session) - - self["actions"] = NumberActionMap(["SetupActions"], - { - "cancel": self.close, - "left": self.keyLeft, - "right": self.keyRight, - "0": self.keyNumber, - "1": self.keyNumber, - "2": self.keyNumber, - "3": self.keyNumber, - "4": self.keyNumber, - "5": self.keyNumber, - "6": self.keyNumber, - "7": self.keyNumber, - "8": self.keyNumber, - "9": self.keyNumber - }, -1) - - self.list = [] - self["liste"] = ConfigList(self.list) - self.list.append(getConfigListEntry(_("Slideshow Interval (sec.)"), config.pic.slidetime)) - self.list.append(getConfigListEntry(_("Scaling Mode"), config.pic.resize)) - self.list.append(getConfigListEntry(_("Cache Thumbnails"), config.pic.cache)) - #self.list.append(getConfigListEntry(_("Rotate Picture"), config.pic.rotate)) - - def keyLeft(self): - self["liste"].handleKey(KEY_LEFT) - - def keyRight(self): - self["liste"].handleKey(KEY_RIGHT) - - def keyNumber(self, number): - self["liste"].handleKey(KEY_0 + number) - - -#------------------------------------------------------------------------------------------ - -class picmain(Screen): - skin = """ - - - - - - - - - - """ - - def __init__(self, session): - self.skin = picmain.skin - Screen.__init__(self, session) - - self["actions"] = ActionMap(["OkCancelActions", "DirectionActions", "ColorActions", "MovieSelectionActions"], - { - "ok": self.KeyOk, - "cancel": self.Exit, - "right": self.rightDown, - "left": self.leftUp, - "up": self.up, - "down": self.down, - "showEventInfo": self.StartExif, - "contextMenu": self.Settings, - "red": self.StartThumb - }, -1) - - self.aspect = getAspect() - currDir = config.pic.lastDir.value - if not pathExists(currDir): - currDir = "/" - - self.filelist = FileList(currDir, matchingPattern = "(?i)^.*\.(jpeg|jpg|jpe|png|bmp|gif)") - self["filelist"] = self.filelist - self["thumbnail"] = Pixmap() - - self.ThumbTimer = eTimer() - self.ThumbTimer.callback.append(self.showThumb) - self.ThumbTimer.start(500, True) - - def up(self): - self["filelist"].up() - self.ThumbTimer.start(1500, True) - - def down(self): - self["filelist"].down() - self.ThumbTimer.start(1500, True) - - def leftUp(self): - self["filelist"].pageUp() - self.ThumbTimer.start(1500, True) - - def rightDown(self): - self["filelist"].pageDown() - self.ThumbTimer.start(1500, True) - - def showThumb(self): - if not self.filelist.canDescent(): - cachefile = "" - if config.pic.cache.value: - 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.filelist.getCurrentDirectory() + self.filelist.getFilename(), 180, 160, self.aspect, int(config.pic.resize.value), 0, 0, cachefile, 1) - if ptr != None: - self["thumbnail"].show() - self["thumbnail"].instance.setPixmap(ptr) - else: - self["thumbnail"].hide() - - def KeyOk(self): - if self.filelist.canDescent(): - self.filelist.descent() + def slidePic(self): + print "slide to next Picture index=" + str(self.lastindex) + if config.pic.loop.value==False and self.lastindex == self.maxentry: + self.PlayPause() + self.shownow = True + self.ShowPicture() + + def PlayPause(self): + if self.slideTimer.isActive(): + self.slideTimer.stop() + self["play_icon"].hide() else: - 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.getFilename(), self.filelist.getCurrentDirectory()) + self.slideTimer.start(config.pic.slidetime.value*1000) + self["play_icon"].show() + self.nextPic() - def returnVal(self, val=0): - if val > 0: - for x in self.filelist.getFileList(): - if x[0][1] == True: - val += 1 - self.filelist.moveToIndex(val) + def prevPic(self): + self.currPic = [] + self.index = self.lastindex + self.prev() + self.start_decode() + self.shownow = True + def nextPic(self): + self.shownow = True + self.ShowPicture() + def StartExif(self): - if not self.filelist.canDescent(): - self.session.open(ExifView, self.filelist.getCurrentDirectory() + self.filelist.getFilename(), self.filelist.getFilename()) + if self.maxentry < 0: + return + self.session.open(Pic_Exif, self.picload.getInfo(self.filelist[self.lastindex])) - def Settings(self): - self.session.open(PicSetup) - def Exit(self): - if self.filelist.getCurrentDirectory() is None: - config.pic.lastDir.value = "/" - else: - config.pic.lastDir.value = self.filelist.getCurrentDirectory() - - config.pic.save() - self.close() + del self.picload + self.close(self.lastindex + self.dirlistcount) #------------------------------------------------------------------------------------------ def main(session, **kwargs): - session.open(picmain) + session.open(picshow) 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, "", "") + session.open(Pic_Full_View, filelist, 0, file.path) def filescan(**kwargs): from Components.Scanner import Scanner, ScanPath @@ -557,5 +584,5 @@ def filescan(**kwargs): def Plugins(**kwargs): return \ - [PluginDescriptor(name="PicturePlayer", description="Picture Viewer (BMP, PNG, JPG, GIF)", icon="pictureplayer.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main), - PluginDescriptor(name="PicturePlayer", where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)] + [PluginDescriptor(name=_("PicturePlayer"), description=_("fileformats (BMP, PNG, JPG, GIF)"), icon="pictureplayer.png", where = PluginDescriptor.WHERE_PLUGINMENU, fnc=main), + PluginDescriptor(name=_("PicturePlayer"), where = PluginDescriptor.WHERE_FILESCAN, fnc = filescan)] -- cgit v1.2.3 From 5aa89f34249397330995cc0ab1e080c1f567e174 Mon Sep 17 00:00:00 2001 From: ghost Date: Mon, 17 Nov 2008 23:34:41 +0100 Subject: get rid of some floating point values --- lib/gdi/picload.cpp | 35 +++++++++++----------- lib/python/Components/AVSwitch.py | 14 ++++----- .../Plugins/Extensions/PicturePlayer/plugin.py | 14 +++++---- .../SystemPlugins/Videomode/VideoHardware.py | 8 ++--- 4 files changed, 36 insertions(+), 35 deletions(-) (limited to 'lib/python/Plugins/Extensions/PicturePlayer') diff --git a/lib/gdi/picload.cpp b/lib/gdi/picload.cpp index f67507ca..375f33fb 100644 --- a/lib/gdi/picload.cpp +++ b/lib/gdi/picload.cpp @@ -1011,16 +1011,16 @@ RESULT ePicLoad::setPara(PyObject *val) { if (!PySequence_Check(val)) return 0; - if (PySequence_Size(val) < 6) + if (PySequence_Size(val) < 7) return 0; else { ePyObject fast = PySequence_Fast(val, ""); m_conf.max_x = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 0)); m_conf.max_y = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 1)); - m_conf.aspect_ratio = PyFloat_AsDouble( PySequence_Fast_GET_ITEM(val, 2)); - m_conf.usecache = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 3)); - m_conf.resizetype = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 4)); - const char *bg_str = PyString_AsString( PySequence_Fast_GET_ITEM(val, 5)); + m_conf.aspect_ratio = (double)PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 2)) / PyInt_AsLong(PySequence_Fast_GET_ITEM(val, 3)); + m_conf.usecache = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 4)); + m_conf.resizetype = PyInt_AsLong( PySequence_Fast_GET_ITEM(val, 5)); + const char *bg_str = PyString_AsString( PySequence_Fast_GET_ITEM(val, 6)); if(bg_str[0] == '#' && strlen(bg_str)==9) { @@ -1040,29 +1040,30 @@ RESULT ePicLoad::setPara(PyObject *val) //for old plugins SWIG_VOID(int) loadPic(ePtr &result, std::string filename, int x, int y, int aspect, int resize_mode, int rotate, int background, std::string cachefile) { + long asp1, asp2; result = 0; eDebug("deprecated loadPic function used!!! please use the non blocking version! you can see demo code in Pictureplayer plugin... this function is removed in the near future!"); ePicLoad mPL; - double aspect_ratio; switch(aspect) { - case 1: aspect_ratio = 1.778 / ((double)720/576); break; //16:9 - case 2: aspect_ratio = 1.600 / ((double)720/576); break; //16:10 - case 3: aspect_ratio = 1.250 / ((double)720/576); break; //5:4 - default: aspect_ratio = 1.333 / ((double)720/576); //4:3 + case 1: asp1 = 16*576, asp2 = 9*720; break; //16:9 + case 2: asp1 = 16*576, asp2 = 10*720; break; //16:10 + case 3: asp1 = 5*576, asp2 = 4*720; break; //5:4 + default: asp1 = 4*576, asp2 = 3*720; break; //4:3 } - - ePyObject tuple = PyTuple_New(6); + + ePyObject tuple = PyTuple_New(7); PyTuple_SET_ITEM(tuple, 0, PyLong_FromLong(x)); PyTuple_SET_ITEM(tuple, 1, PyLong_FromLong(y)); - PyTuple_SET_ITEM(tuple, 2, PyFloat_FromDouble(aspect_ratio)); - PyTuple_SET_ITEM(tuple, 3, PyLong_FromLong(0)); - PyTuple_SET_ITEM(tuple, 4, PyLong_FromLong(resize_mode)); + PyTuple_SET_ITEM(tuple, 2, PyLong_FromLong(asp1)); + PyTuple_SET_ITEM(tuple, 3, PyLong_FromLong(asp2)); + PyTuple_SET_ITEM(tuple, 4, PyLong_FromLong(0)); + PyTuple_SET_ITEM(tuple, 5, PyLong_FromLong(resize_mode)); if(background) - PyTuple_SET_ITEM(tuple, 5, PyString_FromString("#ff000000")); + PyTuple_SET_ITEM(tuple, 6, PyString_FromString("#ff000000")); else - PyTuple_SET_ITEM(tuple, 5, PyString_FromString("#00000000")); + PyTuple_SET_ITEM(tuple, 6, PyString_FromString("#00000000")); mPL.setPara(tuple); diff --git a/lib/python/Components/AVSwitch.py b/lib/python/Components/AVSwitch.py index 19aca24d..00350cbb 100644 --- a/lib/python/Components/AVSwitch.py +++ b/lib/python/Components/AVSwitch.py @@ -30,26 +30,24 @@ class AVSwitch: def getOutputAspect(self): if valstr in ("4_3_letterbox", "4_3_panscan"): # 4:3 - return 1.333333333 + return (4,3) elif valstr == "16_9": # auto ... 4:3 or 16:9 try: aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read() if aspect_str == "1": # 4:3 - return 1.333333333 + return (4,3) except IOError: pass - return 1.777777778 elif valstr in ("16_9_always", "16_9_letterbox"): # 16:9 - return 1.777777778 + pass elif valstr in ("16_10_letterbox", "16_10_panscan"): # 16:10 - return 1.6 - print "unknown output aspect!" - return 1.0000 + return (16,10) + return (16,9) def getFramebufferScale(self): aspect = self.getOutputAspect() fb_size = getDesktop(0).size() - return aspect / ((1.0 * fb_size.width()) / fb_size.height()) + return (aspect[0] * fb_size.height(), aspect[1] * fb_size.width()) def getAspectRatioSetting(self): valstr = config.av.aspectratio.value diff --git a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py index 7d62d2be..0cdab563 100644 --- a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py +++ b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py @@ -15,7 +15,7 @@ from Components.ConfigList import ConfigList from Components.config import config, ConfigSubsection, ConfigInteger, ConfigSelection, ConfigText, ConfigEnableDisable, KEY_LEFT, KEY_RIGHT, KEY_0, getConfigListEntry -def getAspectforPic(): +def getScale(): return AVSwitch().getFramebufferScale() config.pic = ConfigSubsection() @@ -119,8 +119,9 @@ class picshow(Screen): self.session.openWithCallback(self.callbackView, Pic_Full_View, self.filelist.getFileList(), self.filelist.getSelectionIndex(), self.filelist.getCurrentDirectory()) def setConf(self): + sc = getScale() #0=Width 1=Height 2=Aspect 3=use_cache 4=resize_type 5=Background(#AARRGGBB) - self.picload.setPara([self["thn"].instance.size().width(), self["thn"].instance.size().height(), getAspectforPic(), config.pic.cache.value, int(config.pic.resize.value), "#00000000"]) + 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")) def callbackView(self, val=0): if val > 0: @@ -311,10 +312,10 @@ class Pic_Thumb(Screen): self.ThumbTimer.callback.append(self.showPic) def setPicloadConf(self): - self.picload.setPara([self["thumb0"].instance.size().width(), self["thumb0"].instance.size().height(), getAspectforPic(), config.pic.cache.value, int(config.pic.resize.value), self.color]) + sc = getScale() + 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]) self.paintFrame() - - + def paintFrame(self): #print "index=" + str(self.index) if self.maxentry < self.index or self.index < 0: @@ -468,7 +469,8 @@ class Pic_Full_View(Screen): self.onLayoutFinish.append(self.setPicloadConf) def setPicloadConf(self): - self.picload.setPara([self["pic"].instance.size().width(), self["pic"].instance.size().height(), getAspectforPic(), 0, int(config.pic.resize.value), self.bgcolor]) + sc = getScale() + 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]) self["play_icon"].hide() if config.pic.infoline.value == False: diff --git a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py index 5e38f3e6..02fdf9a5 100644 --- a/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py +++ b/lib/python/Plugins/SystemPlugins/Videomode/VideoHardware.py @@ -60,7 +60,7 @@ class VideoHardware: widescreen_modes = set(["720p", "1080i"]) def getOutputAspect(self): - ret = 1.777777778 # 16:9 + ret = (16,9) port = config.av.videoport.value if port not in config.av.videomode: print "current port not available in getOutputAspect!!! force 16:9" @@ -75,16 +75,16 @@ class VideoHardware: else: aspect = {"16_9": "16:9", "16_10": "16:10"}[config.av.aspect.value] if aspect == "16:10": - ret = 1.6 + ret = (16,10) elif is_auto: try: aspect_str = open("/proc/stb/vmpeg/0/aspect", "r").read() if aspect_str == "1": # 4:3 - ret = 1.333333333 + ret = (4,3) except IOError: pass else: # 4:3 - ret = 1.333333333 + ret = (4,3) return ret def __init__(self): -- cgit v1.2.3 From 5cb7cb980986fe89da490d8d5c2a73b935844724 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Tue, 18 Nov 2008 13:04:38 +0100 Subject: use already translated string --- lib/python/Plugins/Extensions/PicturePlayer/plugin.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib/python/Plugins/Extensions/PicturePlayer') diff --git a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py index 0cdab563..aeca12dc 100644 --- a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py +++ b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py @@ -202,7 +202,7 @@ class Pic_Exif(Screen): "cancel": self.close }, -1) - 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:"] + 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:"] list = [] for x in range(len(exiflist)): -- cgit v1.2.3 From ac28912f03ba943cce61b30df2014f06dd499ba7 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 19 Nov 2008 09:58:34 +0100 Subject: fix filelist crash, add necessary import for hotplug --- lib/python/Plugins/Extensions/PicturePlayer/plugin.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'lib/python/Plugins/Extensions/PicturePlayer') diff --git a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py index aeca12dc..e9da3e2f 100644 --- a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py +++ b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py @@ -1,7 +1,7 @@ from enigma import ePicLoad, eTimer, getDesktop from Screens.Screen import Screen -from Tools.Directories import resolveFilename, pathExists, SCOPE_MEDIA +from Tools.Directories import resolveFilename, pathExists, fileExists, SCOPE_MEDIA from Plugins.Plugin import PluginDescriptor from Components.Pixmap import Pixmap, MovingPixmap @@ -91,8 +91,9 @@ class picshow(Screen): def showThumb(self): if not self.filelist.canDescent(): - if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1: - self.ThumbTimer.start(500, True) + if self.filelist.getCurrentDirectory() and self.filelist.getFilename(): + if self.picload.getThumbnail(self.filelist.getCurrentDirectory() + self.filelist.getFilename()) == 1: + self.ThumbTimer.start(500, True) def selectionChanged(self): if not self.filelist.canDescent(): -- cgit v1.2.3 From 5474861f9be0b88428d490b45625d1a65575c020 Mon Sep 17 00:00:00 2001 From: Fraxinas Date: Wed, 19 Nov 2008 17:39:20 +0100 Subject: fix mediascanner list handling, thx to mechatron --- lib/python/Plugins/Extensions/PicturePlayer/plugin.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/python/Plugins/Extensions/PicturePlayer') diff --git a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py index e9da3e2f..05adb633 100644 --- a/lib/python/Plugins/Extensions/PicturePlayer/plugin.py +++ b/lib/python/Plugins/Extensions/PicturePlayer/plugin.py @@ -452,6 +452,11 @@ class Pic_Full_View(Screen): self.filelist.append(path + x[0][0]) else: self.dirlistcount += 1 + elif len(filelist[0]) == 2: #scanlist + if x[0][1] == False: + self.filelist.append(x[0][0]) + else: + self.dirlistcount += 1 else: # thumbnaillist self.filelist.append(x[T_FULL]) -- cgit v1.2.3