2
# Copyright (C) 2012 Cole Kendrick colej.kendrick@gmail.com Alexander Kendrick kentalex8@gmail.com
3
# This program is free software: you can redistribute it and/or modify it
4
# under the terms of the GNU General Public License version 3, as published
5
# by the Free Software Foundation.
7
# This program is distributed in the hope that it will be useful, but
8
# WITHOUT ANY WARRANTY; without even the implied warranties of
9
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
10
# PURPOSE. See the GNU General Public License for more details.
12
# You should have received a copy of the GNU General Public License along
13
# with this program. If not, see <http://www.gnu.org/licenses/>.
16
from gi.repository import Gtk, Gio, Gdk
17
from gi.repository.GdkPixbuf import Pixbuf
20
def InitDisplay(self,builder, sourceFolder,sourceInterval):
24
self.builder.get_object("folderChooser").set_current_folder(sourceFolder)
25
self.builder.get_object("intervalEdit").set_value(int(sourceInterval))
26
iconStore = Gtk.ListStore(Pixbuf)
27
iconview = self.builder.get_object("displayView")
28
iconview.set_columns(-1)
29
iconview.set_model(iconStore)
30
iconview.set_pixbuf_column(0)
31
Status = self.builder.get_object("status")
33
#ensure the directory exists before continuing.
34
if os.path.exists(sourceFolder):
35
print "Directory "+sourceFolder+" is valid"
37
# maybe do a dialog here?
39
print "Could not find directory "+sourceFolder+" attempting to create it."
40
os.makedirs(sourceFolder)
41
print "Directory created at "+sourceFolder
43
print "Could not create directory at "+sourceFolder
45
for name in os.listdir(sourceFolder):
46
filename = os.path.join(sourceFolder, name)
47
if name.endswith(".jpg") or name.endswith(".png") or name.endswith(".jpeg"):
48
if name.endswith(".jpg") or name.endswith(".jpeg"):
49
files_jpg = files_jpg + 1
50
if name.endswith(".png"):
51
files_png = files_png + 1
53
pixbuf = Pixbuf.new_from_file_at_size(filename,96,96)
54
iconStore.append([pixbuf])
56
print ("%s not a image file!" % (filename))
60
Status.push(1,"No images found in %s" % (sourceFolder))
62
Status.push(1,"%s images found (%s .jpg, %s .png)" % (files, files_jpg, files_png))