[Sugar-devel] [PATCH v2 Paint] Changes made to save the last added text item. (OLPC #5917)

Gonzalo Odiard gonzalo at laptop.org
Mon Oct 18 07:55:52 EDT 2010


I want to add to the review made from James:

* the text tool from Paint is in bad state. I want to change it to support
text styles and the actual approach don't allow it.
* there are variables with names in portuguese like janela and estadoTexto.
estadoTexto means text_status :(
* estadoTexto use values like 1 and 0, like you did. I agree with James, it
makes the code difficult to read and is a bad practice.

Then I propose:

* Create the constants and replace in the use with estadoTexto.
* rename estadoTexto to text_status.
* put the part of Desenho.text where the text is printed in the image in a
new method. At the start of OficinaActivity.write_file, verify the
text_status and call the new method if necessary.

Regards

Gonzalo


On Sun, Oct 17, 2010 at 5:47 AM, Ishan Bansal <ishan at seeta.in> wrote:

> New variable text_status defined which could keep the track of the status
> of
> text being entered and save it when activity is stopped.
>
> Signed-off-by: Ishan Bansal<ishan at seeta.in>, Anubhav Aggarwal<
> anubhav at seeta.in>
> ---
>  Area.py |   11 +++++++++++
>  1 files changed, 11 insertions(+), 0 deletions(-)
>
> v1->v2: Patch updated
>
> diff --git a/Area.py b/Area.py
> index 2dca7da..a2db51b 100644
> --- a/Area.py
> +++ b/Area.py
> @@ -113,6 +113,8 @@ class Area(gtk.DrawingArea):
>         self.connect("leave_notify_event", self.mouseleave)
>         self.connect("enter_notify_event", self.mouseenter)
>
> +        self.text_status = -1
> +
>         target = [('text/uri-list', 0, TARGET_URI)]
>         self.drag_dest_set(gtk.DEST_DEFAULT_ALL, target,
>                 gtk.gdk.ACTION_COPY | gtk.gdk.ACTION_MOVE)
> @@ -303,6 +305,7 @@ class Area(gtk.DrawingArea):
>         # text
>         if self.tool['name'] == 'text':
>             self.d.text(widget,event)
> +            self.text_status = 0
>
>         # This fixes a bug that made the text viewer get stuck in the
> canvas
>         elif self.estadoTexto is 1:
> @@ -473,6 +476,10 @@ class Area(gtk.DrawingArea):
>                 self.configure_line(self.line_size)
>
> self.d.polygon(widget,coords,True,self.tool['fill'],"moving")
>
> +        if self.tool['name'] == 'text':
> +           if self.text_status == 0:
> +              self.text_status = 1
> +
>         gtk.gdk.event_request_motions (event)
>
>     def mouseup(self,widget,event):
> @@ -571,6 +578,10 @@ class Area(gtk.DrawingArea):
>             size = self.tool['line size']
>             widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size,
> size*2, size*2)
>
> +        if self.tool['name'] == 'text':
> +           if self.text_status == 1:
> +                  self.d.text(widget,event)
> +
>     def mouseenter(self, widget, event):
>         if self.tool['name'] in ['pencil','eraser','brush','rainbow']:
>             self.drawing = False
> --
> 1.7.0.4
>
> _______________________________________________
> Sugar-devel mailing list
> Sugar-devel at lists.sugarlabs.org
> http://lists.sugarlabs.org/listinfo/sugar-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20101018/d346f908/attachment.html>


More information about the Sugar-devel mailing list