Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGonzalo Odiard <godiard@sugarlabs.org>2014-04-11 02:03:54 (GMT)
committer Gonzalo Odiard <godiard@gmail.com>2014-05-14 21:21:41 (GMT)
commit24bf5a350a4e029c6b3eb10484826a9924c2aff5 (patch)
tree93a4136a6f81eee4df3f1f0f97a35e07c0fe8fec
parentdd749da6fdc05374ee656762f6c34d2c52ca6779 (diff)
Change expose events to draw
-rw-r--r--mapnav.py16
-rw-r--r--mapview.py12
-rw-r--r--questions.py6
-rw-r--r--stateview.py5
4 files changed, 18 insertions, 21 deletions
diff --git a/mapnav.py b/mapnav.py
index bf2d0a0..b5f0597 100644
--- a/mapnav.py
+++ b/mapnav.py
@@ -64,7 +64,7 @@ class MapNavView(Gtk.DrawingArea):
self.add_events(Gdk.EventMask.KEY_PRESS_MASK | Gdk.EventMask.POINTER_MOTION_MASK |
Gdk.EventMask.BUTTON_PRESS_MASK | Gdk.EventMask.BUTTON_RELEASE_MASK |
Gdk.EventMask.BUTTON1_MOTION_MASK)
- self.connect('expose_event', self.expose)
+ self.connect('draw', self.__draw_cb)
self.connect('key-press-event', self.__key_press_event_cb)
self.connect('button_press_event', self.__button_press_event_cb)
self.connect('motion_notify_event', self.__motion_notify_event_cb)
@@ -332,17 +332,17 @@ class MapNavView(Gtk.DrawingArea):
self._door_width = 3
self._door_height = 6
- def expose(self, widget, event):
- rect = self.get_allocation()
+ def __draw_cb(self, widget, ctx):
ctx = widget.window.cairo_create()
+ rect = self.get_allocation()
# set a clip region for the expose event
- ctx.rectangle(event.area.x, event.area.y, event.area.width,
- event.area.height)
- ctx.clip()
+ #ctx.rectangle(event.area.x, event.area.y, event.area.width,
+ # event.area.height)
+ #ctx.clip()
#logging.error('expose clipping area %d %d %d %d', event.area.x,
# event.area.y, event.area.width, event.area.height)
- self.draw(ctx, event.area.x, event.area.y, event.area.width,
- event.area.height)
+ clip_x, clip_y, clip_width, clip_height = ctx.clip_extents()
+ self.draw(ctx, clip_x, clip_y, clip_width, clip_height)
if self.view_mode == self.MODE_PLAY:
position = {'x': self.x, 'y': self.y, 'direction': self.direction}
diff --git a/mapview.py b/mapview.py
index 1966f03..d6c0b92 100644
--- a/mapview.py
+++ b/mapview.py
@@ -120,7 +120,7 @@ class TopMapView(Gtk.DrawingArea):
self._show_position = None
super(TopMapView, self).__init__()
self.set_size_request(width, height)
- self.connect('expose_event', self.expose)
+ self.connect('draw', self.__draw_cb)
def show_position(self, x, y, direction):
self._show_position = {'x': x, 'y': y, 'direction': direction}
@@ -130,14 +130,12 @@ class TopMapView(Gtk.DrawingArea):
self._show_position = None
self.queue_draw()
- def expose(self, widget, event):
- #rect = self.get_allocation()
- ctx = widget.window.cairo_create()
+ def __draw_cb(self, widget, ctx):
ctx.save()
# set a clip region for the expose event
- ctx.rectangle(event.area.x, event.area.y, event.area.width,
- event.area.height)
- ctx.clip()
+ #ctx.rectangle(event.area.x, event.area.y, event.area.width,
+ # event.area.height)
+ #ctx.clip()
view_data = {'width': self._width, 'height': self._height,
'show_position': self._show_position}
diff --git a/questions.py b/questions.py
index b1fdea8..0233af8 100644
--- a/questions.py
+++ b/questions.py
@@ -36,7 +36,7 @@ class DrawReplyArea(Gtk.DrawingArea):
self._width, self._height)
# Signals used to handle backing pixmap
- self.connect("expose_event", self.__expose_draw_reply_cb)
+ self.connect("draw", self.__draw_cb)
# Event signals
if self._edit:
@@ -71,10 +71,10 @@ class DrawReplyArea(Gtk.DrawingArea):
return True
# Redraw the screen from the backing pixmap
- def __expose_draw_reply_cb(self, widget, event):
+ def __draw_cb(self, widget, ctx):
if self.background is None:
self.setup()
- x, y, width, height = event.area
+ x, y, width, height = ctx.clip_extents()
widget.window.draw_drawable(widget.get_style().fg_gc[Gtk.StateType.NORMAL],
self.background, x, y, x, y, width, height)
if self._edit:
diff --git a/stateview.py b/stateview.py
index 87bb534..2f5a3c2 100644
--- a/stateview.py
+++ b/stateview.py
@@ -89,12 +89,11 @@ def main():
state = {'displayed_questions': 3, 'replied_questions': 2}
_model.data['state'] = state
- def expose(widget, event, state_view):
- ctx = widget.window.cairo_create()
+ def __draw_cb(widget, ctx, state_view):
state_view.draw(ctx)
return False
- area.connect('expose_event', expose, state_view)
+ area.connect('draw', __draw_cb, state_view)
window.add(area)
window.connect("destroy", Gtk.main_quit)