Skip to content

Instantly share code, notes, and snippets.

@quozl
Last active June 11, 2018 08:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save quozl/7a91fedf0e63ea48ba15af8e211d295e to your computer and use it in GitHub Desktop.
Save quozl/7a91fedf0e63ea48ba15af8e211d295e to your computer and use it in GitHub Desktop.
diff --git a/.gitignore b/.gitignore
index 0b4786b..55e9d9b 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,5 +4,3 @@ locale
dist
po.original
po.merged
-*.rej
-*.patch
diff --git a/TurtleArt/sprites.py b/TurtleArt/sprites.py
index dbde7d5..44e174b 100644
--- a/TurtleArt/sprites.py
+++ b/TurtleArt/sprites.py
@@ -79,6 +79,7 @@ import cairo
import gi
gi.require_version("Gtk", "3.0")
gi.require_version('PangoCairo', '1.0')
+
from gi.repository import Gtk
from gi.repository import Gdk
from gi.repository import GdkPixbuf
diff --git a/TurtleArt/tawindow.py b/TurtleArt/tawindow.py
index 054680c..0326ab8 100644
--- a/TurtleArt/tawindow.py
+++ b/TurtleArt/tawindow.py
@@ -3032,7 +3032,7 @@ class TurtleArtWindow():
self._autohide_shape = True
if blk is None:
return
- if self.interactive_mode:
+ if not self.interactive_mode:
self.lc.find_value_blocks() # Are there blocks to update?
if self.canvas.cr_svg is None:
self.canvas.setup_svg_surface()
diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py
index 2a4bf1e..38feab9 100644
--- a/TurtleArtActivity.py
+++ b/TurtleArtActivity.py
@@ -279,7 +279,6 @@ class TurtleArtActivity(activity.Activity):
if hasattr(self, 'get_window'):
self.get_window().set_cursor(self._old_cursor)
-
def do_save_as_python_cb(self, widget):
''' Callback for saving the project as Python code. '''
self.save_as_python.set_icon_name('python-saveon')
@@ -536,7 +535,7 @@ class TurtleArtActivity(activity.Activity):
self.tw.eraser_button()
self.restore_state()
GObject.timeout_add(250, self.eraser_button.set_icon_name, 'eraseron')
-
+
def restore_state(self):
''' Restore the current challange after a clear screen '''
if self._custom_filepath is None:
@@ -755,7 +754,7 @@ class TurtleArtActivity(activity.Activity):
self.read_file(os.path.join(
activity.get_bundle_path(), 'challenges',
'help-' + flag + '.ta'))
-
+
def get_document_path(self, async_cb, async_err_cb):
''' View TA code as part of view source. '''
ta_code_path = self._dump_ta_code()
@@ -914,10 +913,12 @@ class TurtleArtActivity(activity.Activity):
self.edit_toolbar_button.set_expanded(True)
self.edit_toolbar_button.set_expanded(False)
self.palette_toolbar_button.set_expanded(True)
+
self._unfullscreen_button._button.connect('clicked', self.do_unfullscreen_cb)
def _setup_extra_controls(self):
''' Add the rest of the buttons to the main toolbar '''
+
self._make_project_buttons(self.toolbox.toolbar)
self.extras_separator = self._add_separator(
@@ -1468,7 +1469,6 @@ class TurtleArtActivity(activity.Activity):
self.metadata['error_list'] = data_to_string(errors)
_logger.debug('Wrote to file: %s' % (file_path))
-
def _reload_plugin_alert(self, tmp_dir, tmp_path, plugin_path, plugin_name,
file_info):
''' We warn the user if the plugin was previously loaded '''
@@ -1844,6 +1844,7 @@ class TurtleArtActivity(activity.Activity):
self._challenge_box.add(self._challenge_window)
self.fixed.put(self._challenge_box, width, height)
+
self._offsets = {}
offset_fd = open(os.path.join(activity.get_bundle_path(),
'challenges',
@@ -1888,7 +1889,6 @@ class TurtleArtActivity(activity.Activity):
self._load_level()
self.get_window().set_cursor(Gdk.Cursor(Gdk.CursorType.WATCH))
-
def _fill_challenges_list(self, store):
'''
Append images from the artwork_paths to the store.
@@ -1916,10 +1916,3 @@ class TurtleArtActivity(activity.Activity):
elif self.activity_toolbar_button.is_expanded():
return True
return False
-
- def _scan_for_challenges(self):
- file_list = list(glob.glob(os.path.join(activity.get_bundle_path(),
- 'samples', 'thumbnails',
- '*.svg')))
- file_list.sort()
- return file_list
diff --git a/activity/activity.info b/activity/activity.info
index 74ca4ae..0911dff 100644
--- a/activity/activity.info
+++ b/activity/activity.info
@@ -10,4 +10,5 @@ website = http://wiki.sugarlabs.org/go/Activities/Turtle_Art
mime_types = application/x-turtle-art;application/vnd.turtleblocks
categories = programming art
summary = A Logo-inspired turtle that draws colorful pictures with snap-together visual programming blocks
-repository = https://github.com/sugarlabs/activity-turtle-confusion
+repository = https://github.com/sugarlabs/turtleart-activity
+
diff --git a/gnome_plugins/uploader_plugin.py b/gnome_plugins/uploader_plugin.py
index 6be2367..895a886 100644
--- a/gnome_plugins/uploader_plugin.py
+++ b/gnome_plugins/uploader_plugin.py
@@ -158,7 +158,11 @@ http://turtleartsite.sugarlabs.org to upload your project.'))
username = self.username_entry.get_text()
password = self.password_entry.get_text()
server = xmlrpclib.ServerProxy(self._upload_server + '/call/xmlrpc')
- logged_in = server.login_remote(username, password)
+ logged_in = None
+ try:
+ logged_in = server.login_remote(username, password)
+ except socket.gaierror as e:
+ print "Login failed %s" % e
if logged_in:
upload_key = logged_in
self._do_submit_to_web(upload_key)
diff --git a/plugins/accelerometer/accelerometer.py b/plugins/accelerometer/accelerometer.py
index d62113a..512cb17 100644
--- a/plugins/accelerometer/accelerometer.py
+++ b/plugins/accelerometer/accelerometer.py
@@ -50,10 +50,16 @@ class Accelerometer(Plugin):
help_string=_('Palette of extra options'),
position=8,
translation=_('extras'))
+ '''
+ palette = make_palette('sensor',
+ colors=["#FF6060", "#A06060"],
+ help_string=_('Palette of sensor blocks'),
+ position=6)
+ '''
if self._status:
palette.add_block('xyz',
- hidden=True
+ hidden=True,
style='basic-style-extended-vertical',
label=_('acceleration'),
help_string=_(
@@ -64,8 +70,9 @@ class Accelerometer(Plugin):
hidden=True,
style='basic-style-extended-vertical',
label=_('acceleration'),
- help_string=\
- _('push acceleration in x, y, z to heap'),
+ help_string=_(
+ 'push acceleration in x, y, z to heap'),
+ hidden=True,
prim_name='xyz')
self._parent.lc.def_prim(
diff --git a/plugins/camera_sensor/camera_sensor.py b/plugins/camera_sensor/camera_sensor.py
index b507236..d09444b 100644
--- a/plugins/camera_sensor/camera_sensor.py
+++ b/plugins/camera_sensor/camera_sensor.py
@@ -64,6 +64,13 @@ class Camera_sensor(Plugin):
def setup(self):
''' Set up the palettes '''
+ '''
+ sensors_palette = make_palette('sensor',
+ colors=["#FF6060", "#A06060"],
+ help_string=_(
+ 'Palette of sensor blocks'),
+ position=6)
+ '''
media_palette = make_palette('media',
colors=["#A0FF00", "#80A000"],
help_string=_('Palette of media objects'),
@@ -79,107 +86,60 @@ class Camera_sensor(Plugin):
hidden = True
second_cam = False
if self._status:
- sensors_palette.add_block('luminance',
- hidden=True,
- style='box-style',
- label=_('brightness'),
- help_string=_(
- 'light level detected by camera'),
- value_block=True,
- prim_name='luminance')
- self._parent.lc.def_prim(
- 'luminance', 0,
- Primitive(self.prim_read_camera,
- return_type=TYPE_NUMBER,
- kwarg_descs={'luminance_only': ConstantArg(True)},
- call_afterwards=self.after_luminance))
-
- # Depreciated block
- sensors_palette.add_block('read_camera',
- hidden=True,
- style='box-style',
- label=_('brightness'),
- help_string=_(
- 'Average RGB color from camera \
-is pushed to the stack'),
- value_block=True,
- prim_name='read_camera')
- self._parent.lc.def_prim(
- 'read_camera', 0,
- Primitive(self.prim_read_camera,
- kwarg_descs={'luminance_only': ConstantArg(False)}))
-
- media_palette.add_block('camera',
- hidden=True,
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
+ hidden = False
if len(self.devices) > 1:
- media_palette.add_block('camera1',
- hidden=True,
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
- else:
- media_palette.add_block('camera1',
- hidden=True,
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
-
- else: # No camera, so blocks should do nothing
- sensors_palette.add_block('luminance',
- hidden=True,
- style='box-style',
- label=_('brightness'),
- help_string=\
- _('light level detected by camera'),
- value_block=True,
- prim_name='read_camera')
- self._parent.lc.def_prim(
- 'luminance', 0,
- Primitive(self.prim_read_camera,
- return_type=TYPE_NUMBER,
- kwarg_descs={'luminance_only': ConstantArg(True)},
- call_afterwards=self.after_luminance))
-
- # Depreciated block
- sensors_palette.add_block('read_camera',
- hidden=True,
- style='box-style',
- label=_('brightness'),
- help_string=_(
- 'Average RGB color from camera \
-is pushed to the stack'),
- value_block=True,
- prim_name='read_camera')
- self._parent.lc.def_prim(
- 'read_camera', 0,
- Primitive(self.prim_read_camera,
- return_type=TYPE_NUMBER,
- kwarg_descs={'luminance_only': ConstantArg(False)}))
-
- media_palette.add_block('camera',
- hidden=True,
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
-
- media_palette.add_block('camera1',
- hidden=True,
- style='box-style-media',
- label=' ',
- default='CAMERA',
- help_string=_('camera output'),
- content_block=True)
+ second_cam = True
+
+ # ++ Turtle Confusion
+ hidden = True
+ second_cam = False
+ # -- Turtle Confusion
+
+ sensors_palette.add_block('luminance',
+ hidden=hidden,
+ style='box-style',
+ label=_('brightness'),
+ help_string=_(
+ 'light level detected by camera'),
+ value_block=True,
+ prim_name='luminance')
+ self._parent.lc.def_prim(
+ 'luminance', 0,
+ Primitive(self.prim_read_camera,
+ return_type=TYPE_NUMBER,
+ kwarg_descs={'luminance_only': ConstantArg(True)},
+ call_afterwards=self.after_luminance))
+
+ media_palette.add_block('camera',
+ hidden=hidden,
+ style='box-style-media',
+ label=' ',
+ default='CAMERA',
+ help_string=_('camera output'),
+ content_block=True)
+
+ media_palette.add_block('camera1',
+ hidden=not(second_cam),
+ style='box-style-media',
+ label=' ',
+ default='CAMERA',
+ help_string=_('camera output'),
+ content_block=True)
+
+ # Depreciated block
+ sensors_palette.add_block(
+ 'read_camera',
+ hidden=True,
+ style='box-style',
+ label=_('brightness'),
+ help_string=_('Average RGB color from camera is pushed to the stack'),
+ value_block=True,
+ prim_name='read_camera')
+ self._parent.lc.def_prim(
+ 'read_camera', 0,
+ Primitive(self.prim_read_camera,
+ return_type=TYPE_NUMBER,
+ kwarg_descs={'luminance_only': ConstantArg(False)}))
NO_IMPORT.append('camera')
BLOCKS_WITH_SKIN.append('camera')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment