Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPootle daemon <pootle@pootle.sugarlabs.org>2013-11-02 04:30:36 (GMT)
committer Pootle daemon <pootle@pootle.sugarlabs.org>2013-11-02 04:30:36 (GMT)
commit4af89d1f979f2ca90f964746c92d40e38645a259 (patch)
tree17637808a0834cf547e130362f089f1a2b9d4709
parent73c135cad42a21de2b102278cd4c101c42876527 (diff)
parent1de9124a7af7802db43e86891d99b5eaed564c19 (diff)
Merge branch 'master' of git.sugarlabs.org:turtleart/mainline
-rw-r--r--TurtleArt/taexportpython.py9
-rw-r--r--TurtleArt/taprimitive.py4
-rw-r--r--TurtleArt/tawindow.py22
-rw-r--r--TurtleArtActivity.py5
-rw-r--r--plugins/turtle_blocks_extras/turtle_blocks_extras.py26
-rw-r--r--samples/game-snake.tb75
-rw-r--r--samples/media-music-keyboard.tb7
-rwxr-xr-xturtleblocks.py5
8 files changed, 85 insertions, 68 deletions
diff --git a/TurtleArt/taexportpython.py b/TurtleArt/taexportpython.py
index 49bde06..458b886 100644
--- a/TurtleArt/taexportpython.py
+++ b/TurtleArt/taexportpython.py
@@ -33,7 +33,7 @@ from talogo import LogoCode
from taprimitive import (ast_yield_true, Primitive, PyExportError,
value_to_ast)
from tautils import (debug_output, find_group, find_top_block, get_stack_name)
-from tawindow import global_objects
+from tawindow import (global_objects, plugins_in_use)
_SETUP_CODE_START = """\
@@ -128,11 +128,8 @@ def _action_stack_to_python(block, tw, name="start"):
name_id = _make_identifier(name)
if name == 'start':
pre_preamble = _START_STACK_START_ADD
- # TODO: only add the objects we are using
- for k in global_objects.keys():
- if k not in ['window', 'canvas', 'logo', 'turtles']:
- pre_preamble += " %s = global_objects['%s']\n" % (
- k.lower(), k)
+ for k in plugins_in_use:
+ pre_preamble += " %s = global_objects['%s']\n" % (k.lower(), k)
else:
pre_preamble = ''
generated_code = _indent(generated_code, 1)
diff --git a/TurtleArt/taprimitive.py b/TurtleArt/taprimitive.py
index 3f922b4..7ffc2ef 100644
--- a/TurtleArt/taprimitive.py
+++ b/TurtleArt/taprimitive.py
@@ -33,7 +33,7 @@ from talogo import (LogoCode, logoerror, NegativeRootError)
from taturtle import (Turtle, Turtles)
from tatype import *
from tautils import debug_output
-from tawindow import TurtleArtWindow, global_objects
+from tawindow import (TurtleArtWindow, global_objects, plugins_in_use)
from util import ast_extensions
@@ -143,6 +143,8 @@ class Primitive(object):
if results:
for k in global_objects.keys():
if k == plugin:
+ if k not in plugins_in_use:
+ plugins_in_use.append(k)
func_name = k.lower() + '.'
break
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 448dbf3..6d9ca0a 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -82,6 +82,7 @@ from tautils import (magnitude, get_load_name, get_save_name, data_from_file,
restore_clamp, collapse_clamp, data_from_string,
increment_name, get_screen_dpi)
from tasprite_factory import (SVG, svg_str_to_pixbuf, svg_from_file)
+from tapalette import block_primitives
from sprites import (Sprites, Sprite)
if _GST_AVAILABLE:
@@ -98,6 +99,7 @@ _MACROS_SUBPATH = 'macros'
# the global instances of single-instance classes
global_objects = {}
+plugins_in_use = []
class TurtleArtWindow():
@@ -319,6 +321,12 @@ class TurtleArtWindow():
def get_global_objects(self):
return global_objects
+ def get_init_complete(self):
+ if self.running_turtleart:
+ return self.activity.init_complete
+ else:
+ return True
+
def _lazy_init(self):
self._init_plugins()
self._setup_plugins()
@@ -338,8 +346,8 @@ class TurtleArtWindow():
regenerate=True,
show=True)
- if self.running_sugar:
- self.activity.check_buttons_for_fit()
+ if self.running_sugar:
+ self.activity.check_buttons_for_fit()
def _set_screen_dpi(self):
dpi = get_screen_dpi()
@@ -1507,10 +1515,12 @@ class TurtleArtWindow():
return int((self.canvas.height / 2) - self.mouse_y)
def button_press(self, mask, x, y):
- if self.running_sugar:
- self._show_unfullscreen_button()
+ if self.running_turtleart:
+ if self.running_sugar:
+ self._show_unfullscreen_button()
- self.activity.hide_store()
+ if self.interactive_mode:
+ self.activity.hide_store()
# Find out what was clicked
spr = self.sprite_list.find_sprite((x, y))
@@ -1520,7 +1530,7 @@ class TurtleArtWindow():
blk = self.block_list.spr_to_block(spr)
if blk is not None:
# Make sure stop button is visible
- if self.running_sugar:
+ if self.running_sugar and self.running_turtleart:
self.activity.stop_turtle_button.set_icon("stopiton")
self.activity.stop_turtle_button.set_tooltip(
_('Stop turtle'))
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index c413358..db2eec8 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -1751,6 +1751,10 @@ in order to use the plugin.'))
self._selected_sample = image_path
self._sample_window.hide()
+ self.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ gobject.idle_add(self._sample_loader)
+
+ def _sample_loader(self):
# Convert from thumbnail path to sample path
basename = os.path.basename(self._selected_sample)[:-4]
for suffix in ['.ta', '.tb']:
@@ -1761,6 +1765,7 @@ in order to use the plugin.'))
break
self.tw.load_save_folder = os.path.join(activity.get_bundle_path(),
'samples')
+ self.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
def _fill_samples_list(self, store):
'''
diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
index c900a3c..9bf4cbb 100644
--- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py
+++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py
@@ -237,7 +237,6 @@ Journal'))
call_afterwards=lambda value: self.after_set(
'scale', value)))
- primitive_dictionary['savepix'] = self._prim_save_picture
palette.add_block('savepix',
style='basic-style-1arg',
label=_('save picture'),
@@ -246,9 +245,9 @@ Journal'))
help_string=_('saves a picture to the Sugar \
Journal'))
self.tw.lc.def_prim('savepix', 1,
- lambda self, x: primitive_dictionary['savepix'](x))
+ Primitive(self.tw.save_as_image,
+ arg_descs=[ArgSlot(TYPE_STRING)]))
- primitive_dictionary['savesvg'] = self._prim_save_svg
palette.add_block('savesvg',
style='basic-style-1arg',
label=_('save SVG'),
@@ -257,7 +256,9 @@ Journal'))
help_string=_('saves turtle graphics as an SVG file \
in the Sugar Journal'))
self.tw.lc.def_prim('savesvg', 1,
- lambda self, x: primitive_dictionary['savesvg'](x))
+ Primitive(self.tw.save_as_image,
+ arg_descs=[ArgSlot(TYPE_STRING)],
+ kwarg_descs={'svg': ConstantArg(True)}))
palette.add_block('scale',
style='box-style',
@@ -309,7 +310,6 @@ complete'))
Primitive(self.prim_speak,
arg_descs=[ArgSlot(TYPE_STRING)]))
- primitive_dictionary['sinewave'] = self._prim_sinewave
palette.add_block('sinewave',
style='basic-style-3arg',
# TRANS: pitch, duration, amplitude
@@ -320,8 +320,10 @@ complete'))
help_string=_('plays a sinewave at frequency, \
amplitude, and duration (in seconds)'))
self.tw.lc.def_prim('sinewave', 3,
- lambda self, x, y, z:
- primitive_dictionary['sinewave'](x, y, z))
+ Primitive(self.prim_sinewave,
+ arg_descs=[ArgSlot(TYPE_NUMBER),
+ ArgSlot(TYPE_NUMBER),
+ ArgSlot(TYPE_NUMBER)]))
def _sensor_palette(self):
debug_output('creating %s palette' % _('sensor'),
@@ -1148,14 +1150,6 @@ Journal objects'))
else:
self.tw.lc.update_label_value('pop', self.tw.lc.heap[-1])
- def _prim_save_picture(self, name):
- """ Save canvas to file as PNG """
- self.tw.save_as_image(name)
-
- def _prim_save_svg(self, name):
- """ Save SVG to file """
- self.tw.save_as_image(name, svg=True)
-
def prim_speak(self, text):
""" Speak text """
if type(text) == float and int(text) == text:
@@ -1176,7 +1170,7 @@ Journal objects'))
language_option, text]))
self.tw.send_event(event)
- def _prim_sinewave(self, pitch, amplitude, duration):
+ def prim_sinewave(self, pitch, amplitude, duration):
""" Create a Csound score to play a sine wave. """
self.orchlines = []
self.scorelines = []
diff --git a/samples/game-snake.tb b/samples/game-snake.tb
index 95be7b7..4e8215c 100644
--- a/samples/game-snake.tb
+++ b/samples/game-snake.tb
@@ -1,57 +1,60 @@
[[0, ["start", 2.0], 200, 180, [null, 56]],
[1, "hat", 740, 420, [null, 2, 13]],
-[2, ["string", "left"], 799, 432, [1, null]],
+[2, ["string", "left"], 798, 432, [1, null]],
[3, "hat", 740, 180, [null, 4, 12]],
-[4, ["string", "right"], 799, 192, [3, null]],
+[4, ["string", "right"], 798, 192, [3, null]],
[5, "stack", 520, 276, [11, 6, 7]],
-[6, ["string", "left"], 579, 276, [5, null]],
+[6, ["string", "left"], 578, 276, [5, null]],
[7, "stack", 520, 318, [5, 8, 9]],
-[8, ["string", "right"], 579, 318, [7, null]],
+[8, ["string", "right"], 578, 318, [7, null]],
[9, "forward", 520, 360, [7, 10, 51]],
-[10, ["number", 10], 594, 360, [9, null]],
+[10, ["number", 10], 591, 360, [9, null]],
[11, "kbinput", 520, 234, [33, 5]],
[12, ["vspace", 0], 740, 234, [3, 14]],
[13, ["vspace", 0], 740, 474, [1, 15]],
[14, ["if", 0], 740, 276, [12, 16, 20, null]],
[15, ["if", 0], 740, 516, [13, 17, 22, null]],
-[16, ["equal2", 0], 806, 242, [14, 45, 18, null]],
-[17, ["equal2", 0], 806, 482, [15, 46, 19, null]],
-[18, "keyboard", 862, 284, [16, null]],
-[19, "keyboard", 862, 524, [17, null]],
+[16, ["equal2", 0], 796, 242, [14, 45, 18, null]],
+[17, ["equal2", 0], 796, 482, [15, 46, 19, null]],
+[18, "keyboard", 852, 284, [16, null]],
+[19, "keyboard", 852, 524, [17, null]],
[20, "right", 758, 342, [14, 21, null]],
-[21, ["number", 10], 830, 342, [20, null]],
+[21, ["number", 10], 816, 342, [20, null]],
[22, "left", 758, 582, [15, 23, null]],
-[23, ["number", 10], 837, 582, [22, null]],
-[24, "wait", 218, 502, [35, 25, null]],
-[25, ["number", 0.1], 287, 502, [24, null]],
+[23, ["number", 10], 816, 582, [22, null]],
+[24, "wait", 218, 586, [35, 25, null]],
+[25, ["number", 0.1], 276, 586, [24, null]],
[26, "forward", 1020, 276, [30, 27, 39]],
-[27, ["number", 3], 1094, 276, [26, null]],
+[27, ["number", 5.0], 1091, 276, [26, null]],
[28, "back", 1020, 402, [39, 29, 31]],
-[29, ["number", 3], 1078, 402, [28, null]],
+[29, ["number", 5.0], 1078, 402, [28, null]],
[30, "penup", 1020, 234, [49, 26]],
[31, "pendown", 1020, 444, [28, null]],
-[32, "showblocks", 200, 562, [47, null]],
+[32, "showblocks", 200, 646, [47, null]],
[33, "hat", 520, 180, [null, 34, 11]],
-[34, ["string", "action"], 579, 192, [33, null]],
-[35, "stack", 218, 460, [47, 36, 24]],
-[36, ["string", "action"], 277, 460, [35, null]],
-[37, "setpensize", 200, 268, [56, 38, 54]],
-[38, ["number", 5], 301, 268, [37, null]],
+[34, ["string", "action"], 578, 192, [33, null]],
+[35, "stack", 218, 544, [47, 36, 24]],
+[36, ["string", "action"], 276, 544, [35, null]],
+[37, "setpensize", 200, 352, [57, 38, 54]],
+[38, ["number", 8.0], 302, 352, [37, null]],
[39, ["storein", 0], 1020, 318, [26, 40, 41, 28]],
-[40, ["string", "color"], 1115, 318, [39, null]],
-[41, "see", 1115, 360, [39, null]],
-[42, ["equal2", 0], 256, 360, [47, 43, 53, null]],
-[43, "box", 312, 360, [42, 44, null]],
-[44, ["string", "color"], 367, 360, [43, null]],
-[45, ["number", 3], 862, 242, [16, null]],
-[46, ["number", 1], 862, 482, [17, null]],
-[47, ["until", 21], 200, 394, [48, 42, 35, 32]],
-[48, ["vspace", 0], 200, 352, [54, 47]],
+[40, ["string", "color"], 1088, 318, [39, null]],
+[41, "see", 1088, 360, [39, null]],
+[42, ["equal2", 0], 256, 444, [47, 43, 53, null]],
+[43, "box", 312, 444, [42, 44, null]],
+[44, ["string", "color"], 367, 444, [43, null]],
+[45, ["number", 3], 852, 242, [16, null]],
+[46, ["number", 1], 852, 482, [17, null]],
+[47, ["until", 21], 200, 478, [48, 42, 35, 32]],
+[48, ["vspace", 0], 200, 436, [54, 47]],
[49, "hat", 1020, 180, [null, 50, 30]],
-[50, ["string", "look ahead"], 1079, 192, [49, null]],
+[50, ["string", "look ahead"], 1078, 192, [49, null]],
[51, "stack", 520, 402, [9, 52, null]],
-[52, ["string", "look ahead"], 579, 402, [51, null]],
-[53, "red", 312, 402, [42, null]],
-[54, "setcolor", 200, 310, [37, 55, 48]],
-[55, "red", 281, 310, [54, null]],
-[56, "clean", 200, 226, [0, 37]]]
+[52, ["string", "look ahead"], 578, 402, [51, null]],
+[53, "red", 312, 486, [42, null]],
+[54, "setcolor", 200, 394, [37, 55, 48]],
+[55, "red", 277, 394, [54, null]],
+[56, "clean", 200, 226, [0, 57]],
+[57, ["storein", 0], 200, 268, [56, 58, 59, 37]],
+[58, ["string", "color"], 268, 268, [57, null]],
+[59, "blue", 268, 310, [57, null]]]
diff --git a/samples/media-music-keyboard.tb b/samples/media-music-keyboard.tb
index a525d33..6ac5eae 100644
--- a/samples/media-music-keyboard.tb
+++ b/samples/media-music-keyboard.tb
@@ -1,4 +1,4 @@
-[[0, ["start", 2.0], 160, 200, [null, 110]],
+[[0, ["start", 2.0], 160, 200, [null, 130]],
[1, ["until", 63], 600, 254, [38, 22, 25, 28]],
[2, ["forever", 230], 160, 330, [112, 40, null]],
[3, "sinewave", 178, 698, [20, 36, 10, 4, 11]],
@@ -108,7 +108,7 @@
[107, "ycor", 929, 1565, [101, null]],
[108, "hat", 1096, 195, [null, 109, 114]],
[109, ["string", "select notes"], 1154, 207, [108, null]],
-[110, "stack", 160, 246, [0, 111, 112]],
+[110, "stack", 160, 246, [130, 111, 112]],
[111, ["string", "select notes"], 218, 246, [110, null]],
[112, "stack", 160, 288, [110, 113, 2]],
[113, ["string", "draw keyboard"], 218, 288, [112, null]],
@@ -127,4 +127,5 @@
[126, "push", 1096, 501, [124, 127, 128]],
[127, ["number", 26.0], 1154, 501, [126, null]],
[128, "push", 1096, 543, [126, 129, null]],
-[129, ["number", 24], 1154, 543, [128, null]]]
+[129, ["number", 24], 1154, 543, [128, null]],
+[130, "clean", 853, 1149, [0, 110]]] \ No newline at end of file
diff --git a/turtleblocks.py b/turtleblocks.py
index 55a02dc..df25eea 100755
--- a/turtleblocks.py
+++ b/turtleblocks.py
@@ -879,6 +879,10 @@ Would you like to save before quitting?'))
self._selected_sample = image_path
self._sample_window.hide()
+ self.win.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.WATCH))
+ gobject.idle_add(self._sample_loader)
+
+ def _sample_loader(self):
# Convert from thumbnail path to sample path
basename = os.path.basename(self._selected_sample)[:-4]
for suffix in ['.ta', '.tb']:
@@ -889,6 +893,7 @@ Would you like to save before quitting?'))
break
self.tw.load_save_folder = os.path.join(self._get_execution_dir(),
'samples')
+ self.win.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
def _fill_samples_list(self, store):
'''