Index: ImageSourceLocalStorage.lua =================================================================== --- ImageSourceLocalStorage.lua (revision 8754) +++ ImageSourceLocalStorage.lua (working copy) @@ -51,6 +51,16 @@ obj.pathOverride = paramOverride.path end + if paramOverride and paramOverride.startImage then + log:debug("start slideshow with image: ", paramOverride.startImage) + obj.startImage = paramOverride.startImage + end + + if paramOverride and paramOverride.noRecursion then + log:debug("don't search subfolders") + obj.noRecursion = true + end + return obj end @@ -89,7 +99,7 @@ local fullpath = nextfolder .. "/" .. f - if lfs.attributes(fullpath, "mode") == "directory" then + if (not self.norecursion) and lfs.attributes(fullpath, "mode") == "directory" then -- push this directory on our list to be scanned table.insert(dirstoscan, fullpath) @@ -100,8 +110,13 @@ or string.find(string.lower(fullpath), "%ppng") or string.find(string.lower(fullpath), "%pbmp") or string.find(string.lower(fullpath), "%pgif") then + -- log:info(fullpath) table.insert(self.imgFiles, fullpath) + + if self.startImage and self.startImage == f then + self.currentImage = #self.imgFiles - 1 + end end end Index: ImageViewerApplet.lua =================================================================== --- ImageViewerApplet.lua (revision 8754) +++ ImageViewerApplet.lua (working copy) @@ -31,6 +31,7 @@ local Framework = require("jive.ui.Framework") local Font = require("jive.ui.Font") local Icon = require("jive.ui.Icon") +local Textarea = require("jive.ui.Textarea") local Label = require("jive.ui.Label") local Group = require("jive.ui.Group") local RadioButton = require("jive.ui.RadioButton") @@ -120,34 +121,109 @@ end function openImageViewer(self) - -- two item menu that shows start slideshow and settings local window = Window("text_list", self:string('IMAGE_VIEWER')) - window:addWidget( - SimpleMenu("menu", + + local menu = SimpleMenu("menu", { { - { - text = self:string("IMAGE_VIEWER_START_SLIDESHOW"), - sound = "WINDOWSHOW", - callback = function(event, menuItem) - self:startSlideshow(false) - return EVENT_CONSUME - end - }, - { - text = self:string("IMAGE_VIEWER_SETTINGS"), - sound = "WINDOWSHOW", - callback = function() - self:openSettings() - return EVENT_CONSUME + text = self:string("IMAGE_VIEWER_START_SLIDESHOW"), + sound = "WINDOWSHOW", + callback = function(event, menuItem) + self:startSlideshow(false) + return EVENT_CONSUME + end + }, + { + text = self:string("IMAGE_VIEWER_SETTINGS"), + sound = "WINDOWSHOW", + callback = function() + self:openSettings() + return EVENT_CONSUME + end + }, + }) + + if System:hasLocalStorage() then + menu:insertItem({ + text = self:string("IMAGE_VIEWER_BROWSE_MEDIA"), + sound = "WINDOWSHOW", + callback = function(event, menuItem) + self:browseFolder("/media") + return EVENT_CONSUME + end + }, 1) + end + + window:addWidget(menu) + self:tieAndShowWindow(window) + return window +end + +function browseFolder(self, folder, title) + local window = Window("text_list", title or folder) + + log:info("Browse folder for images: " .. folder) + + -- verify validity of the directory + if lfs.attributes(folder, "mode") ~= 'directory' then + local text = Textarea("text", tostring(self:string("IMAGE_VIEWER_INVALID_FOLDER")) .. "\n" .. folder) + + window:addWidget(text) + self:tieAndShowWindow(window) + return window + end + + local menu = SimpleMenu("menu") + + for f in lfs.dir(folder) do + -- exclude any dot file (hidden files/directories) + if (string.sub(f, 1, 1) ~= ".") then + + local fullpath = folder .. "/" .. f + + if lfs.attributes(fullpath, "mode") == "directory" then + menu:addItem({ + text = f, + sound = "WINDOWSHOW", + callback = function() + self:browseFolder(fullpath, f) + end + }) + + elseif lfs.attributes(fullpath, "mode") == "file" then + -- check for supported file type + if string.find(string.lower(fullpath), "%pjpe*g") + or string.find(string.lower(fullpath), "%ppng") + or string.find(string.lower(fullpath), "%pbmp") + or string.find(string.lower(fullpath), "%pgif") then + -- log:info(fullpath) + menu:addItem({ + text = f, + sound = "WINDOWSHOW", + callback = function() + self:startSlideshow(false, ImageSourceLocalStorage(self, { + path = folder, + startImage = f, + noRecursion = true + })) + end + }) end - }, - } - ) - ) + end + + end + end + + if menu:numItems() > 0 then + window:addWidget(menu) + else + window:addWidget(Textarea("text", self:string("IMAGE_VIEWER_EMPTY_LIST"))) + end + self:tieAndShowWindow(window) return window end + function startScreensaver(self) log:info("start standard image viewer screensaver") self:startSlideshow(true) @@ -475,12 +551,16 @@ end end --- callback called from media manager +-- callbacks called from media manager function mmImageViewerMenu(self, devName) log:info('mmImageViewerMenu: ', devName) self:startSlideshow(false, ImageSourceLocalStorage(self, { path = '/media/' .. devName })) end +function mmImageViewerBrowse(self, devName) + log:info('mmImageViewerBrowse: ', devName) + self:browseFolder('/media/' .. devName) +end function free(self) log:info("destructor of image viewer") Index: ImageViewerMeta.lua =================================================================== --- ImageViewerMeta.lua (revision 8754) +++ ImageViewerMeta.lua (working copy) @@ -41,6 +41,7 @@ meta:registerService("unregisterRemoteScreensaver") meta:registerService("openRemoteScreensaver") meta:registerService("mmImageViewerMenu") + meta:registerService("mmImageViewerBrowse") end @@ -59,6 +60,11 @@ serviceMethod = "mmImageViewerMenu", menuText = self:string('IMAGE_VIEWER_START_SLIDESHOW') }) + + appletManager:callService("mmRegisterMenuItem", { + serviceMethod = "mmImageViewerBrowse", + menuText = self:string('IMAGE_VIEWER_BROWSE_IMAGES') + }) end Index: strings.txt =================================================================== --- strings.txt (revision 8754) +++ strings.txt (working copy) @@ -1063,3 +1063,11 @@ RU Сохраненный слайд SV Sparad bild +IMAGE_VIEWER_BROWSE_MEDIA + EN Browse Media + +IMAGE_VIEWER_BROWSE_IMAGES + EN Browse for Images + +IMAGE_VIEWER_INVALID_FOLDER + EN Can not open folder: