Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAgustin Zubiaga <aguz@sugarlabs.org>2012-06-03 00:45:31 (GMT)
committer Agustin Zubiaga <aguz@sugarlabs.org>2012-06-03 00:45:31 (GMT)
commitca9e22818438d35b374d4078768d78c890b926a1 (patch)
treed34f21f888fe236b16b8ef57a3a5f464f2cfad9e
parent52c081f29bf4be4e943569fa55a92c200c623e4a (diff)
Save data in journal fixed
-rw-r--r--activity.py36
1 files changed, 19 insertions, 17 deletions
diff --git a/activity.py b/activity.py
index b41a137..e679417 100644
--- a/activity.py
+++ b/activity.py
@@ -41,6 +41,8 @@ from sugar.graphics.radiotoolbutton import RadioToolButton
from sugar import mime
from gettext import gettext as _
+from StringIO import StringIO
+
import animation
from frames_list import FramesList
@@ -174,32 +176,29 @@ class AnimateActivity(activity.Activity):
def write_file(self, file_path):
zfile = zipfile.ZipFile(file_path, 'w')
- jfile_path = tempfile.mktemp()
- jfile = open(jfile_path, "w")
- jfile_content = {"mode": self._animation.get_mode()}
+ temp_file_path = tempfile.mktemp()
+ temp_file = open(temp_file_path, "w")
+ temp_file_content = {"mode": self._animation.get_mode()}
try:
- json.dump(jfile_content, jfile)
+ json.dump(temp_file_content, temp_file)
finally:
- jfile.close()
- zfile.write(jfile_path, 'config')
+ temp_file.close()
+ zfile.write(temp_file_path, 'config')
zfile.close()
- os.remove(file_path)
+
+ os.remove(temp_file_path)
def read_file(self, file_path):
zfile = zipfile.ZipFile(file_path, 'r')
- jfile_text = zfile.read('config')
- jfile_path = tempfile.mktemp()
- jfile = open(jfile_path, 'w')
- jfile.write(jfile_text)
- jfile.close()
+ str_io = StringIO(zfile.read('config'))
zfile.close()
- jfile = open(jfile_path, 'r')
+
try:
- jfile_content = json.load(jfile)
+ options = json.load(str_io)
finally:
- jfile.close()
- mode = jfile_content['mode']
- self.animation.set_mode(mode)
+ str_io.close()
+ mode = options['mode']
+ self._animation_mode = mode
self.modes_buttons[mode].set_active(True)
def _remove_frame(self, widget):
@@ -262,8 +261,11 @@ class AnimateActivity(activity.Activity):
if not self._animation:
self._animation = animation.Animation(width, height)
+ self._animation.set_mode(self._animation_mode)
self._animation.show_all()
+ del self._animation_mode
+
self._frames_list._animation = self._animation
canvas.pack_start(self._animation, True, True, 0)