Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-08-29 09:34:56 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-08-29 09:34:56 (GMT)
commite700ed1e2d027208f2aaed037c52ff9c4d6cc063 (patch)
tree6f94856187419e5aae0a45bb6b03cb7c15c69fa8 /sugar
parente25847c37506f9190a4364443d3a827b8d51acee (diff)
Expose and size allocation fixes.
Diffstat (limited to 'sugar')
-rw-r--r--sugar/graphics/icon.py39
1 files changed, 30 insertions, 9 deletions
diff --git a/sugar/graphics/icon.py b/sugar/graphics/icon.py
index 6d7a4c6..133e256 100644
--- a/sugar/graphics/icon.py
+++ b/sugar/graphics/icon.py
@@ -17,6 +17,7 @@
import os
import re
+import math
import time
import logging
@@ -337,18 +338,38 @@ class Icon(gtk.Image):
self._buffer.width = width
self._buffer.height = height
- def do_expose_event(self, event):
+ def do_size_request(self, requisition):
self._sync_image_properties()
-
surface = self._buffer.get_surface()
- if surface is not None:
- cr = self.window.cairo_create()
-
- x = self.allocation.x
- y = self.allocation.y
+ if surface:
+ requisition[0] = surface.get_width()
+ requisition[1] = surface.get_height()
+ elif self._buffer.width and self._buffer.height:
+ requisition[0] = self._buffer.width
+ requisition[1] = self._buffer.width
+ else:
+ requisition[0] = requisition[1] = 0
- cr.set_source_surface(surface, x, y)
- cr.paint()
+ def do_expose_event(self, event):
+ self._sync_image_properties()
+ surface = self._buffer.get_surface()
+ if surface is None:
+ return
+
+ xpad, ypad = self.get_padding()
+ xalign, yalign = self.get_alignment()
+ requisition = self.get_child_requisition()
+ if self.get_direction != gtk.TEXT_DIR_LTR:
+ xalign = 1.0 - xalign
+
+ x = math.floor(self.allocation.x + xpad +
+ (self.allocation.width - requisition[0]) * xalign)
+ y = math.floor(self.allocation.y + ypad +
+ (self.allocation.height - requisition[1]) * yalign)
+
+ cr = self.window.cairo_create()
+ cr.set_source_surface(surface, x, y)
+ cr.paint()
def do_set_property(self, pspec, value):
if pspec.name == 'xo-color':