Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/ImageView.py
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-10-02 03:48:29 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-10-02 03:48:29 (GMT)
commit03e5e85f43d973323e56073071e2ddf0c4dd46c9 (patch)
treee18c0d7b67dafbc96cd6233d98830a66679af471 /ImageView.py
parentecb1f86526376bd8ddad004c50a157b1d0d2fb5b (diff)
Center the image on the screen
Signed-off-by: Agustin Zubiaga <aguz@sugarlabs.org>
Diffstat (limited to 'ImageView.py')
-rw-r--r--ImageView.py16
1 files changed, 6 insertions, 10 deletions
diff --git a/ImageView.py b/ImageView.py
index cbfa560..2785337 100644
--- a/ImageView.py
+++ b/ImageView.py
@@ -133,17 +133,13 @@ class ImageViewer(Gtk.DrawingArea):
x = rect.x
y = rect.y
- if self.parent:
- rect = self.parent.get_allocation()
- if rect.width > w:
- x = int(((rect.width - x) - w) / 2)
- if rect.height > h:
- y = int(((rect.height - y) - h) / 2)
-
- # TODO: center the image into the canvas
- # ctx.translate(x, y)
+ rect = self.get_allocation()
+ if rect.width > w:
+ x = int((rect.width - w) / 2)
+ if rect.height > h:
+ y = int((rect.height - h) / 2)
- ctx.set_source_surface(self.surface, 0, 0)
+ ctx.set_source_surface(self.surface, x, y)
ctx.paint()
logging.debug('ImageViewer.draw end %f', (time.time() - timeini))