1 diff -Naur gnome-activity-journal-0.8.0.orig/src/common.py gnome-activity-journal-0.8.0/src/common.py
2 --- gnome-activity-journal-0.8.0.orig/src/common.py 2011-07-16 18:27:43.000000000 +0200
3 +++ gnome-activity-journal-0.8.0/src/common.py 2011-10-09 07:04:07.011645989 +0200
26 SIZE_TEXT_TIMELINEVIEW = ["small", "medium", "large", "x-large"]
27 SIZE_TEXT_THUMBVIEW = ["x-small", "small", "large", "xx-large"]
29 -THUMBNAIL_FACTORIES = {
30 - SIZE_NORMAL: gnome.ui.ThumbnailFactory("normal"),
31 - SIZE_LARGE: gnome.ui.ThumbnailFactory("large")
34 + THUMBNAIL_FACTORIES = {
35 + SIZE_NORMAL: gnome.ui.ThumbnailFactory("normal"),
36 + SIZE_LARGE: gnome.ui.ThumbnailFactory("large")
38 ICON_THEME = gtk.icon_theme_get_default()
40 #FIXME i know it's ugly. Btw this is only a temp solution. It will be removed
43 thumb = THUMBS[size][self.uri]
46 - factory = THUMBNAIL_FACTORIES[size]
47 - location = factory.lookup(self.uri, self.mtime)
49 - thumb, mtime = THUMBS[size][self.uri] = \
50 - (gtk.gdk.pixbuf_new_from_file(location), self.mtime)
52 - if factory.has_valid_failed_thumbnail(self.uri, self.mtime):
53 - thumb = THUMBS[size][self.uri] = None
55 + factory = THUMBNAIL_FACTORIES[size]
56 + location = factory.lookup(self.uri, self.mtime)
58 + thumb, mtime = THUMBS[size][self.uri] = \
59 + (gtk.gdk.pixbuf_new_from_file(location), self.mtime)
61 - thumb = factory.generate_thumbnail(self.uri, self.mime_type)
63 - # maybe we are able to use a custom thumbnailer here
64 - if filter(lambda name: "application-vnd.oasis.opendocument" in name, self.icon_names):
65 - thumb = create_opendocument_thumb(self._file_object.get_path())
66 - elif "text-x-generic" in self.icon_names or "text-x-script" in self.icon_names:
68 - thumb = create_text_thumb(self, size, 1)
71 - elif "audio-x-generic" in self.icon_names:
74 - #thumb = self.get_audio_cover(size)
76 - factory.create_failed_thumbnail(self.uri, self.mtime)
77 + if factory.has_valid_failed_thumbnail(self.uri, self.mtime):
78 + thumb = THUMBS[size][self.uri] = None
80 - width, height = thumb.get_width(), thumb.get_height()
81 - if width > size[0] or height > size[1]:
82 - scale = min(float(size[0])/width, float(size[1])/height)
83 - thumb = gnome.ui.thumbnail_scale_down_pixbuf(
84 - thumb, int(scale*width), int(scale*height))
85 - factory.save_thumbnail(thumb, self.uri, self.mtime)
86 - THUMBS[size][self.uri] = (thumb, self.mtime)
87 + thumb = factory.generate_thumbnail(self.uri, self.mime_type)
89 + # maybe we are able to use a custom thumbnailer here
90 + if filter(lambda name: "application-vnd.oasis.opendocument" in name, self.icon_names):
91 + thumb = create_opendocument_thumb(self._file_object.get_path())
92 + elif "text-x-generic" in self.icon_names or "text-x-script" in self.icon_names:
94 + thumb = create_text_thumb(self, size, 1)
97 + elif "audio-x-generic" in self.icon_names:
100 + #thumb = self.get_audio_cover(size)
102 + factory.create_failed_thumbnail(self.uri, self.mtime)
104 + width, height = thumb.get_width(), thumb.get_height()
105 + if width > size[0] or height > size[1]:
106 + scale = min(float(size[0])/width, float(size[1])/height)
107 + thumb = gnome.ui.thumbnail_scale_down_pixbuf(
108 + thumb, int(scale*width), int(scale*height))
109 + factory.save_thumbnail(thumb, self.uri, self.mtime)
110 + THUMBS[size][self.uri] = (thumb, self.mtime)
112 if thumb is not None:
113 if thumb[1] != self.mtime: