Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafael Ortiz <rafael@activitycentral.com>2012-12-19 15:19:55 (GMT)
committer Rafael Ortiz <rafael@activitycentral.com>2012-12-19 15:19:55 (GMT)
commit8a6127cf8ef9f94f8c640caa9f9e262ccb3d5524 (patch)
tree4f640d983af7dc4603bd7202c87340bc1187121d
parentf0ece64d68676ab4418da872205450ff823515e8 (diff)
Matching activity.py with mainline
-rw-r--r--activity.py35
1 files changed, 33 insertions, 2 deletions
diff --git a/activity.py b/activity.py
index 3e9f71f..461de84 100644
--- a/activity.py
+++ b/activity.py
@@ -53,6 +53,7 @@ import createtoolbar
import cardlist
import createcardpanel
import face
+import time
SERVICE = 'org.laptop.Memorize'
IFACE = SERVICE
@@ -69,6 +70,7 @@ _MODE_CREATE = 2
changed_strings = [_('Play'), _('Create'), _('Game name:'), _('Equal pairs'),
_('addition'), _('letters'), _('sounds')]
+
class MemorizeActivity(Activity):
def __init__(self, handle):
@@ -106,7 +108,7 @@ class MemorizeActivity(Activity):
# Play game mode
self.table = cardtable.CardTable()
self.scoreboard = scoreboard.Scoreboard()
- self.cardlist = cardlist.CardList()
+ self.cardlist = cardlist.CardList(self)
self.createcardpanel = createcardpanel.CreateCardPanel()
self.cardlist.connect('pair-selected',
self.createcardpanel.pair_selected)
@@ -122,9 +124,11 @@ class MemorizeActivity(Activity):
self.cardlist.clean_list)
self._createToolbarBuilder.connect('create_new_game',
self.createcardpanel.clean)
+ self._createToolbarBuilder.connect('create_new_game',
+ self._memorizeToolbarBuilder.reset)
self._createToolbarBuilder.connect('create_equal_pairs',
self.change_equal_pairs)
- self.game = game.MemorizeGame()
+ self.game = game.MemorizeGame(self)
self._edit_button.connect('toggled', self._change_mode_bt)
@@ -212,6 +216,7 @@ class MemorizeActivity(Activity):
self.game.add_buddy(self.owner)
else:
self.game.add_buddy(self.owner)
+
self.show_all()
def _change_mode_bt(self, button):
@@ -233,12 +238,17 @@ class MemorizeActivity(Activity):
self.metadata['title'], color)
def write_file(self, file_path):
+ # Wait for graphics events finish
+ self.flush_events()
logging.debug('WRITE_FILE is_demo %s', self.game.model.is_demo)
+ # We want to save the game-image for demo games too !!!
+ """
if self.game.model.is_demo:
# if is a demo game only want keep the metadata
self._jobject.set_file_path(None)
raise NotImplementedError
return
+ """
if self.cardlist.pair_list_modified:
self.cardlist.update_model(self.game.model)
@@ -287,6 +297,13 @@ class MemorizeActivity(Activity):
game_zip.close()
self.metadata['mime_type'] = 'application/x-memorize-project'
+ # Store the game image as a string - that is simpler instead of
+ # having to deal with the dbus-converted list.
+ # When reading back, we use "eval" to convert the string into
+ # the correct type ("list" in this case).
+ self.metadata['saved_game_data_image'] = str(self.game.model.grid)
+ self.metadata['size'] = int(self.game.model.data['size'])
+
def _complete_close(self):
self._remove_temp_files()
Activity._complete_close(self)
@@ -462,3 +479,17 @@ class MemorizeActivity(Activity):
def _cleanup_cb(self, data=None):
self.game.audio.stop()
+
+ def getToolbarBox(self):
+ """ Get toolbar box
+ """
+ return self._toolbar
+
+ def flush_events(self):
+ """ Wait for graphics events finish
+ """
+ gtk.gdk.threads_enter()
+ while gtk.events_pending():
+ gtk.main_iteration(True)
+ gtk.gdk.flush()
+ gtk.gdk.threads_leave()