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

anubhav at seeta.in anubhav at seeta.in
Wed Oct 20 16:03:04 EDT 2010


The variable name of estadoTexto has been changed to text_status as suggested
and just before saving the file the text status is checked if 1 (representing
the text field in prgress and not yet saved) then the function text() is called
from Desenho thus saving the text

v1 -> v2. Updated at suggested

Co-authored-by: Anubhav Aggarwal<anubhav at seeta.in>, Ishan Bansal <ishan at seeta.in>
---
 Area.py            |    6 +++---
 Desenho.py         |    6 +++---
 OficinaActivity.py |    4 ++++
 3 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/Area.py b/Area.py
index 2dca7da..23be48c 100644
--- a/Area.py
+++ b/Area.py
@@ -159,7 +159,7 @@ class Area(gtk.DrawingArea):
         self.pixmap_sel = None
         self.desenho = []   
         self.textos = []
-        self.estadoTexto = 0
+        self.text_status = 0
         self.janela = janela    
         self.d = Desenho(self)
         self.line_size = 2
@@ -305,7 +305,7 @@ class Area(gtk.DrawingArea):
             self.d.text(widget,event)
             
         # This fixes a bug that made the text viewer get stuck in the canvas
-        elif self.estadoTexto is 1:
+        elif self.text_status is 1:
             try:
             # This works for a gtk.Entry
                 text = self.janela.textview.get_text()
@@ -317,7 +317,7 @@ class Area(gtk.DrawingArea):
                 
             if text is not None:
                 self.d.text(widget,event)
-            self.estadoTexto = 0
+            self.text_status = 0
             self.janela.textview.hide()
             
         self.oldx, self.oldy = coords
diff --git a/Desenho.py b/Desenho.py
index c9a134b..a52469b 100644
--- a/Desenho.py
+++ b/Desenho.py
@@ -508,8 +508,8 @@ class Desenho:
 
         """
         
-        if widget.estadoTexto == 0:
-            widget.estadoTexto = 1
+        if widget.text_status == 0:
+            widget.text_status = 1
             
             #widget.janela.fixed.move(widget.janela.textview, int(event.x)+200, int(event.y)+100)
             # Area size has changed...
@@ -518,7 +518,7 @@ class Desenho:
             widget.janela.textview.grab_focus()
             
         else:   
-            widget.estadoTexto = 0  
+            widget.text_status = 0  
             
             try:
             # This works for a gtk.Entry
diff --git a/OficinaActivity.py b/OficinaActivity.py
index 21ccc04..44f3b32 100644
--- a/OficinaActivity.py
+++ b/OficinaActivity.py
@@ -73,6 +73,7 @@ from sugar.graphics import style
 from toolbox import Toolbox
 from Area import Area
 import logging
+from Desenho import Desenho
 
 class OficinaActivity(activity.Activity):
 
@@ -166,6 +167,9 @@ class OficinaActivity(activity.Activity):
         '''Save file on Sugar Journal. '''
 
         width, height = self.area.get_size_request()
+        if self.area.text_status == 1:
+            save_text = Desenho(self.area)
+            save_text.text(self.area, event =None)     			
 
         logging.debug('writting file=%s w=%s h=%s' % (file_path, width, height))
 
-- 
1.7.0.4



More information about the Sugar-devel mailing list