From ae91c9c6f47a00c5c37a92a035e09649f502af3c Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Tue, 26 Jul 2011 16:24:53 +0000 Subject: move block skins to plugins directory --- diff --git a/TurtleArt/taconstants.py b/TurtleArt/taconstants.py index 80d505c..e40b3ca 100644 --- a/TurtleArt/taconstants.py +++ b/TurtleArt/taconstants.py @@ -131,6 +131,7 @@ PREFIX_DICTIONARY = {'journal': '#smedia_', 'description': '#sdescr_', # # Status blocks # +SKIN_PATHS = ['images'] MEDIA_SHAPES = [] diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py index 07d7488..692fb4e 100644 --- a/TurtleArt/tawindow.py +++ b/TurtleArt/tawindow.py @@ -53,7 +53,7 @@ except ImportError: from taconstants import HORIZONTAL_PALETTE, VERTICAL_PALETTE, BLOCK_SCALE, \ MEDIA_SHAPES, STATUS_SHAPES, OVERLAY_SHAPES, STRING_OR_NUMBER_ARGS, \ TOOLBAR_SHAPES, TAB_LAYER, RETURN, OVERLAY_LAYER, CATEGORY_LAYER, \ - BLOCKS_WITH_SKIN, ICON_SIZE, PALETTE_SCALE, PALETTE_WIDTH, \ + BLOCKS_WITH_SKIN, ICON_SIZE, PALETTE_SCALE, PALETTE_WIDTH, SKIN_PATHS, \ MACROS, TOP_LAYER, BLOCK_LAYER, OLD_NAMES, DEFAULT_TURTLE, TURTLE_LAYER, \ CURSOR, EXPANDABLE, COLLAPSIBLE, DEAD_DICTS, DEAD_KEYS, NO_IMPORT, \ TEMPLATES, PYTHON_SKIN, PALETTE_HEIGHT, STATUS_LAYER, OLD_DOCK, \ @@ -365,8 +365,13 @@ class TurtleArtWindow(): filename = 'file' + name[7:] else: filename = name - self.media_shapes[name] = svg_str_to_pixbuf(svg_from_file( - "%s/images/%s.svg" % (self.path, filename))) + # Try both images/ and plugins/*/images/ + for path in SKIN_PATHS: + if os.path.exists(os.path.join(self.path, path, + filename + '.svg')): + self.media_shapes[name] = svg_str_to_pixbuf(svg_from_file( + os.path.join(self.path, path, filename + '.svg'))) + break for i, name in enumerate(STATUS_SHAPES): self.status_shapes[name] = svg_str_to_pixbuf(svg_from_file( diff --git a/plugins/camera_sensor/camera_sensor.py b/plugins/camera_sensor/camera_sensor.py index 66ff23c..32a394d 100644 --- a/plugins/camera_sensor/camera_sensor.py +++ b/plugins/camera_sensor/camera_sensor.py @@ -30,7 +30,7 @@ from plugins.plugin import Plugin from TurtleArt.tapalette import make_palette from TurtleArt.talogo import media_blocks_dictionary, primitive_dictionary from TurtleArt.tautils import get_path, debug_output -from TurtleArt.taconstants import MEDIA_SHAPES, NO_IMPORT +from TurtleArt.taconstants import MEDIA_SHAPES, NO_IMPORT, SKIN_PATHS class Camera_sensor(Plugin): @@ -60,6 +60,8 @@ class Camera_sensor(Plugin): primitive_dictionary['read_camera'] = self.prim_read_camera media_blocks_dictionary['camera'] = self.prim_take_picture + SKIN_PATHS.append('plugins/camera_sensor/images') + if self._status: palette.add_block('luminance', style='box-style', diff --git a/plugins/turtle_blocks_extras/turtle_blocks_extras.py b/plugins/turtle_blocks_extras/turtle_blocks_extras.py index d628975..865fb13 100644 --- a/plugins/turtle_blocks_extras/turtle_blocks_extras.py +++ b/plugins/turtle_blocks_extras/turtle_blocks_extras.py @@ -30,7 +30,7 @@ from TurtleArt.tapalette import make_palette, define_logo_function from TurtleArt.talogo import primitive_dictionary, logoerror, \ media_blocks_dictionary from TurtleArt.taconstants import DEFAULT_SCALE, ICON_SIZE, CONSTANTS, \ - MEDIA_SHAPES + MEDIA_SHAPES, SKIN_PATHS from TurtleArt.tautils import convert, round_int, debug_output from TurtleArt.tajail import myfunc, myfunc_import @@ -72,6 +72,8 @@ class Turtle_blocks_extras(Plugin): self.tw = parent def setup(self): + SKIN_PATHS.append('plugins/turtle_blocks_extras/images') + self.heap = self.tw.lc.heap self.keyboard = self.tw.lc.keyboard self.title_height = int((self.tw.canvas.height / 20) * self.tw.scale) -- cgit v0.9.1