Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/GNUChessActivity.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2012-07-20 22:22:55 (GMT)
committer Walter Bender <walter.bender@gmail.com>2012-07-20 22:22:55 (GMT)
commit9698ae2baac6d7c0cfca274943c5e45d36205389 (patch)
tree3577381c202f433de8cf28957fbe44d979d3dfb3 /GNUChessActivity.py
parent41edaf53b46d78cd5f233d3dc4c0896484251f86 (diff)
mostly kid of working
Diffstat (limited to 'GNUChessActivity.py')
-rw-r--r--GNUChessActivity.py33
1 files changed, 23 insertions, 10 deletions
diff --git a/GNUChessActivity.py b/GNUChessActivity.py
index 01dc5d6..8f54185 100644
--- a/GNUChessActivity.py
+++ b/GNUChessActivity.py
@@ -242,20 +242,34 @@ class GNUChessActivity(activity.Activity):
self.fullscreen()
def _copy_cb(self, *args):
- ''' Copying as JSON data (FIXME) '''
clipboard = gtk.Clipboard()
- _logger.debug('Serialize the game and copy to clipboard.')
- text = json_dump(self._gnuchess.save_game())
- if text is not None:
- clipboard.set_text(text)
+ clipboard.set_text(self._gnuchess.copy_game())
def _paste_cb(self, *args):
- ''' Pasting from JSON data (FIXME) '''
+ ''' Pasting '''
clipboard = gtk.Clipboard()
- _logger.debug('Restore from paste')
text = clipboard.wait_for_text()
- if text is not None:
- self._gnuchess.restore_game(json_load(text))
+ # Assuming of form ... 1. e4 e6 2. ...
+ # Assuming no comments
+ move_list = []
+ found_one = False
+ for move in text.split():
+ if move == '1.':
+ found_one = True
+ number = True
+ white = False
+ elif found_one:
+ if not number:
+ number = True
+ elif not white:
+ move_list.append(move)
+ white = True
+ else:
+ move_list.append(move)
+ number = False
+ white = False
+ if move_list is not None:
+ self._gnuchess.restore_game(move_list)
def _undo_cb(self, *args):
self._gnuchess.undo()
@@ -329,7 +343,6 @@ class GNUChessActivity(activity.Activity):
if self.metadata['playing_white'] == 'False':
self.playing_white = False
self.play_black_button.set_active(True)
- self._gnuchess.reskin()
if 'playing_mode' in self.metadata:
_logger.debug(self.metadata['playing_mode'])
self.playing_mode = self.metadata['playing_mode']