<a href="http://dev.laptop.org/ticket/3696">http://dev.laptop.org/ticket/3696</a><br><br>I want to work with the cursors (there are many bugs about this) and selection of fonts in the texts, but didn't have any response from the maintainer of this activity.<br clear="all">
<br>From 0f99bd0b5d6d03dfe6673d944764a9346427dee1 Mon Sep 17 00:00:00 2001<br>From: Gonzalo Odiard <<a href="mailto:godiard@gmail.com">godiard@gmail.com</a>><br>Date: Sat, 22 May 2010 10:16:52 -0300<br>Subject: [PATCH] move free form tool<br>
<br>---<br> toolbox.py | 97 ++++++++++++++++++++++++++----------------------------------<br> 1 files changed, 42 insertions(+), 55 deletions(-)<br><br>diff --git a/toolbox.py b/toolbox.py<br>index 6a01a72..c3bcc01 100644<br>
--- a/toolbox.py<br>+++ b/toolbox.py<br>@@ -216,15 +216,6 @@ class ToolsToolbar(gtk.Toolbar):<br> 'vertices' : None<br> }<br> <br>- _TOOL_POLYGON = {<br>- 'name' : 'polygon',<br>
- 'line size' : 2,<br>- 'fill color' : None,<br>- 'stroke color' : None,<br>- 'line shape' : 'circle',<br>- 'fill' : True,<br>
- 'vertices' : None<br>- }<br> <br> _TOOL_BUCKET = {<br> 'name' : 'bucket',<br>@@ -319,13 +310,6 @@ class ToolsToolbar(gtk.Toolbar):<br> except:<br> logging.debug('Could not create palette for tool Eraser')<br>
<br>- self._tool_polygon = ToolButton('tool-polygon')<br>- self.insert(self._tool_polygon, -1)<br>- self._tool_polygon.set_tooltip(_('Polygon'))<br>- try:<br>- self._configure_palette(self._tool_polygon, self._TOOL_POLYGON)<br>
- except:<br>- logging.debug('Could not create palette for tool Polygon')<br> <br> self._tool_bucket = ToolButton('tool-bucket')<br> self.insert(self._tool_bucket, -1)<br>
@@ -365,7 +349,6 @@ class ToolsToolbar(gtk.Toolbar):<br> <br> # New connect method<br> # Using dictionnaries to control tool's properties<br>- self._tool_polygon.connect('clicked', self.set_tool, self._TOOL_POLYGON)<br>
self._tool_pencil.connect('clicked', self.set_tool, self._TOOL_PENCIL)<br> self._tool_brush.connect('clicked', self.set_tool, self._TOOL_BRUSH)<br> self._tool_eraser.connect('clicked', self.set_tool, self._TOOL_ERASER)<br>
@@ -397,7 +380,6 @@ class ToolsToolbar(gtk.Toolbar):<br> <br> # We can set size when using either Pencil, Free Polygon, Brush or Eraser<br> if tool['name'] is self._TOOL_PENCIL['name'] or \<br>
- tool['name'] is self._TOOL_POLYGON['name'] or \<br> tool['name'] is self._TOOL_BRUSH['name'] or \<br> tool['name'] is self._TOOL_ERASER['name']:<br>
<br>@@ -468,36 +450,6 @@ class ToolsToolbar(gtk.Toolbar):<br> #vbox.pack_end(separator)<br> #separator.show()<br> <br>- # User is able to fill or not a polygon, and choose its fill color<br>
- if tool['name'] is self._TOOL_POLYGON['name']:<br>- # Creating a CheckButton named "Fill".<br>- fill_checkbutton = gtk.CheckButton(_('Fill'))<br>- fill_checkbutton.show()<br>
- fill_checkbutton.set_active(self._TOOL_POLYGON['fill'])<br>- <br>- fill_checkbutton.connect('toggled', self._on_fill_checkbutton_toggled, widget, self._TOOL_POLYGON)<br>- <br>
- #palette.set_content(fill_checkbutton)<br>- palette.action_bar.pack_start(fill_checkbutton)<br>- <br>- # Creating Fill Color Button<br>- hbox = gtk.HBox()<br>- hbox.show()<br>
- <br>- label = gtk.Label(_('Fill Color: '))<br>- label.show()<br>- <br>- colorbutton = ButtonFillColor(self._activity)<br>- colorbutton.show_all()<br>
- <br>- hbox.pack_start(label)<br>- hbox.pack_start(colorbutton)<br>- <br>- #palette.action_bar.pack_start(label)<br>- #palette.action_bar.pack_start(colorbutton)<br>
- content_box.pack_start(hbox)<br>- <br>- colorbutton.connect_after('color-set', self._on_color_set, self._TOOL_POLYGON)<br> if tool['name'] is self._TOOL_MARQUEE_RECTANGULAR['name']:<br>
# Creating a CheckButton named "Fill".<br> keep_aspect_checkbutton = gtk.CheckButton(_('Keep aspect'))<br>@@ -545,13 +497,6 @@ class ToolsToolbar(gtk.Toolbar):<br> #setting cursor: Moved to Area<br>
<br> <br>- def _on_fill_checkbutton_toggled(self, checkbutton, button=None, tool=None):<br>- logging.debug('Checkbutton is Active: %s', checkbutton.get_active() )<br>- <br>- # New method for setting tools<br>
- #self._activity.area.fill = checkbutton.get_active()<br>- tool['fill'] = checkbutton.get_active()<br>- self.set_tool(tool=tool)<br> <br> # def _on_fill_checkbutton_map(self, checkbutton, data=None):<br>
# """<br>@@ -734,6 +679,17 @@ class ShapesToolbar(gtk.Toolbar):<br> 'fill' : True,<br> 'vertices' : None<br> }<br>+<br>+ _TOOL_POLYGON = {<br>+ 'name' : 'polygon',<br>
+ 'line size' : 2,<br>+ 'fill color' : None,<br>+ 'stroke color' : None,<br>+ 'line shape' : 'circle',<br>+ 'fill' : True,<br>
+ 'vertices' : None<br>+ }<br>+<br> <br> ##The Constructor<br> def __init__(self, activity):<br>@@ -782,6 +738,14 @@ class ShapesToolbar(gtk.Toolbar):<br> self._configure_palette_shape_line()<br>
except:<br> logging.debug('Could not create palette for Shape Line')<br>+<br>+ self._tool_polygon = ToolButton('tool-polygon')<br>+ self.insert(self._tool_polygon, -1)<br>
+ self._tool_polygon.set_tooltip(_('Free form'))<br>+ try:<br>+ self._create_simple_palette(self._tool_polygon, self._TOOL_POLYGON)<br>+ except:<br>+ logging.debug('Could not create palette for tool Polygon')<br>
<br> self._shape_polygon = ToolButton('tool-shape-polygon')<br> self.insert(self._shape_polygon, -1)<br>@@ -853,6 +817,7 @@ class ShapesToolbar(gtk.Toolbar):<br> self._shape_arrow.connect('clicked', self.set_tool, self._SHAPE_ARROW)<br>
self._shape_ellipse.connect('clicked', self.set_tool, self._SHAPE_ELLIPSE)<br> #self._shape_freeform.connect('clicked', self.set_tool, self._SHAPE_FREEFORM)<br>+ self._tool_polygon.connect('clicked', self.set_tool, self._TOOL_POLYGON)<br>
self._shape_heart.connect('clicked', self.set_tool, self._SHAPE_HEART)<br> self._shape_line.connect('clicked', self.set_tool, self._SHAPE_LINE)<br> self._shape_parallelogram.connect('clicked', self.set_tool, self._SHAPE_PARALLELOGRAM)<br>
@@ -934,6 +899,13 @@ class ShapesToolbar(gtk.Toolbar):<br> <br> spin.connect('value-changed', self._on_vertices_value_changed, self._SHAPE_POLYGON)<br> <br>+ def _on_fill_checkbutton_toggled(self, checkbutton, button=None, tool=None):<br>
+ logging.debug('Checkbutton is Active: %s', checkbutton.get_active() )<br>+ <br>+ # New method for setting tools<br>+ #self._activity.area.fill = checkbutton.get_active()<br>+ tool['fill'] = checkbutton.get_active()<br>
+ self.set_tool(tool=tool)<br> <br> def _configure_palette_shape_heart(self):<br> logging.debug('Creating palette to shape heart')<br>@@ -980,6 +952,9 @@ class ShapesToolbar(gtk.Toolbar):<br>
palette.content_box.pack_start(hbox)<br> <br> spin.connect('value-changed', self._on_vertices_value_changed, self._SHAPE_STAR)<br>+<br>+ <br>+<br> <br> def _configure_palette_shape_trapezoid(self):<br>
logging.debug('Creating palette to shape trapezoid')<br>@@ -1039,6 +1014,18 @@ class ShapesToolbar(gtk.Toolbar):<br> palette.content_box.pack_start(hbox)<br> <br> size_spinbutton.connect('value-changed', self._on_line_size_value_changed, tool)<br>
+<br>+ # User is able to fill or not a polygon, and choose its fill color<br>+ if tool['name'] is self._TOOL_POLYGON['name']:<br>+ # Creating a CheckButton named "Fill".<br>
+ fill_checkbutton = gtk.CheckButton(_('Fill'))<br>+ fill_checkbutton.show()<br>+ fill_checkbutton.set_active(self._TOOL_POLYGON['fill'])<br>+ <br>+ fill_checkbutton.connect('toggled', self._on_fill_checkbutton_toggled, widget, self._TOOL_POLYGON)<br>
+ <br>+ #palette.set_content(fill_checkbutton)<br>+ palette.action_bar.pack_start(fill_checkbutton)<br> <br> <br> def _configure_palette_shape_line(self):<br>-- <br>1.6.6.1<br>
<br><br>-- <br>Gonzalo Odiard<br>SugarLabs Argentina<br>