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

Ishan Bansal ishan at seeta.in
Sat Oct 16 09:12:25 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(-)

diff --git a/Area.py b/Area.py
index 2dca7da..012b640 100644
--- a/Area.py
+++ b/Area.py
@@ -112,6 +112,8 @@ class Area(gtk.DrawingArea):
         self.connect("key_press_event", self.key_press)
         self.connect("leave_notify_event", self.mouseleave)
         self.connect("enter_notify_event", self.mouseenter)
+        
+        self.textstatus = -1
 
         target = [('text/uri-list', 0, TARGET_URI)]
         self.drag_dest_set(gtk.DEST_DEFAULT_ALL, target,
@@ -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