Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/paintwithme.py
diff options
context:
space:
mode:
Diffstat (limited to 'paintwithme.py')
-rw-r--r--paintwithme.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/paintwithme.py b/paintwithme.py
index 6052cba..3a3f568 100644
--- a/paintwithme.py
+++ b/paintwithme.py
@@ -18,6 +18,7 @@
from gettext import gettext as _
import logging
+import json
from sugar.activity import activity
@@ -29,6 +30,7 @@ from sugar.presence.tubeconn import TubeConnection
from toolbar import PaintToolbar
from drawing import Drawing
+# FIXME use json from standard lib
from utils import json_load, json_dump
@@ -66,6 +68,26 @@ class PaintWithMeActivity(activity.Activity):
self._setup_handle = self.canvas.connect('size_allocate',
size_allocate_cb)
+ def read_file(self, file_path):
+ """Read from Sugar Journal."""
+ self._drawing.load_png(file_path)
+
+ state = json.loads(self.metadata['state'])
+ logging.debug("read_file")
+ logging.debug(state)
+ self._drawing.set_stroke_width(state['width'])
+
+ def write_file(self, file_path):
+ """Write to Sugar Journal."""
+ self.metadata['mime_type'] = 'image/png'
+ self._drawing.save_png(file_path)
+
+ state = {}
+ state['width'] = self._drawing.get_stroke_width()
+ self.metadata['state'] = json.dumps(state)
+ logging.debug("write_file")
+ logging.debug(state)
+
# Collaboration-related methods below:
def _setup_presence_service(self):