Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Quiñones <manuq@laptop.org>2012-08-17 13:00:15 (GMT)
committer Manuel Quiñones <manuq@laptop.org>2012-08-17 17:22:05 (GMT)
commit37df71836a9f3f91d1452794785a08dafbd91d78 (patch)
treeee4ebc53951a487f377edadd2cd9c9c742c8daf7
parent3067ae7e8c243f171a109fcf4fb805c6465506ef (diff)
Use the gdk window to get the depth of the preview pixmap - SL#3804
This prevents harcoding the depth, and uses the one from the gdk window. For this, the preview has to be done after the window is realized, so the code is wrapped in the expose-event callback. Also add a white background to the preview, otherwise artifacts appear for previews smaller than the preview box. Signed-off-by: Manuel Quiñones <manuq@laptop.org> Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r--src/jarabe/journal/expandedentry.py22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/jarabe/journal/expandedentry.py b/src/jarabe/journal/expandedentry.py
index e0c603f..d0c7166 100644
--- a/src/jarabe/journal/expandedentry.py
+++ b/src/jarabe/journal/expandedentry.py
@@ -194,11 +194,18 @@ class ExpandedEntry(gtk.EventBox):
return date
def _create_preview(self):
- width = style.zoom(320)
- height = style.zoom(240)
box = gtk.EventBox()
box.modify_bg(gtk.STATE_NORMAL, style.COLOR_WHITE.get_gdk_color())
+ box.connect('expose-event', self.__expose_event_cb)
+ box.connect_after('button-release-event',
+ self._preview_box_button_release_event_cb)
+ return box
+
+ def __expose_event_cb(self, box, event):
+ width = style.zoom(320)
+ height = style.zoom(240)
+
if len(self._metadata.get('preview', '')) > 4:
if self._metadata['preview'][1:4] == 'PNG':
preview_data = self._metadata['preview']
@@ -214,8 +221,11 @@ class ExpandedEntry(gtk.EventBox):
surface = cairo.ImageSurface.create_from_png(png_file)
png_width = surface.get_width()
png_height = surface.get_height()
- pixmap = gtk.gdk.Pixmap(None, png_width, png_height, 24)
+ gdk_window = self.get_toplevel().window
+ pixmap = gtk.gdk.Pixmap(gdk_window, png_width, png_height, -1)
cr = pixmap.cairo_create()
+ cr.set_source_rgb(1, 1, 1)
+ cr.paint()
cr.set_source_surface(surface, 0, 0)
cr.scale(width / png_width, height / png_height)
cr.paint()
@@ -230,15 +240,13 @@ class ExpandedEntry(gtk.EventBox):
if has_preview:
box.add(im)
+ im.show()
else:
label = gtk.Label()
label.set_text(_('No preview'))
label.set_size_request(width, height)
box.add(label)
-
- box.connect_after('button-release-event',
- self._preview_box_button_release_event_cb)
- return box
+ label.show()
def _create_technical(self):
vbox = gtk.VBox()