Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-12-08 02:56:08 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-12-08 02:56:08 (GMT)
commitaced049e81bbe11ef7417aebebac25693226f82a (patch)
tree8d9a1b2e1fa1681e0f40d77c65a9bd7eaf241b16
parent93e9daca8bf8b42f9d968319c01bfd40ecabaa0a (diff)
sorted out last details re share
-rw-r--r--ReflectionActivity.py13
-rw-r--r--game.py10
2 files changed, 17 insertions, 6 deletions
diff --git a/ReflectionActivity.py b/ReflectionActivity.py
index 1147436..43194c7 100644
--- a/ReflectionActivity.py
+++ b/ReflectionActivity.py
@@ -28,6 +28,7 @@ from toolbar_utils import button_factory, label_factory, separator_factory
from utils import json_load, json_dump
import telepathy
+import dbus
from dbus.service import signal
from dbus.gobject_service import ExportedGObject
from sugar.presence import presenceservice
@@ -51,7 +52,11 @@ class ReflectionActivity(activity.Activity):
def __init__(self, handle):
""" Initialize the toolbars and the game board """
- super(ReflectionActivity, self).__init__(handle)
+ try:
+ super(ReflectionActivity, self).__init__(handle)
+ except dbus.exceptions.DBusException, e:
+ _logger.error(str(e))
+
self.nick = profile.get_nick_name()
if profile.get_color() is not None:
self.colors = profile.get_color().to_string().split(',')
@@ -59,6 +64,7 @@ class ReflectionActivity(activity.Activity):
self.colors = ['#A0FFA0', '#FF8080']
self._setup_toolbars(_have_toolbox)
+ self._setup_dispatch_table()
# Create a canvas
canvas = gtk.DrawingArea()
@@ -69,6 +75,7 @@ class ReflectionActivity(activity.Activity):
self.show_all()
self._game = Game(canvas, parent=self, colors=self.colors)
+ self._setup_presence_service()
if 'dotlist' in self.metadata:
self._restore()
@@ -135,7 +142,7 @@ class ReflectionActivity(activity.Activity):
def write_file(self, file_path):
""" Write the grid status to the Journal """
- (dot_list, orientation) = self._game.save_game()
+ [dot_list, orientation] = self._game.save_game()
self.metadata['orientation'] = orientation
self.metadata['dotlist'] = ''
for dot in dot_list:
@@ -255,7 +262,7 @@ params=%r state=%d' % (id, initiator, type, service, params, state))
def _receive_new_game(self, payload):
''' Sharer can start a new game. '''
- (dot_list, orientation) = json_load(payload)
+ [dot_list, orientation] = json_load(payload)
self._game.restore_game(dot_list, orientation)
def send_dot_click(self, dot, color):
diff --git a/game.py b/game.py
index eceb215..9dd5c05 100644
--- a/game.py
+++ b/game.py
@@ -47,7 +47,7 @@ class Game():
self._canvas = canvas
if parent is not None:
parent.show_all()
- self._patent = parent
+ self._parent = parent
self._canvas.set_flags(gtk.CAN_FOCUS)
self._canvas.add_events(gtk.gdk.BUTTON_PRESS_MASK)
@@ -141,6 +141,7 @@ class Game():
self._colors[self._dots[n].type]))
if self.we_are_sharing:
+ _logger.debug('sending a new game')
self._parent.send_new_game()
def restore_game(self, dot_list, orientation):
@@ -149,6 +150,7 @@ class Game():
self._dots[i].type = dot
self._dots[i].set_shape(self._new_dot(
self._colors[self._dots[i].type]))
+ self._orientation = orientation
self._set_orientation()
def save_game(self):
@@ -157,7 +159,7 @@ class Game():
dot_list = []
for dot in self._dots:
dot_list.append(dot.type)
- return (dot_list, self._orientation)
+ return [dot_list, self._orientation]
def _set_label(self, string):
''' Set the label in the toolbar or the window frame. '''
@@ -178,6 +180,7 @@ class Game():
self._test_game_over()
if self.we_are_sharing:
+ _logger.debug('sending a click to the share')
self._parent.send_dot_click(self._dots.index(spr),
spr.type)
return True
@@ -185,9 +188,10 @@ class Game():
def remote_button_press(self, dot, color):
''' Receive a button press from a sharer '''
self._dots[dot].type = color
- self._dots.set_shape(self._new_dot(self._colors[color]))
+ self._dots[dot].set_shape(self._new_dot(self._colors[color]))
def set_sharing(self, share=True):
+ _logger.debug('enabling sharing')
self.we_are_sharing = share
def _test_game_over(self):