Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
authorWalter Bender <walter@sugarlabs.org>2014-01-19 21:36:47 (GMT)
committer Walter Bender <walter@sugarlabs.org>2014-01-19 21:36:47 (GMT)
commitccc61256b422b623cb0173f15ec2a61d78e00201 (patch)
tree7c9cc8b9de019b851349bfe5d23148f02e9b6449 /activity.py
parent8de9dc0e92b47375e44c4edfad926b8e5143c60f (diff)
add collaboration; fix bug with pause button
Diffstat (limited to 'activity.py')
-rw-r--r--activity.py63
1 files changed, 61 insertions, 2 deletions
diff --git a/activity.py b/activity.py
index ef86d6b..202cf6e 100644
--- a/activity.py
+++ b/activity.py
@@ -320,10 +320,10 @@ class PhysicsActivity(activity.Activity):
self.stop_play_state = not self.stop_play_state
if self.stop_play_state:
- self.stop_play.set_icon('media-playback-stop')
+ self.stop_play.set_icon_name('media-playback-stop')
self.stop_play.set_tooltip(_('Stop'))
else:
- self.stop_play.set_icon('media-playback-start')
+ self.stop_play.set_icon_name('media-playback-start')
self.stop_play.set_tooltip(_('Start'))
def clear_all_cb(self, button):
@@ -507,6 +507,13 @@ class PhysicsActivity(activity.Activity):
def event_received_cb(self, text):
''' Data is passed as tuples: cmd:text '''
dispatch_table = {'C': self._construct_shared_circle,
+ 'B': self._construct_shared_box,
+ 'T': self._construct_shared_triangle,
+ 'j': self._add_shared_joint,
+ 'p': self._add_shared_pin,
+ 'm': self._add_shared_motor,
+ 't': self._add_shared_track,
+ 'c': self._add_shared_chain,
}
logging.debug('<<< %s' % (text[0]))
dispatch_table[text[0]](text[2:])
@@ -521,6 +528,58 @@ class PhysicsActivity(activity.Activity):
self._constructors['Circle'](pos, radius, density, restitution,
friction, share=False)
+ def _construct_shared_box(self, data):
+ box_data = json.loads(data)
+ pos1 = box_data[0]
+ pos2 = box_data[1]
+ density = box_data[2]
+ restitution = box_data[3]
+ friction = box_data[4]
+ self._constructors['Box'](pos1, pos2, density, restitution,
+ friction, share=False)
+
+ def _construct_shared_triangle(self, data):
+ triangle_data = json.loads(data)
+ pos1 = triangle_data[0]
+ pos2 = triangle_data[1]
+ density = triangle_data[2]
+ restitution = triangle_data[3]
+ friction = triangle_data[4]
+ self._constructors['Triangle'](pos1, pos2, density, restitution,
+ friction, share=False)
+
+ def _add_shared_joint(self, data):
+ joint_data = json.loads(data)
+ pos1 = joint_data[0]
+ pos2 = joint_data[1]
+ self._constructors['Joint'](pos1, pos2, share=False)
+
+ def _add_shared_pin(self, data):
+ joint_data = json.loads(data)
+ pos = joint_data[0]
+ self._constructors['Pin'](pos, share=False)
+
+ def _add_shared_motor(self, data):
+ joint_data = json.loads(data)
+ pos = joint_data[0]
+ speed = joint_data[1]
+ self._constructors['Motor'](pos, speed, share=False)
+
+ def _add_shared_track(self, data):
+ joint_data = json.loads(data)
+ pos = joint_data[0]
+ color = joint_data[1]
+ self._constructors['Track'](pos, color, share=False)
+
+ def _add_shared_chain(self, data):
+ joint_data = json.loads(data)
+ pos1 = joint_data[0]
+ pos2 = joint_data[1]
+ link_length = joint_data[2]
+ radius = joint_data[3]
+ self._constructors['Chain'](pos1, pos2, link_length, radius,
+ share=False)
+
def send_event(self, text):
''' Send event through the tube. '''
if hasattr(self, 'chattube') and self.chattube is not None: