<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&#39;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 &lt;<a href="mailto:godiard@gmail.com">godiard@gmail.com</a>&gt;<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>         &#39;vertices&#39;      : None<br>     }<br>     <br>-    _TOOL_POLYGON = {<br>-        &#39;name&#39;          : &#39;polygon&#39;,<br>
-        &#39;line size&#39;     : 2,<br>-        &#39;fill color&#39;    : None,<br>-        &#39;stroke color&#39;  : None,<br>-        &#39;line shape&#39;    : &#39;circle&#39;,<br>-        &#39;fill&#39;          : True,<br>
-        &#39;vertices&#39;      : None<br>-    }<br>     <br>     _TOOL_BUCKET = {<br>         &#39;name&#39;          : &#39;bucket&#39;,<br>@@ -319,13 +310,6 @@ class ToolsToolbar(gtk.Toolbar):<br>         except:<br>             logging.debug(&#39;Could not create palette for tool Eraser&#39;)<br>
         <br>-        self._tool_polygon = ToolButton(&#39;tool-polygon&#39;)<br>-        self.insert(self._tool_polygon, -1)<br>-        self._tool_polygon.set_tooltip(_(&#39;Polygon&#39;))<br>-        try:<br>-            self._configure_palette(self._tool_polygon, self._TOOL_POLYGON)<br>
-        except:<br>-            logging.debug(&#39;Could not create palette for tool Polygon&#39;)<br>         <br>         self._tool_bucket = ToolButton(&#39;tool-bucket&#39;)<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&#39;s properties<br>-        self._tool_polygon.connect(&#39;clicked&#39;, self.set_tool, self._TOOL_POLYGON)<br>
         self._tool_pencil.connect(&#39;clicked&#39;, self.set_tool, self._TOOL_PENCIL)<br>         self._tool_brush.connect(&#39;clicked&#39;, self.set_tool, self._TOOL_BRUSH)<br>         self._tool_eraser.connect(&#39;clicked&#39;, 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[&#39;name&#39;] is self._TOOL_PENCIL[&#39;name&#39;] or \<br>
-             tool[&#39;name&#39;] is self._TOOL_POLYGON[&#39;name&#39;] or \<br>              tool[&#39;name&#39;] is self._TOOL_BRUSH[&#39;name&#39;] or \<br>              tool[&#39;name&#39;] is self._TOOL_ERASER[&#39;name&#39;]:<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[&#39;name&#39;] is self._TOOL_POLYGON[&#39;name&#39;]:<br>-            # Creating a CheckButton named &quot;Fill&quot;.<br>-            fill_checkbutton = gtk.CheckButton(_(&#39;Fill&#39;))<br>-            fill_checkbutton.show()<br>
-            fill_checkbutton.set_active(self._TOOL_POLYGON[&#39;fill&#39;])<br>-            <br>-            fill_checkbutton.connect(&#39;toggled&#39;, 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(_(&#39;Fill Color: &#39;))<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(&#39;color-set&#39;, self._on_color_set, self._TOOL_POLYGON)<br>         if tool[&#39;name&#39;] is self._TOOL_MARQUEE_RECTANGULAR[&#39;name&#39;]:<br>
             # Creating a CheckButton named &quot;Fill&quot;.<br>             keep_aspect_checkbutton = gtk.CheckButton(_(&#39;Keep aspect&#39;))<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(&#39;Checkbutton is Active: %s&#39;, checkbutton.get_active() )<br>-        <br>-        # New method for setting tools<br>
-        #self._activity.area.fill = checkbutton.get_active()<br>-        tool[&#39;fill&#39;] = checkbutton.get_active()<br>-        self.set_tool(tool=tool)<br>         <br> #     def _on_fill_checkbutton_map(self, checkbutton, data=None):<br>
 #         &quot;&quot;&quot;<br>@@ -734,6 +679,17 @@ class ShapesToolbar(gtk.Toolbar):<br>         &#39;fill&#39;          : True,<br>         &#39;vertices&#39;      : None<br>     }<br>+<br>+    _TOOL_POLYGON = {<br>+        &#39;name&#39;          : &#39;polygon&#39;,<br>
+        &#39;line size&#39;     : 2,<br>+        &#39;fill color&#39;    : None,<br>+        &#39;stroke color&#39;  : None,<br>+        &#39;line shape&#39;    : &#39;circle&#39;,<br>+        &#39;fill&#39;          : True,<br>
+        &#39;vertices&#39;      : 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(&#39;Could not create palette for Shape Line&#39;)<br>+<br>+        self._tool_polygon = ToolButton(&#39;tool-polygon&#39;)<br>+        self.insert(self._tool_polygon, -1)<br>
+        self._tool_polygon.set_tooltip(_(&#39;Free form&#39;))<br>+        try:<br>+            self._create_simple_palette(self._tool_polygon, self._TOOL_POLYGON)<br>+        except:<br>+            logging.debug(&#39;Could not create palette for tool Polygon&#39;)<br>
         <br>         self._shape_polygon = ToolButton(&#39;tool-shape-polygon&#39;)<br>         self.insert(self._shape_polygon, -1)<br>@@ -853,6 +817,7 @@ class ShapesToolbar(gtk.Toolbar):<br>         self._shape_arrow.connect(&#39;clicked&#39;, self.set_tool, self._SHAPE_ARROW)<br>
         self._shape_ellipse.connect(&#39;clicked&#39;, self.set_tool, self._SHAPE_ELLIPSE)<br>         #self._shape_freeform.connect(&#39;clicked&#39;, self.set_tool, self._SHAPE_FREEFORM)<br>+        self._tool_polygon.connect(&#39;clicked&#39;, self.set_tool, self._TOOL_POLYGON)<br>
         self._shape_heart.connect(&#39;clicked&#39;, self.set_tool, self._SHAPE_HEART)<br>         self._shape_line.connect(&#39;clicked&#39;, self.set_tool, self._SHAPE_LINE)<br>         self._shape_parallelogram.connect(&#39;clicked&#39;, self.set_tool, self._SHAPE_PARALLELOGRAM)<br>
@@ -934,6 +899,13 @@ class ShapesToolbar(gtk.Toolbar):<br>         <br>         spin.connect(&#39;value-changed&#39;, self._on_vertices_value_changed, self._SHAPE_POLYGON)<br>         <br>+    def _on_fill_checkbutton_toggled(self, checkbutton, button=None, tool=None):<br>
+        logging.debug(&#39;Checkbutton is Active: %s&#39;, checkbutton.get_active() )<br>+        <br>+        # New method for setting tools<br>+        #self._activity.area.fill = checkbutton.get_active()<br>+        tool[&#39;fill&#39;] = checkbutton.get_active()<br>
+        self.set_tool(tool=tool)<br>         <br>     def _configure_palette_shape_heart(self):<br>         logging.debug(&#39;Creating palette to shape heart&#39;)<br>@@ -980,6 +952,9 @@ class ShapesToolbar(gtk.Toolbar):<br>
         palette.content_box.pack_start(hbox)<br>         <br>         spin.connect(&#39;value-changed&#39;, self._on_vertices_value_changed, self._SHAPE_STAR)<br>+<br>+            <br>+<br>     <br>     def _configure_palette_shape_trapezoid(self):<br>
         logging.debug(&#39;Creating palette to shape trapezoid&#39;)<br>@@ -1039,6 +1014,18 @@ class ShapesToolbar(gtk.Toolbar):<br>         palette.content_box.pack_start(hbox)<br>         <br>         size_spinbutton.connect(&#39;value-changed&#39;, 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[&#39;name&#39;] is self._TOOL_POLYGON[&#39;name&#39;]:<br>+            # Creating a CheckButton named &quot;Fill&quot;.<br>
+            fill_checkbutton = gtk.CheckButton(_(&#39;Fill&#39;))<br>+            fill_checkbutton.show()<br>+            fill_checkbutton.set_active(self._TOOL_POLYGON[&#39;fill&#39;])<br>+            <br>+            fill_checkbutton.connect(&#39;toggled&#39;, 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>