Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArtActivity.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2010-10-11 15:42:07 (GMT)
committer Walter Bender <walter@sugarlabs.org>2010-10-11 15:42:07 (GMT)
commit8fcccae06415542040431d046dbd2bced51e65f5 (patch)
tree61e434b4e46e31c9b4b5564fa7055a30d15ca91e /TurtleArtActivity.py
parent24e80496c68b5712f1404bc7a1abc792b1abd432 (diff)
more consolidation of chooser code
Diffstat (limited to 'TurtleArtActivity.py')
-rw-r--r--TurtleArtActivity.py40
1 files changed, 9 insertions, 31 deletions
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index 8ce1fbc..940d548 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -54,7 +54,7 @@ from TurtleArt.taconstants import PALETTE_NAMES, OVERLAY_LAYER, HELP_STRINGS
from TurtleArt.taexporthtml import save_html
from TurtleArt.taexportlogo import save_logo
from TurtleArt.tautils import data_to_file, data_to_string, data_from_string, \
- get_path
+ get_path, chooser
from TurtleArt.tawindow import TurtleArtWindow
from TurtleArt.taturtle import Turtle
@@ -219,46 +219,25 @@ class TurtleArtActivity(activity.Activity):
def do_load_ta_project_cb(self, button):
""" Load a project from the Journal """
- from sugar.graphics.objectchooser import ObjectChooser
- chooser = ObjectChooser(parent=self,
- what_filter='org.laptop.TurtleArtActivity')
+ chooser(self, SERVICE, self._load_ta_project)
+ def _load_ta_project(self, dsobject):
+ """ Load a ta project from the datastore """
try:
- result = chooser.run()
- if result == gtk.RESPONSE_ACCEPT:
- dsobject = chooser.get_selected_object()
- try:
- _logger.debug("opening %s " % dsobject.file_path)
- self.read_file(dsobject.file_path, False)
- except:
- _logger.debug("couldn't open %s" % dsobject.file_path)
- dsobject.destroy()
- finally:
- chooser.destroy()
- del chooser
- return
+ _logger.debug("opening %s " % dsobject.file_path)
+ self.read_file(dsobject.file_path, False)
+ except:
+ _logger.debug("couldn't open %s" % dsobject.file_path)
def do_load_python_cb(self, button):
""" Load Python code from the Journal. """
self.load_python.set_icon("pippy-openon")
self.import_py()
gobject.timeout_add(250, self.load_python.set_icon, "pippy-openoff")
- return
def import_py(self):
""" Import Python code from the Journal to load into 'myblock'. """
- from sugar.graphics.objectchooser import ObjectChooser
- chooser = ObjectChooser(parent=self,
- what_filter='org.laptop.Pippy')
-
- try:
- result = chooser.run()
- if result == gtk.RESPONSE_ACCEPT:
- dsobject = chooser.get_selected_object()
- self._load_python(dsobject)
- finally:
- chooser.destroy()
- del chooser
+ chooser(self, 'org.laptop.Pippy', self._load_python)
def _load_python(self, dsobject):
""" Read the Python code from the Journal object """
@@ -272,7 +251,6 @@ class TurtleArtActivity(activity.Activity):
self.metadata['python code'] = dsobject.object_id
except:
_logger.debug("couldn't open %s" % dsobject.file_path)
- dsobject.destroy()
def do_save_as_image_cb(self, button):
""" Save the canvas to the Journal. """