There are two simple changes you must do:<br><br>* replace the values 1 and 0 for constants like James said.<br>* In OficinaActivity, you can use self.area.d to use the object Desenho.<br>Also you must check for trailing white spaces and get the last sources from git before create the new patch.<br>
<br>Gonzalo<br><br><div class="gmail_quote">On Wed, Oct 20, 2010 at 5:03 PM, <span dir="ltr"><<a href="mailto:anubhav@seeta.in">anubhav@seeta.in</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
The variable name of estadoTexto has been changed to text_status as suggested<br>
and just before saving the file the text status is checked if 1 (representing<br>
the text field in prgress and not yet saved) then the function text() is called<br>
from Desenho thus saving the text<br>
<br>
v1 -> v2. Updated at suggested<br>
<br>
Co-authored-by: Anubhav Aggarwal<<a href="mailto:anubhav@seeta.in">anubhav@seeta.in</a>>, Ishan Bansal <<a href="mailto:ishan@seeta.in">ishan@seeta.in</a>><br>
---<br>
Area.py | 6 +++---<br>
Desenho.py | 6 +++---<br>
OficinaActivity.py | 4 ++++<br>
3 files changed, 10 insertions(+), 6 deletions(-)<br>
<div class="im"><br>
diff --git a/Area.py b/Area.py<br>
</div>index 2dca7da..23be48c 100644<br>
<div class="im">--- a/Area.py<br>
+++ b/Area.py<br>
</div>@@ -159,7 +159,7 @@ class Area(gtk.DrawingArea):<br>
self.pixmap_sel = None<br>
self.desenho = []<br>
self.textos = []<br>
- self.estadoTexto = 0<br>
+ self.text_status = 0<br>
self.janela = janela<br>
self.d = Desenho(self)<br>
self.line_size = 2<br>
@@ -305,7 +305,7 @@ class Area(gtk.DrawingArea):<br>
<div class="im"> self.d.text(widget,event)<br>
<br>
</div><div class="im"> # This fixes a bug that made the text viewer get stuck in the canvas<br>
- elif self.estadoTexto is 1:<br>
</div>+ elif self.text_status is 1:<br>
try:<br>
# This works for a gtk.Entry<br>
text = self.janela.textview.get_text()<br>
@@ -317,7 +317,7 @@ class Area(gtk.DrawingArea):<br>
<br>
if text is not None:<br>
<div class="im"> self.d.text(widget,event)<br>
</div>- self.estadoTexto = 0<br>
+ self.text_status = 0<br>
self.janela.textview.hide()<br>
<br>
self.oldx, self.oldy = coords<br>
diff --git a/Desenho.py b/Desenho.py<br>
index c9a134b..a52469b 100644<br>
--- a/Desenho.py<br>
+++ b/Desenho.py<br>
@@ -508,8 +508,8 @@ class Desenho:<br>
<br>
"""<br>
<br>
- if widget.estadoTexto == 0:<br>
- widget.estadoTexto = 1<br>
+ if widget.text_status == 0:<br>
+ widget.text_status = 1<br>
<br>
#widget.janela.fixed.move(widget.janela.textview, int(event.x)+200, int(event.y)+100)<br>
# Area size has changed...<br>
@@ -518,7 +518,7 @@ class Desenho:<br>
widget.janela.textview.grab_focus()<br>
<br>
else:<br>
- widget.estadoTexto = 0<br>
+ widget.text_status = 0<br>
<br>
try:<br>
# This works for a gtk.Entry<br>
diff --git a/OficinaActivity.py b/OficinaActivity.py<br>
index 21ccc04..44f3b32 100644<br>
--- a/OficinaActivity.py<br>
+++ b/OficinaActivity.py<br>
@@ -73,6 +73,7 @@ from sugar.graphics import style<br>
from toolbox import Toolbox<br>
from Area import Area<br>
import logging<br>
+from Desenho import Desenho<br>
<br>
class OficinaActivity(activity.Activity):<br>
<br>
@@ -166,6 +167,9 @@ class OficinaActivity(activity.Activity):<br>
'''Save file on Sugar Journal. '''<br>
<br>
width, height = self.area.get_size_request()<br>
+ if self.area.text_status == 1:<br>
+ save_text = Desenho(self.area)<br>
+ save_text.text(self.area, event =None)<br>
<br>
logging.debug('writting file=%s w=%s h=%s' % (file_path, width, height))<br>
<font color="#888888"><br>
--<br>
1.7.0.4<br>
<br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Gonzalo Odiard<br><br><br>