Tomeu was right. Catching the key stokes in the activity works.<br><br>From 08e0226731c13e74b993b59c1a2c8165e9ad3654 Mon Sep 17 00:00:00 2001<br>From: Gonzalo Odiard <<a href="mailto:godiard@gmail.com">godiard@gmail.com</a>><br>
Date: Wed, 2 Jun 2010 01:59:54 -0300<br>Subject: [PATCH] implement OLPC #8865<br><br>---<br> Area.py | 13 ++++++++-----<br> OficinaActivity.py | 15 +++++++++++++++<br> 2 files changed, 23 insertions(+), 5 deletions(-)<br>
<br>diff --git a/Area.py b/Area.py<br>index e81fcdc..8a5e523 100644<br>--- a/Area.py<br>+++ b/Area.py<br>@@ -97,15 +97,13 @@ class Area(gtk.DrawingArea):<br> gtk.gdk.BUTTON_PRESS_MASK |<br> gtk.gdk.BUTTON_RELEASE_MASK|<br>
gtk.gdk.EXPOSURE_MASK |<br>- gtk.gdk.KEY_PRESS_MASK |<br>- gtk.gdk.KEY_RELEASE_MASK) <br>+ gtk.gdk.KEY_PRESS_MASK) <br> <br> self.connect("expose_event",self.expose)<br>
self.connect("motion_notify_event", self.mousemove)<br> self.connect("button_press_event", self.mousedown)<br> self.connect("button_release_event", self.mouseup)<br> self.connect("key_press_event", self.key_press)<br>
- self.connect("key_release_event", self.key_release)<br> <br> self.set_flags(gtk.CAN_FOCUS)<br> self.grab_focus()<br>@@ -1163,8 +1161,13 @@ class Area(gtk.DrawingArea):<br> self.window.set_cursor(gtk.gdk.Cursor(gtk.gdk.TCROSS))<br>
widget.queue_draw()<br> <br>- def key_release(self,widget,event):<br>- pass<br>+ def change_line_size(self, delta):<br>+ if self.tool['name'] in ['pencil','eraser','brush','rainbow']:<br>
+ size = self.tool['line size'] + delta<br>+ self.tool['line size'] = size<br>+ self.configure_line(size)<br>+ self.queue_draw()<br>+<br> <br> def _keep_selection_ratio(self, coords):<br>
def sign(x):<br>diff --git a/OficinaActivity.py b/OficinaActivity.py<br>index f7dd088..8259ca8 100644<br>--- a/OficinaActivity.py<br>+++ b/OficinaActivity.py<br>@@ -116,6 +116,8 @@ class OficinaActivity(activity.Activity):<br>
self.set_toolbox(toolbox)<br> toolbox.show()<br> <br>+ self.connect("key_press_event", self.key_press)<br>+<br> # setup self.area only once<br> <br> def map_cp(widget):<br>
@@ -130,6 +132,19 @@ class OficinaActivity(activity.Activity):<br> <br> self._setup_handle = self.connect('map', map_cp)<br> <br>+<br>+ def key_press(self,widget,event):<br>+ if (event.keyval >= 65474) and (event.keyval <= 65477):<br>
+ if event.keyval == 65474:<br>+ self.area.change_line_size(-5)<br>+ elif event.keyval == 65475:<br>+ self.area.change_line_size(-1)<br>+ elif event.keyval == 65476:<br>
+ self.area.change_line_size(1)<br>+ elif event.keyval == 65477:<br>+ self.area.change_line_size(5)<br>+<br>+<br> def read_file(self, file_path):<br> '''Read file from Sugar Journal.'''<br>
<br>-- <br>1.6.6.1<br><br clear="all"><br>-- <br>Gonzalo<br>