No subject
Mon Mar 15 02:42:15 EDT 2010
com">godiard at gmail.com</a>><br>
</div>Date: Wed, 2 Jun 2010 16:07:06 +1000<br>
Subject: [PATCH] slider keys change line size, <a href=3D"http://dev.laptop=
.org" target=3D"_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. =A0The size change is relative to<br>
current size.<br>
<br>
<a href=3D"http://dev.laptop.org/ticket/8865" target=3D"_blank">http://dev.=
laptop.org/ticket/8865</a><br>
<br>
Reviewed-by: James Cameron <<a href=3D"mailto:quozl at laptop.org">quozl at la=
ptop.org</a>><br>
Tested-by: James Cameron <<a href=3D"mailto:quozl at laptop.org">quozl at lapt=
op.org</a>><br>
---<br>
=A0Area.py =A0 =A0 =A0 =A0 =A0 =A0| =A0 12 +++++++-----<br>
=A0OficinaActivity.py | =A0 =A07 +++++++<br>
=A02 files changed, 14 insertions(+), 5 deletions(-)<br>
<div class=3D"im"><br>
diff --git a/Area.py b/Area.py<br>
</div>index 7b8c8b4..570d093 100644<br>
<div class=3D"im">--- a/Area.py<br>
+++ b/Area.py<br>
@@ -97,15 +97,13 @@ class Area(gtk.DrawingArea):<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gtk.gdk.BUTTON_PRESS_MASK |<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gtk.gdk.BUTTON_RELEASE_MASK|<br>
=A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 gtk.gdk.EXPOSURE_MASK |<br>
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0gtk.gdk.KEY_PRESS_MASK |<br>
- =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0gtk.gdk.KEY_RELEASE_MASK)<br>
+ =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0gtk.gdk.KEY_PRESS_MASK)<br>
<br>
=A0 =A0 =A0 =A0 self.connect("expose_event",self.expose)<br>
=A0 =A0 =A0 =A0 self.connect("motion_notify_event", self.mousemo=
ve)<br>
=A0 =A0 =A0 =A0 self.connect("button_press_event", self.mousedow=
n)<br>
=A0 =A0 =A0 =A0 self.connect("button_release_event", self.mouseu=
p)<br>
=A0 =A0 =A0 =A0 self.connect("key_press_event", self.key_press)<=
br>
- =A0 =A0 =A0 =A0self.connect("key_release_event", self.key_relea=
se)<br>
<br>
=A0 =A0 =A0 =A0 self.set_flags(gtk.CAN_FOCUS)<br>
=A0 =A0 =A0 =A0 self.grab_focus()<br>
</div>@@ -1164,8 +1162,12 @@ class Area(gtk.DrawingArea):<br>
<div class=3D"im"> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 self.window.set_cursor(g=
tk.gdk.Cursor(gtk.gdk.TCROSS))<br>
=A0 =A0 =A0 =A0 =A0 =A0 widget.queue_draw()<br>
<br>
- =A0 =A0def key_release(self,widget,event):<br>
- =A0 =A0 =A0 =A0pass<br>
+ =A0 =A0def change_line_size(self, delta):<br>
+ =A0 =A0 =A0 =A0if self.tool['name'] in ['pencil','era=
ser','brush','rainbow']:<br>
+ =A0 =A0 =A0 =A0 =A0 =A0size =3D self.tool['line size'] + delta<br=
>
+ =A0 =A0 =A0 =A0 =A0 =A0self.tool['line size'] =3D size<br>
+ =A0 =A0 =A0 =A0 =A0 =A0self.configure_line(size)<br>
+ =A0 =A0 =A0 =A0 =A0 =A0self.queue_draw()<br>
<br>
=A0 =A0 def _keep_selection_ratio(self, coords):<br>
=A0 =A0 =A0 =A0 def sign(x):<br>
diff --git a/OficinaActivity.py b/OficinaActivity.py<br>
</div>index 332f198..c72576a 100644<br>
<div class=3D"im">--- a/OficinaActivity.py<br>
+++ b/OficinaActivity.py<br>
</div>@@ -117,6 +117,8 @@ class OficinaActivity(activity.Activity):<br>
<div class=3D"im"> =A0 =A0 =A0 =A0 self.set_toolbox(toolbox)<br>
=A0 =A0 =A0 =A0 toolbox.show()<br>
<br>
+ =A0 =A0 =A0 =A0self.connect("key_press_event", self.key_press)<=
br>
+<br>
=A0 =A0 =A0 =A0 # setup self.area only once<br>
<br>
=A0 =A0 =A0 =A0 def map_cp(widget):<br>
</div>@@ -131,6 +133,11 @@ class OficinaActivity(activity.Activity):<br>
<div class=3D"im"><br>
=A0 =A0 =A0 =A0 self._setup_handle =3D self.connect('map', map_cp)=
<br>
<br>
+ =A0 =A0def key_press(self, widget, event):<br>
</div>+ =A0 =A0 =A0 =A0sliders =3D {65474: -5, 65475: -1, 65476: 1, 65477: =
5}<br>
+ =A0 =A0 =A0 =A0if event.keyval in sliders:<br>
+ =A0 =A0 =A0 =A0 =A0 =A0self.area.change_line_size(sliders[event.keyval])<=
br>
<div class=3D"im">+<br>
=A0 =A0 def read_file(self, file_path):<br>
=A0 =A0 =A0 =A0 '''Read file from Sugar Journal.'''=
;<br>
<br>
--<br>
</div>1.7.1<br>
<font color=3D"#888888"><br>
--<br>
</font><div><div></div><div class=3D"h5">James Cameron<br>
<a href=3D"http://quozl.linux.org.au/" target=3D"_blank">http://quozl.linux=
.org.au/</a><br>
</div></div></blockquote></div><br><br clear=3D"all"><br>-- <br>Gonzalo<br>
--000e0cd48b2002c7290488097fb5--
More information about the Sugar-devel
mailing list