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

Ishan Bansal ishan at seeta.in
Sun Oct 17 04:47:17 EDT 2010


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



More information about the Sugar-devel mailing list