2
# Copyright 2009, Martin Owens.
4
# This program is free software: you can redistribute it and/or modify
5
# it under the terms of the GNU General Public License as published by
6
# the Free Software Foundation, either version 3 of the License, or
7
# (at your option) any later version.
9
# This program is distributed in the hope that it will be useful,
10
# but WITHOUT ANY WARRANTY; without even the implied warranty of
11
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
# GNU General Public License for more details.
14
# You should have received a copy of the GNU General Public License
15
# along with this program. If not, see <http://www.gnu.org/licenses/>.
18
List images in a single directory.
21
from gwc.base import ListerBase, add_lister
23
class folderLister(ListerBase):
24
"""Pick a wallpaper out of a folder at random"""
27
icon = 'gtk-directory'
28
variables = [ 'localfolder' ]
30
def __init__(self, dir):
31
lister.__init__(self, dir)
34
if os.path.exists(self._dir):
35
for item in self.imgList(self._dir):
38
def imgList(self, dir):
39
for f in os.listdir(dir):
40
path = os.path.join(dir, f)
41
if os.path.isfile(path) and os.access(path,os.R_OK):
46
elif os.path.isdir(path) and config['recursive']=='True':
47
for item in self.imgList(path):
50
def widgets(self, config):
51
"""Return a list of widgets for local folder selection"""
56
if __name__ != '__main__':
57
add_lister(folderLister)