diff options
author | Manuel Kaufmann <humitos@gmail.com> | 2012-11-09 20:10:14 (GMT) |
---|---|---|
committer | Rafael Ortiz <rafael@activitycentral.com> | 2012-11-20 15:53:10 (GMT) |
commit | f209d7278be9e4a1a0c0f13bc268fac7e8e6f049 (patch) | |
tree | 28ae25d51c4bbfbace359311659f0648da0e7f9c | |
parent | fa3cd4b64b203b4480cfef3600825a20dcc33d80 (diff) |
Collaboration fixed SL #3747
A bug regarding collaboration was intruced in this commit[1] when the
toolbar was modified to show the correct icons. In the same commit the
call to 'olpcgames.PygameActivity.build_toolbar' was removed and the
collaboration setup was done there.
I copied the code that setup the collaboration from
'olpcgames.PygameActivity.build_toolbar' to
'activity.MazeActivity.__init__'.
[1] http://git.sugarlabs.org/maze/mainline/commit/87f832850ba242b1606acb0f1d60bc5631920f34
Signed-off-by: Manuel Kaufmann <humitos@gmail.com>
-rwxr-xr-x | activity.py | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/activity.py b/activity.py index 4afbf56..127e73f 100755 --- a/activity.py +++ b/activity.py @@ -1,9 +1,13 @@ # -*- coding: utf-8 -*- +import logging import olpcgames import pygame import gtk +from olpcgames import mesh +from olpcgames import util + from sugar.activity.widgets import ActivityToolbarButton from sugar.activity.widgets import StopButton from sugar.graphics.toolbarbox import ToolbarBox @@ -16,6 +20,42 @@ class MazeActivity(olpcgames.PyGameActivity): game_title = _('Maze') game_size = None # Let olpcgames pick a nice size for us + def __init__(self, handle): + super(MazeActivity, self).__init__(handle) + + # This code was copied from olpcgames.activity.PyGameActivity + def shared_cb(*args, **kwargs): + logging.info('shared: %s, %s', args, kwargs) + try: + mesh.activity_shared(self) + except Exception, err: + logging.error('Failure signaling activity sharing' + 'to mesh module: %s', util.get_traceback(err)) + else: + logging.info('mesh activity shared message sent,' + ' trying to grab focus') + try: + self._pgc.grab_focus() + except Exception, err: + logging.warn('Focus failed: %s', err) + else: + logging.info('asserting focus') + assert self._pgc.is_focus(), \ + 'Did not successfully set pygame canvas focus' + logging.info('callback finished') + + def joined_cb(*args, **kwargs): + logging.info('joined: %s, %s', args, kwargs) + mesh.activity_joined(self) + self._pgc.grab_focus() + self.connect('shared', shared_cb) + self.connect('joined', joined_cb) + + if self.get_shared(): + # if set at this point, it means we've already joined (i.e., + # launched from Neighborhood) + joined_cb() + def build_toolbar(self): """Build our Activity toolbar for the Sugar system.""" |