Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGary Martin <gary@garycmartin.com>2012-10-04 13:38:40 (GMT)
committer Gary Martin <gary@garycmartin.com>2012-10-04 13:38:40 (GMT)
commit6ff7132c8556079edaf6d1308d79ca7ffcd2b651 (patch)
tree60d151c82194ab3b18c3d901f865edf458e2d98f
parent9fa9fca2618ba5c5fae61c135ffd6c4814e44b5b (diff)
Move Nice clock face caching code into _size_allocate_cb to fix Nice clock layout bugs when user changes the display (adds information, rotates the display).
-rwxr-xr-xclock.py25
1 files changed, 10 insertions, 15 deletions
diff --git a/clock.py b/clock.py
index bb793cb..0a30391 100755
--- a/clock.py
+++ b/clock.py
@@ -525,9 +525,6 @@ class ClockFace(gtk.DrawingArea):
# Black
self._COLOR_BLACK = "#000000"
- # cache backgrounds
- self._nice_background_cache = None
-
# gtk.Widget signals
self.connect("expose-event", self._expose_cb)
self.connect("size-allocate", self._size_allocate_cb)
@@ -564,6 +561,16 @@ class ClockFace(gtk.DrawingArea):
# Reload the svg handle
self._svg_handle = rsvg.Handle(file="clock.svg")
+ cr = self.window.cairo_create()
+ self._nice_background_cache = cr.get_target().create_similar(
+ cairo.CONTENT_COLOR_ALPHA, self._radius * 2,
+ self._radius * 2)
+ cache_ctx = cairo.Context(self._nice_background_cache)
+ scale_x = self._radius * 2.0 / self._svg_handle.props.width
+ scale_y = self._radius * 2.0 / self._svg_handle.props.height
+ matrix = cairo.Matrix(xx=scale_x, yy=scale_y)
+ cache_ctx.transform(matrix)
+ self._svg_handle.render_cairo(cache_ctx)
self.initialized = True
@@ -740,18 +747,6 @@ class ClockFace(gtk.DrawingArea):
"""
# We transform the background SVG
cr = self.window.cairo_create()
-
- if self._nice_background_cache == None:
- self._nice_background_cache = cr.get_target().create_similar(
- cairo.CONTENT_COLOR_ALPHA, self._radius * 2,
- self._radius * 2)
- cache_ctx = cairo.Context(self._nice_background_cache)
- scale_x = self._radius * 2.0 / self._svg_handle.props.width
- scale_y = self._radius * 2.0 / self._svg_handle.props.height
- matrix = cairo.Matrix(xx=scale_x, yy=scale_y)
- cache_ctx.transform(matrix)
- self._svg_handle.render_cairo(cache_ctx)
-
cr.translate(self._center_x - self._radius,
self._center_y - self._radius)
cr.set_source_surface(self._nice_background_cache)