# -*- coding: iso-8859-1 -*- ## ## Copyright (C) 2008 michael michael[at]vierpi(dot)de ## ## This program is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published ## by the Free Software Foundation; version 2 only. ## ## This program is distributed in the hope that it will be useful, ## but WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ## GNU General Public License for more details. ## # http://www.vierpi.de/JbroutSlideshow.html from __main__ import JPlugin import os class Plugin(JPlugin): """Open a slideshow with the selected pictures.""" __author__ = "michael" __version__ = "1.0" # tempdir = '/tmp/slideshow' player = 'gimv -S' movextlist = ('.avi', '.mpg') def menuEntries(self, l): ipath = '/usr/share/icons/gnome/24x24/stock/object/stock_slide-show.png' if os.path.exists(ipath): icon = ipath else: icon = None return [ (510, _("Slideshow"), False, self.slideshowFromMenu, icon), ] def albumEntries(self,n): return [ (90, _("Slideshow"), False, self.slideshowFromAlbum), ] def slideshow(self, filelist): # if not os.path.exists(self.tempdir): # os.mkdir(self.tempdir, 0700) # else: # for f in os.listdir(self.tempdir): # os.remove(os.path.join(self.tempdir, f)) # for f in filelist: # os.system('ln -s ' + f + ' ' + self.tempdir) # os.system('gqview -f -s ' + self.tempdir) os.system(self.player + ' ' + ' '.join(filelist)) def slideshowFromAlbum(self, node): filelist = [] dirlist = os.listdir(node.file) dirlist.sort() for f in dirlist: if os.path.splitext(f)[1] in self.movextlist: if os.path.exists(os.path.join(node.file, os.path.splitext(f)[0] + '.jpg')): filelist.append(os.path.join(node.file, f)) else: for movext in self.movextlist: if os.path.exists(os.path.join(node.file, os.path.splitext(f)[0] + movext)): break else: filelist.append(os.path.join(node.file, f)) self.slideshow(filelist) return False def slideshowFromMenu(self, l): filelist = [] for f in l: for movext in self.movextlist: if os.path.exists(os.path.splitext(f.file)[0] + movext): filelist.append(os.path.splitext(f.file)[0] + movext) break else: filelist.append(f.file) self.slideshow(filelist) return False