From 4e75964c7d73a2f763728c0858e0a6130cd456a5 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Fri, 07 Oct 2011 12:24:04 +0000 Subject: consolidation of remote turtle positioning code --- diff --git a/TurtleArt/tacollaboration.py b/TurtleArt/tacollaboration.py index e1534a4..8316c7a 100644 --- a/TurtleArt/tacollaboration.py +++ b/TurtleArt/tacollaboration.py @@ -232,7 +232,7 @@ class Collaboration(): self._get_colors() event_payload = data_to_string(self._tw.remote_turtle_dictionary) self.send_event('T|' + event_payload) - self._send_my_xy() # And the sender should report her xy position. + self.send_my_xy() # And the sender should report her xy position. def _receive_turtle_dict(self, payload): ''' Any time there is a new joiner, an updated turtle dictionary is @@ -260,10 +260,11 @@ class Collaboration(): debug_output('%s already in remote turtle dictionary' \ % (nick), self._tw.running_sugar) self.waiting_for_turtles = False - self._send_my_xy() + self.send_my_xy() - def _send_my_xy(self): - ''' Set xy location so joiner can sync turtle positions. ''' + def send_my_xy(self): + ''' Set xy location so joiner can sync turtle positions. Should be + used to sync positions after turtle drag. ''' self._tw.canvas.set_turtle(self._get_nick()) if self._tw.canvas.pendown: self.send_event('p|%s' % (data_to_string([self._get_nick(), diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py index 3395b48..861122f 100644 --- a/TurtleArtActivity.py +++ b/TurtleArtActivity.py @@ -733,6 +733,10 @@ class TurtleArtActivity(activity.Activity): self._collaboration = Collaboration(self.tw, self) self._collaboration.setup() + def send_xy(self): + ''' Resync xy position (and orientation) of my turtle. ''' + self._collaboration.send_my_xy() + def _setup_visibility_handler(self): ''' Notify me when the visibility state changes. ''' self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK) diff --git a/gnome_plugins/collaboration_plugin.py b/gnome_plugins/collaboration_plugin.py index 19c084b..4ba98a5 100644 --- a/gnome_plugins/collaboration_plugin.py +++ b/gnome_plugins/collaboration_plugin.py @@ -133,6 +133,10 @@ class Collaboration_plugin(Plugin): return neighborhood_menu + def send_xy(self): + ''' Resync xy position (and orientation) of my turtle. ''' + self._collaboration.send_my_xy() + def get_colors(self): return self._colors -- cgit v0.9.1