Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/stateview.py
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@gmail.com>2012-05-04 04:04:10 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2012-05-04 04:04:10 (GMT)
commita5e5a30839c98d11d3dbc8e0305d80141eae481a (patch)
tree476f9ecd2c6499c552424c733b6406d07a53e82f /stateview.py
parentb69adce545f8c51eec7211b040b7d6ac0157d5bc (diff)
Avoid redrawing the stateview if the state ahas not changed
Signed-off-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'stateview.py')
-rw-r--r--stateview.py12
1 files changed, 12 insertions, 0 deletions
diff --git a/stateview.py b/stateview.py
index 3a6624b..b27aa6e 100644
--- a/stateview.py
+++ b/stateview.py
@@ -27,6 +27,10 @@ class StateView():
self._tmp_ctx = cairo.Context(self._tmp_image)
svg.render_cairo(self._tmp_ctx)
self._svg_width = svg.props.width
+ # last values to avoid redraws
+ self._last_cant_questions = 0
+ self._last_displayed_questions = 0
+ self._last_replied_questions = 0
def draw(self, ctx):
# calculate cell size
@@ -38,6 +42,14 @@ class StateView():
displayed_questions = len(state['displayed_questions'])
replied_questions = len(state['replied_questions'])
+ if self._last_cant_questions != cant_questions or \
+ self._last_displayed_questions != displayed_questions or \
+ self._last_replied_questions != replied_questions:
+ self._last_cant_questions = cant_questions
+ self._last_displayed_questions = displayed_questions
+ self._last_replied_questions = replied_questions
+ else:
+ return
scale = float(self._svg_width) / float(self._cell_size)
logging.error('draw stateview scale %s', scale)
ctx.save()