<div class="gmail_quote">On Wed, Jun 2, 2010 at 3:20 AM, James Cameron <span dir="ltr"><<a href="mailto:quozl@laptop.org">quozl@laptop.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Wed, Jun 02, 2010 at 02:02:04AM -0300, Gonzalo Odiard wrote:<br>
> Tomeu was right. Catching the key stokes in the activity works.<br>
<br>
</div>Yes, I see, that works well.<br>
<br>
Are you happy with relative size change rather than absolute? The<br>
ticket originally asked for absolute size setting. You have made the<br>
keys change the size relative to the current size.<br>
<br></blockquote><div>I think its better for a drawing activity. Absolute sizes limit to 4 line widths only.<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Here is the patch with your usual whitespace errors fixed, and a rewrite<br>
of the key handling using a dictionary again.<br>
<br></blockquote><div>Thanks<br> </div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
>From e2f9eba803f44aeba778221825dc6f976087b3a4 Mon Sep 17 00:00:00 2001<br>
<div class="im">From: Gonzalo Odiard <<a href="mailto:godiard@gmail.com">godiard@gmail.com</a>><br>
</div>Date: Wed, 2 Jun 2010 16:07:06 +1000<br>
Subject: [PATCH] slider keys change line size, <a href="http://dev.laptop.org" target="_blank">dev.laptop.org</a> #8865<br>
<br>
Connects XO-1 and XO-1.5 slider function keys to line size change for<br>
pencil, eraser, brush and rainbow. The size change is relative to<br>
current size.<br>
<br>
<a href="http://dev.laptop.org/ticket/8865" target="_blank">http://dev.laptop.org/ticket/8865</a><br>
<br>
Reviewed-by: James Cameron <<a href="mailto:quozl@laptop.org">quozl@laptop.org</a>><br>
Tested-by: James Cameron <<a href="mailto:quozl@laptop.org">quozl@laptop.org</a>><br>
---<br>
Area.py | 12 +++++++-----<br>
OficinaActivity.py | 7 +++++++<br>
2 files changed, 14 insertions(+), 5 deletions(-)<br>
<div class="im"><br>
diff --git a/Area.py b/Area.py<br>
</div>index 7b8c8b4..570d093 100644<br>
<div class="im">--- 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>
</div>@@ -1164,8 +1162,12 @@ class Area(gtk.DrawingArea):<br>
<div class="im"> 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>
def _keep_selection_ratio(self, coords):<br>
def sign(x):<br>
diff --git a/OficinaActivity.py b/OficinaActivity.py<br>
</div>index 332f198..c72576a 100644<br>
<div class="im">--- a/OficinaActivity.py<br>
+++ b/OficinaActivity.py<br>
</div>@@ -117,6 +117,8 @@ class OficinaActivity(activity.Activity):<br>
<div class="im"> 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>
</div>@@ -131,6 +133,11 @@ class OficinaActivity(activity.Activity):<br>
<div class="im"><br>
self._setup_handle = self.connect('map', map_cp)<br>
<br>
+ def key_press(self, widget, event):<br>
</div>+ sliders = {65474: -5, 65475: -1, 65476: 1, 65477: 5}<br>
+ if event.keyval in sliders:<br>
+ self.area.change_line_size(sliders[event.keyval])<br>
<div class="im">+<br>
def read_file(self, file_path):<br>
'''Read file from Sugar Journal.'''<br>
<br>
--<br>
</div>1.7.1<br>
<font color="#888888"><br>
--<br>
</font><div><div></div><div class="h5">James Cameron<br>
<a href="http://quozl.linux.org.au/" target="_blank">http://quozl.linux.org.au/</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>Gonzalo<br>