Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/TurtleArt/tawindow.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2013-10-08 20:44:17 (GMT)
committer Walter Bender <walter@sugarlabs.org>2013-10-08 20:44:17 (GMT)
commitc80ccaf443dc6f1ea9dd59f45e60e8d7fa525fa1 (patch)
tree3acee3d12991adbfc2f49daf307df5ed4e949624 /TurtleArt/tawindow.py
parent3c02fe640e42fa8e7f1d6123330cb699e650b00f (diff)
resync with 191 changes
Diffstat (limited to 'TurtleArt/tawindow.py')
-rw-r--r--TurtleArt/tawindow.py69
1 files changed, 54 insertions, 15 deletions
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index af611a3..2bd720e 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -382,6 +382,7 @@ class TurtleArtWindow():
except Exception as e:
debug_output('Failed to load %s: %s' % (plugin_class, str(e)),
self.running_sugar)
+
def _add_plugin_icon_dir(self, dirname):
''' If there is an icon subdir, add it to the search path. '''
@@ -404,38 +405,73 @@ class TurtleArtWindow():
def _setup_plugins(self):
''' Initial setup -- called just once. '''
for plugin in self.turtleart_plugins:
- plugin.setup()
+ try:
+ plugin.setup()
+ except Exception as e:
+ debug_output('Plugin %s failed during setup: %s' %
+ (plugin, str(e)), self.running_sugar)
+ # If setup fails, remove the plugin from the list
+ self.turtleart_plugins.remove(plugin)
def _start_plugins(self):
''' Start is called everytime we execute blocks. '''
for plugin in self.turtleart_plugins:
- plugin.start()
+ if hasattr(plugin, 'start'):
+ try:
+ plugin.start()
+ except Exception as e:
+ debug_output('Plugin %s failed during start: %s' %
+ (plugin, str(e)), self.running_sugar)
def stop_plugins(self):
''' Stop is called whenever we stop execution. '''
for plugin in self.turtleart_plugins:
- plugin.stop()
+ if hasattr(plugin, 'stop'):
+ try:
+ plugin.stop()
+ except Exception as e:
+ debug_output('Plugin %s failed during stop: %s' %
+ (plugin, str(e)), self.running_sugar)
def clear_plugins(self):
''' Clear is called from the clean block and erase button. '''
for plugin in self.turtleart_plugins:
if hasattr(plugin, 'clear'):
- plugin.clear()
+ try:
+ plugin.clear()
+ except Exception as e:
+ debug_output('Plugin %s failed during clear: %s' %
+ (plugin, str(e)), self.running_sugar)
def background_plugins(self):
''' Background is called when we are pushed to the background. '''
for plugin in self.turtleart_plugins:
- plugin.goto_background()
+ if hasattr(plugin, 'goto_background'):
+ try:
+ plugin.goto_background()
+ except Exception as e:
+ debug_output('Plugin %s failed during background: %s' %
+ (plugin, str(e)), self.running_sugar)
def foreground_plugins(self):
''' Foreground is called when we are return from the background. '''
for plugin in self.turtleart_plugins:
- plugin.return_to_foreground()
+ if hasattr(plugin, 'return_to_foreground'):
+ try:
+ plugin.return_to_foreground()
+ except Exception as e:
+ debug_output('Plugin %s failed during foreground: %s' %
+ (plugin, str(e)), self.running_sugar)
def quit_plugins(self):
''' Quit is called upon program exit. '''
for plugin in self.turtleart_plugins:
- plugin.quit()
+ if hasattr(plugin, 'quit'):
+ try:
+ plugin.quit()
+ except Exception as e:
+ debug_output('Plugin %s failed during quit: %s' %
+ (plugin, str(e)), self.running_sugar)
def _setup_events(self):
''' Register the events we listen to. '''
@@ -1002,7 +1038,8 @@ class TurtleArtWindow():
self.running_sugar)
else:
blk.spr.hide()
- if 'trash' in palette_names and n == palette_names.index('trash'):
+ if 'trash' in palette_names and \
+ n == palette_names.index('trash'):
for blk in self.trash_stack:
# Deprecated
for gblk in find_group(blk):
@@ -1545,9 +1582,9 @@ before making changes to your program'))
self._restore_from_trash(find_top_block(blk))
elif blk.type == 'proto':
if self.deleting_blocks:
- if 'myblocks' in palette_names and \
+ if 'my blocks' in palette_names and \
self.selected_palette == \
- palette_names.index('myblocks'):
+ palette_names.index('my blocks'):
self._delete_stack_alert(blk)
self.parent.get_window().set_cursor(
gtk.gdk.Cursor(gtk.gdk.LEFT_PTR))
@@ -1569,8 +1606,9 @@ before making changes to your program'))
self._put_in_trash(b1)
else:
self._put_in_trash(find_top_block(b))
- self.show_toolbar_palette(palette_names.index('trash'),
- regenerate=True)
+ if 'trash' in palette_names:
+ self.show_toolbar_palette(
+ palette_names.index('trash'), regenerate=True)
elif blk.name in MACROS:
self.new_macro(blk.name, x + 20, y + 20)
else:
@@ -1752,7 +1790,7 @@ before making changes to your program'))
error_output('Could not remove macro %s: %s' %
(macro_path, e))
return
- i = palette_names.index('myblocks')
+ i = palette_names.index('my blocks')
palette_blocks[i].remove(blk.name)
for pblk in self.palettes[i]:
if pblk.name == blk.name:
@@ -2117,8 +2155,9 @@ before making changes to your program'))
blk.type = 'deleted'
blk.spr.hide()
self.trash_stack = []
- self.show_toolbar_palette(palette_names.index('trash'),
- regenerate=True)
+ if 'trash' in palette_names:
+ self.show_toolbar_palette(palette_names.index('trash'),
+ regenerate=True)
def _in_the_trash(self, x, y):
''' Is x, y over a palette? '''