Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2013-05-09 21:34:25 (GMT)
committer Walter Bender <walter@sugarlabs.org>2013-05-09 21:34:25 (GMT)
commit2467422171c71ce916a13d2dc9a0d7c7418b234f (patch)
treee17d78c555879891a7cd045b1438c1c7ce0e3caf
parent6553d941df5aa537afbbeb39fd6f55bfef61abd7 (diff)
Add ability to remove macros
-rw-r--r--TurtleArt/tawindow.py92
-rw-r--r--TurtleArtActivity.py20
-rw-r--r--icons/delete-blocks.svg78
-rw-r--r--icons/myblocksoff.svg69
-rw-r--r--icons/myblockson.svg70
-rw-r--r--icons/save-blocks.svg78
-rwxr-xr-xturtleblocks.py16
7 files changed, 415 insertions, 8 deletions
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 109149b..8de5e2e 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -48,6 +48,8 @@ DEGTOR = 2 * pi / 360
import locale
+import logging
+
from taconstants import (HORIZONTAL_PALETTE, VERTICAL_PALETTE, BLOCK_SCALE,
MEDIA_SHAPES, STATUS_SHAPES, OVERLAY_SHAPES, TOOLBAR_SHAPES, TAB_LAYER,
RETURN, OVERLAY_LAYER, CATEGORY_LAYER, BLOCKS_WITH_SKIN, ICON_SIZE,
@@ -112,7 +114,9 @@ class TurtleArtWindow():
if running_sugar:
self.parent.show_all()
self.running_sugar = True
+
from sugar import profile
+
self.nick = profile.get_nick_name()
self.macros_path = os.path.join(
get_path(parent, 'data'), self._MACROS_SUBPATH)
@@ -155,6 +159,7 @@ class TurtleArtWindow():
self.saving_blocks = False
self.copying_blocks = False
self.sharing_blocks = False
+ self.deleting_blocks = False
try:
locale.setlocale(locale.LC_NUMERIC, '')
@@ -1383,6 +1388,11 @@ before making changes to your Turtle Blocks program'))
self.copying_blocks = False
self.sharing_blocks = False
self.saving_blocks = False
+ elif self.deleting_blocks:
+ if blk is None or blk.type != 'proto':
+ self.parent.get_window().set_cursor(
+ gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
+ self.deleting_blocks = False
if blk is not None:
if blk.type == 'block':
self.selected_blk = blk
@@ -1390,7 +1400,14 @@ before making changes to your Turtle Blocks program'))
elif blk.type == 'trash':
self._restore_from_trash(find_top_block(blk))
elif blk.type == 'proto':
- if blk.name == 'restoreall':
+ if self.deleting_blocks:
+ if self.selected_palette == \
+ palette_names.index('myblocks'):
+ self._delete_stack_alert(blk)
+ self.parent.get_window().set_cursor(
+ gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
+ self.deleting_blocks = False
+ elif blk.name == 'restoreall':
self._restore_all_from_trash()
elif blk.name == 'restore':
self.restore_latest_from_trash()
@@ -1503,6 +1520,62 @@ before making changes to your Turtle Blocks program'))
return True
return False
+ def _delete_stack_alert(self, blk):
+ if self.running_sugar:
+ from sugar.graphics.alert import Alert
+ from sugar.graphics.icon import Icon
+
+ alert = Alert()
+ alert.props.title = _('Delete stack')
+ alert.props.msg = _('Really delete stack?')
+
+ cancel_icon = Icon(icon_name='dialog-cancel')
+ alert.add_button(gtk.RESPONSE_CANCEL, _('Cancel'),
+ cancel_icon)
+ stop_icon = Icon(icon_name='dialog-ok')
+ alert.add_button(gtk.RESPONSE_OK,
+ '%s %s' % (_('Delete stack'), blk.spr.labels[0]),
+ stop_icon)
+
+ self.activity.add_alert(alert)
+ alert.connect('response', self._delete_stack_dialog_response_cb,
+ blk)
+ else:
+ msg = _('Really delete stack?')
+ dialog = gtk.MessageDialog(self.parent, 0, gtk.MESSAGE_WARNING,
+ gtk.BUTTONS_OK_CANCEL, msg)
+ dialog.set_title('%s %s' % (_('Delete stack'), blk.spr.labels[0]))
+ answer = dialog.run()
+ dialog.destroy()
+ if answer == gtk.RESPONSE_OK:
+ self._delete_stack(blk)
+
+ def _delete_stack_dialog_response_cb(self, alert, response_id, blk):
+ self.activity.remove_alert(alert)
+ if response_id == gtk.RESPONSE_OK:
+ self._delete_stack(blk)
+
+ def _delete_stack(self, blk):
+ name = blk.spr.labels[0]
+ error_output('deleting proto: clicked on %s %s' % (blk.name, name),
+ self.running_sugar)
+ macro_path = os.path.join(self.macros_path, '%s.tb' % (name))
+ if os.path.exists(macro_path):
+ try:
+ os.remove(macro_path)
+ except Exception, e:
+ error_debug('Could not remove macro %s: %s' % (
+ macro_path, e))
+ return
+ i = palette_names.index('myblocks')
+ palette_blocks[i].remove(blk.name)
+ for pblk in self.palettes[i]:
+ if pblk.name == blk.name:
+ pblk.spr.hide()
+ self.palettes[i].remove(pblk)
+ break
+ self.show_toolbar_palette(i, regenerate=True)
+
def _look_for_a_turtle(self, spr, x, y):
# Next, look for a turtle
t = self.turtles.spr_to_turtle(spr)
@@ -1891,11 +1964,14 @@ before making changes to your Turtle Blocks program'))
debug_output('Serialize blocks and save.',
self.running_sugar)
i = find_hat(data)
- if i is not None and data[i][4][1] is not None:
+ if i is not None:
+ name = ''
try:
name = str(data[data[i][4][1]][1][1])
except:
- name = 'macro%d' % (int(uniform(0, 10000)))
+ pass
+ if name == '':
+ name = 'stack_%d' % (int(uniform(0, 10000)))
debug_output('saving macro %s' % (name),
self.running_sugar)
if not os.path.exists(self.macros_path):
@@ -1906,8 +1982,12 @@ before making changes to your Turtle Blocks program'))
pass
else:
raise
- data_to_file(data, os.path.join(self.macros_path,
- '%s.tb' % (name)))
+ macro_path = os.path.join(
+ self.macros_path, '%s.tb' % (name))
+ # Make sure name is unique
+ while os.path.exists(macro_path):
+ macro_path = increment_name(macro_path)
+ data_to_file(data, macro_path)
elif self.copying_blocks:
clipboard = gtk.Clipboard()
debug_output('Serialize blocks and copy to clipboard',
@@ -2415,7 +2495,7 @@ before making changes to your Turtle Blocks program'))
if block_name in special_names:
special_block_name = special_names[block_name]
elif block_name in block_names:
- special_block_name = block_names[block_name][0]
+ special_block_name = str(block_names[block_name][0])
elif block_name in TOOLBAR_SHAPES:
special_block_name = ''
else:
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index 2867cb8..c26b2b0 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -621,8 +621,11 @@ class TurtleArtActivity(activity.Activity):
edit_toolbar, '<Ctrl>v')
self._add_button('edit-undo', _('Restore blocks from trash'),
self._undo_cb, edit_toolbar)
- self._add_button('save-macro', _('Save stack'), self._save_macro_cb,
+ self._add_separator(edit_toolbar)
+ self._add_button('save-blocks', _('Save stack'), self._save_macro_cb,
edit_toolbar)
+ self._add_button('delete-blocks', _('Delete stack'),
+ self._delete_macro_cb, edit_toolbar)
self._add_button('view-fullscreen', _('Fullscreen'),
self.do_fullscreen_cb, self._view_toolbar,
@@ -1347,6 +1350,7 @@ in order to use the plugin.'))
self.tw.copying_blocks = False
self.tw.sharing_blocks = False
self.tw.saving_blocks = False
+ self.tw.deleting_blocks = False
if hasattr(self, 'get_window'):
if hasattr(self.get_window(), 'get_cursor'):
self.get_window().set_cursor(self._old_cursor)
@@ -1366,7 +1370,7 @@ in order to use the plugin.'))
self.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
def _save_macro_cb(self, button):
- ''' Save stack macros_path '''
+ ''' Save stack to macros_path '''
if self.tw.saving_blocks:
self.tw.saving_blocks = False
self.restore_cursor()
@@ -1377,6 +1381,18 @@ in order to use the plugin.'))
self._old_cursor = self.get_window().get_cursor()
self.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
+ def _delete_macro_cb(self, button):
+ ''' Delete stack from macros_path '''
+ if self.tw.deleting_blocks:
+ self.tw.deleting_blocks = False
+ self.restore_cursor()
+ else:
+ self.tw.deleting_blocks = True
+ if hasattr(self, 'get_window'):
+ if hasattr(self.get_window(), 'get_cursor'):
+ self._old_cursor = self.get_window().get_cursor()
+ self.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
+
def _paste_cb(self, button):
''' Paste from the clipboard. '''
if self.tw.copying_blocks:
diff --git a/icons/delete-blocks.svg b/icons/delete-blocks.svg
new file mode 100644
index 0000000..992bb8d
--- /dev/null
+++ b/icons/delete-blocks.svg
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ version="1.1"
+ width="55"
+ height="55"
+ viewBox="0 0 55 55"
+ id="svg2"
+ xml:space="preserve"><metadata
+ id="metadata25"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs33" /><g
+ transform="matrix(1,0,0,-1,-30.386573,49.171266)"
+ id="g4770"><g
+ transform="translate(34.0803,-1006.42)"
+ id="g4772"><polyline
+ transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)"
+ style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round"
+ points="51.562,15.306 41.17,16.188 42.053,5.794"
+ id="polyline4774" /><path
+ d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067"
+ id="path4776"
+ style="fill:none;stroke:#ffffff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g><g
+ transform="matrix(0.80095119,0,0,0.80095119,-4.6564792,-5.9184549)"
+ id="g3789"><path
+ d="m 15.719636,31.331478 0.114372,5.261133 11.437247,6.290486 L 27.5,29.387146"
+ id="path2463"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 27.728744,29.501519 0.05719,13.381578 11.723178,-7.548583 0,-4.689272 -5.947368,3.545548"
+ id="path2465"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 10.001012,27.328441 5.604251,-5.146761 -5.832996,-2.973684 12.123482,-7.091093 5.718623,3.316801 5.489879,-3.088056 12.123482,7.319838 -5.832996,2.401822 5.489878,5.032388 -11.322874,7.205466 -5.947369,-5.261134 -6.290485,5.261134 -11.322875,-6.976721 z"
+ id="path2459"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="M 16.40587,21.952935 27.156883,15.204959 38.937247,22.067308 27.614372,28.815283 16.40587,21.952935 z"
+ id="path2461"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g><g
+ transform="matrix(0.72581188,0,0,0.72581188,41.648526,6.5008956)"
+ id="g3151"><path
+ d="m 12.414428,59.423099 a 11.011069,3.4902595 0 1 1 -22.0221357,0 11.011069,3.4902595 0 1 1 22.0221357,0 z"
+ id="path2822"
+ style="fill:none;stroke:#ffffff;stroke-width:2.29999995;stroke-linecap:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 14.696708,33.884776 a 13.76451,3.1119547 0 0 1 -27.529014,0 13.76451,3.1119547 0 1 1 27.529014,0 z"
+ id="path2818"
+ style="fill:none;stroke:#ffffff;stroke-width:2.29999995;stroke-linecap:square;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m -7.4074987,57.643633 c 0,0 5.109981,-1.82439 8.518339,-1.867761 3.408358,-0.04337 9.1771277,1.744692 9.1771277,1.744692"
+ id="path4192"
+ style="fill:none;stroke:#282828;stroke-width:3;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><g
+ transform="translate(-26.584624,19.407629)"
+ id="g4702"><path
+ d="m 13.75483,14.61245 c 3.56733,24.489728 3.430201,24.354426 3.430201,24.354426 l 0,0"
+ id="path2820"
+ style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 15.951887,16.457318 c 3.836562,25.030939 3.656235,25.621512 3.656235,25.621512"
+ id="path3620"
+ style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 20.66094,17.470259 c 2.288476,25.03094 2.24528,25.62334 2.24528,25.62334"
+ id="path3624"
+ style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 26.831688,18.009641 c 0.06731,24.963289 0.180327,25.396617 0.180327,25.396617"
+ id="path3628"
+ style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="M 34.281292,17.792054 C 31.790893,43.567158 32.084236,43.133828 32.084236,43.133828"
+ id="path3626"
+ style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 39.328864,16.340019 c -2.902587,25.706467 -2.96102,25.806464 -2.96102,25.806464"
+ id="path3622"
+ style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 41.24517,14.793462 c -2.625017,24.01617 -2.55771,24.314197 -2.55771,24.314197"
+ id="path2820-4"
+ style="fill:none;stroke:#ffffff;stroke-width:1.5;stroke-linecap:round;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g></svg> \ No newline at end of file
diff --git a/icons/myblocksoff.svg b/icons/myblocksoff.svg
new file mode 100644
index 0000000..7d9a28c
--- /dev/null
+++ b/icons/myblocksoff.svg
@@ -0,0 +1,69 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ version="1.0"
+ width="55"
+ height="55"
+ id="svg2">
+ <metadata
+ id="metadata10">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs8" />
+ <rect
+ width="45"
+ height="45"
+ x="5"
+ y="5"
+ id="rect2990"
+ style="fill:#282828;fill-opacity:1;stroke:none" />
+ <g
+ id="g3789">
+ <path
+ d="m 15.719636,31.331478 0.114372,5.261133 11.437247,6.290486 L 27.5,29.387146"
+ id="path2463"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 27.728744,29.501519 0.05719,13.381578 11.723178,-7.548583 0,-4.689272 -5.947368,3.545548"
+ id="path2465"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 10.001012,27.328441 5.604251,-5.146761 -5.832996,-2.973684 12.123482,-7.091093 5.718623,3.316801 5.489879,-3.088056 12.123482,7.319838 -5.832996,2.401822 5.489878,5.032388 -11.322874,7.205466 -5.947369,-5.261134 -6.290485,5.261134 -11.322875,-6.976721 z"
+ id="path2459"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="M 16.40587,21.952935 27.156883,15.204959 38.937247,22.067308 27.614372,28.815283 16.40587,21.952935 z"
+ id="path2461"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ </g>
+ <g
+ transform="matrix(0.39620698,0,0,0.39620698,28.654032,26.094918)"
+ id="stock-xo_1_"
+ style="display:block">
+ <path
+ d="m 33.233,35.1 10.102,10.1 c 0.752,0.75 1.217,1.783 1.217,2.932 0,2.287 -1.855,4.143 -4.146,4.143 -1.145,0 -2.178,-0.463 -2.932,-1.211 l -10.102,-10.103 -10.1,10.1 c -0.75,0.75 -1.787,1.211 -2.934,1.211 -2.284,0 -4.143,-1.854 -4.143,-4.141 0,-1.146 0.465,-2.184 1.212,-2.934 L 21.511,35.095 11.409,24.995 c -0.747,-0.748 -1.212,-1.785 -1.212,-2.93 0,-2.289 1.854,-4.146 4.146,-4.146 1.143,0 2.18,0.465 2.93,1.214 L 27.372,29.235 37.474,19.132 c 0.754,-0.749 1.787,-1.214 2.934,-1.214 2.289,0 4.146,1.856 4.146,4.145 0,1.146 -0.467,2.18 -1.217,2.932 L 33.233,35.1 z"
+ id="path3076"
+ style="fill:#ffffff;stroke:#010101;stroke-width:3.5" />
+ <circle
+ cx="27.371"
+ cy="10.849"
+ r="8.1219997"
+ id="circle3078"
+ style="fill:#ffffff;stroke:#010101;stroke-width:3.5" />
+ </g>
+</svg>
diff --git a/icons/myblockson.svg b/icons/myblockson.svg
new file mode 100644
index 0000000..bb8852d
--- /dev/null
+++ b/icons/myblockson.svg
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ version="1.0"
+ width="55"
+ height="55"
+ id="svg2">
+ <metadata
+ id="metadata12">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <defs
+ id="defs4" />
+ <rect
+ width="55"
+ height="55"
+ rx="0"
+ x="0"
+ y="0"
+ id="rect2839"
+ style="fill:#ffd200;fill-opacity:1;fill-rule:evenodd;stroke:none" />
+ <g
+ id="g3788">
+ <path
+ d="m 15.719636,31.331478 0.114372,5.261133 11.437247,6.290486 L 27.5,29.387146"
+ id="path2463"
+ style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#804000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 27.728744,29.501519 0.05719,13.381578 11.723178,-7.548583 0,-4.689272 -5.947368,3.545548"
+ id="path2465"
+ style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#804000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="m 10.001012,27.328441 5.604251,-5.146761 -5.832996,-2.973684 12.123482,-7.091093 5.718623,3.316801 5.489879,-3.088056 12.123482,7.319838 -5.832996,2.401822 5.489878,5.032388 -11.322874,7.205466 -5.947369,-5.261134 -6.290485,5.261134 -11.322875,-6.976721 z"
+ id="path2459"
+ style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#804000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ <path
+ d="M 16.40587,21.952935 27.156883,15.204959 38.937247,22.067308 27.614372,28.815283 16.40587,21.952935 z"
+ id="path2461"
+ style="fill:#ffff00;fill-opacity:1;fill-rule:evenodd;stroke:#804000;stroke-width:1.5;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+ </g>
+ <g
+ transform="matrix(0.39620698,0,0,0.39620698,28.654032,26.094918)"
+ id="stock-xo_1_"
+ style="display:block">
+ <path
+ d="m 33.233,35.1 10.102,10.1 c 0.752,0.75 1.217,1.783 1.217,2.932 0,2.287 -1.855,4.143 -4.146,4.143 -1.145,0 -2.178,-0.463 -2.932,-1.211 l -10.102,-10.103 -10.1,10.1 c -0.75,0.75 -1.787,1.211 -2.934,1.211 -2.284,0 -4.143,-1.854 -4.143,-4.141 0,-1.146 0.465,-2.184 1.212,-2.934 L 21.511,35.095 11.409,24.995 c -0.747,-0.748 -1.212,-1.785 -1.212,-2.93 0,-2.289 1.854,-4.146 4.146,-4.146 1.143,0 2.18,0.465 2.93,1.214 L 27.372,29.235 37.474,19.132 c 0.754,-0.749 1.787,-1.214 2.934,-1.214 2.289,0 4.146,1.856 4.146,4.145 0,1.146 -0.467,2.18 -1.217,2.932 L 33.233,35.1 z"
+ id="path3076"
+ style="fill:#ffffff;stroke:#010101;stroke-width:3.5" />
+ <circle
+ cx="27.371"
+ cy="10.849"
+ r="8.1219997"
+ id="circle3078"
+ style="fill:#ffffff;stroke:#010101;stroke-width:3.5" />
+ </g>
+</svg>
diff --git a/icons/save-blocks.svg b/icons/save-blocks.svg
new file mode 100644
index 0000000..c2cff38
--- /dev/null
+++ b/icons/save-blocks.svg
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ version="1.1"
+ width="55"
+ height="55"
+ viewBox="0 0 55 55"
+ id="svg2"
+ xml:space="preserve"><metadata
+ id="metadata25"><rdf:RDF><cc:Work
+ rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
+ id="defs33" /><g
+ id="g3830"><g
+ transform="matrix(0.55205508,0,0,0.55205508,75.618464,18.235971)"
+ id="g4382"><g
+ transform="translate(-80.093659,12.220029)"
+ id="g4308"
+ style="fill:none;stroke:#ffffff;stroke-opacity:1"><g
+ id="g4310"
+ style="fill:none;stroke:#ffffff;stroke-opacity:1"><path
+ d="m 6.736,49.002 h 24.52 c 2.225,0 3.439,-1.447 3.439,-3.441 v -27.28 c 0,-1.73 -1.732,-3.441 -3.439,-3.441 h -4.389"
+ id="path4312"
+ style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /></g></g><g
+ transform="translate(-80.093659,12.220029)"
+ id="g4314"
+ style="fill:none;stroke:#ffffff;stroke-opacity:1"><g
+ id="g4316"
+ style="fill:none;stroke:#ffffff;stroke-opacity:1"><path
+ d="m 26.867,38.592 c 0,1.836 -1.345,3.201 -3.441,4.047 L 6.736,49.002 V 14.84 l 16.69,-8.599 c 2.228,-0.394 3.441,0.84 3.441,2.834 v 29.517 z"
+ id="path4318"
+ style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /></g></g><path
+ d="m -70.669659,54.827029 c 0,0 -1.351,-0.543 -2.702,-0.543 -1.351,0 -2.703,0.543 -2.703,0.543"
+ id="path4320"
+ style="fill:none;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
+ d="m -70.669659,44.226029 c 0,0 -1.239,-0.543 -2.815,-0.543 -1.577,0 -2.59,0.543 -2.59,0.543"
+ id="path4322"
+ style="fill:none;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><path
+ d="m -70.669659,33.898029 c 0,0 -1.125,-0.544 -2.927,-0.544 -1.802,0 -2.478,0.544 -2.478,0.544"
+ id="path4324"
+ style="fill:none;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /><line
+ id="line4326"
+ y2="23.725029"
+ y1="58.753029"
+ x2="-66.884659"
+ x1="-66.884659"
+ style="fill:none;stroke:#ffffff;stroke-width:2.25;stroke-linecap:round;stroke-linejoin:round;stroke-opacity:1" /></g><g
+ transform="matrix(1,0,0,-1,-30.386573,49.171266)"
+ id="g4770"><g
+ transform="translate(34.0803,-1006.42)"
+ id="g4772"><polyline
+ id="polyline4774"
+ points="51.562,15.306 41.17,16.188 42.053,5.794"
+ style="fill:none;stroke:#ffffff;stroke-width:3.5;stroke-linecap:round;stroke-linejoin:round"
+ transform="matrix(-0.469241,0.469241,-0.469241,-0.469241,66.2906,1019.03)" /><path
+ d="m 39.363241,1033.1291 -0.05636,9.9115 -8.750608,0.067"
+ id="path4776"
+ style="fill:none;stroke:#ffffff;stroke-width:2.5;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></g></g><g
+ transform="matrix(0.80095119,0,0,0.80095119,-4.6564792,-5.9184549)"
+ id="g3789"><path
+ d="m 15.719636,31.331478 0.114372,5.261133 11.437247,6.290486 L 27.5,29.387146"
+ id="path2463"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 27.728744,29.501519 0.05719,13.381578 11.723178,-7.548583 0,-4.689272 -5.947368,3.545548"
+ id="path2465"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="m 10.001012,27.328441 5.604251,-5.146761 -5.832996,-2.973684 12.123482,-7.091093 5.718623,3.316801 5.489879,-3.088056 12.123482,7.319838 -5.832996,2.401822 5.489878,5.032388 -11.322874,7.205466 -5.947369,-5.261134 -6.290485,5.261134 -11.322875,-6.976721 z"
+ id="path2459"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /><path
+ d="M 16.40587,21.952935 27.156883,15.204959 38.937247,22.067308 27.614372,28.815283 16.40587,21.952935 z"
+ id="path2461"
+ style="fill:none;stroke:#ffffff;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /></g></svg> \ No newline at end of file
diff --git a/turtleblocks.py b/turtleblocks.py
index 36a03de..a31cb07 100755
--- a/turtleblocks.py
+++ b/turtleblocks.py
@@ -388,6 +388,8 @@ class TurtleMain():
MenuBuilder.make_menu_item(menu, _('Paste'), self._do_paste_cb)
MenuBuilder.make_menu_item(menu, _('Save stack'),
self._do_save_macro_cb)
+ MenuBuilder.make_menu_item(menu, _('Delete stack'),
+ self._do_delete_macro_cb)
edit_menu = MenuBuilder.make_sub_menu(menu, _('Edit'))
menu = gtk.Menu()
@@ -601,6 +603,7 @@ class TurtleMain():
def _do_save_macro_cb(self, widget):
''' Callback for save stack button. '''
self.tw.copying_blocks = False
+ self.tw.deleting_blocks = False
if self.tw.saving_blocks:
self.win.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
self.tw.saving_blocks = False
@@ -608,9 +611,21 @@ class TurtleMain():
self.win.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
self.tw.saving_blocks = True
+ def _do_delete_macro_cb(self, widget):
+ ''' Callback for delete stack button. '''
+ self.tw.copying_blocks = False
+ self.tw.saving_blocks = False
+ if self.tw.deleting_blocks:
+ self.win.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
+ self.tw.deleting_blocks = False
+ else:
+ self.win.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.HAND1))
+ self.tw.deleting_blocks = True
+
def _do_copy_cb(self, button):
''' Callback for copy button. '''
self.tw.saving_blocks = False
+ self.tw.deleting_blocks = False
if self.tw.copying_blocks:
self.win.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
self.tw.copying_blocks = False
@@ -622,6 +637,7 @@ class TurtleMain():
''' Callback for paste button. '''
self.tw.copying_blocks = False
self.tw.saving_blocks = False
+ self.tw.deleting_blocks = False
self.win.get_window().set_cursor(gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
clipBoard = gtk.Clipboard()
text = clipBoard.wait_for_text()