Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/activity.py
diff options
context:
space:
mode:
Diffstat (limited to 'activity.py')
-rwxr-xr-xactivity.py40
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."""