Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/FractionBounceActivity.py
diff options
context:
space:
mode:
authorWalter Bender <walter.bender@gmail.com>2011-10-06 02:16:11 (GMT)
committer Walter Bender <walter.bender@gmail.com>2011-10-06 02:16:11 (GMT)
commitceb7277dc2cc515811e8e11ff1375d73877b0a56 (patch)
tree5aadb9df65ce7bb2a79186fe8952a92710ed0216 /FractionBounceActivity.py
parent9dbe3b393c732fb784c764f0d818120024ef5e1d (diff)
partial implementation of pause when window obscured
Diffstat (limited to 'FractionBounceActivity.py')
-rw-r--r--FractionBounceActivity.py19
1 files changed, 19 insertions, 0 deletions
diff --git a/FractionBounceActivity.py b/FractionBounceActivity.py
index 65ce75b..5ad6de0 100644
--- a/FractionBounceActivity.py
+++ b/FractionBounceActivity.py
@@ -81,6 +81,9 @@ class FractionBounceActivity(activity.Activity):
""" Initiate activity. """
super(FractionBounceActivity, self).__init__(handle)
+ self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
+ self.connect('visibility-notify-event', self.__visibility_notify_cb)
+
# no sharing
self.max_participants = 1
@@ -147,3 +150,19 @@ class FractionBounceActivity(activity.Activity):
self.challenge.set_label(_("Bounce the ball to a position %(fraction)s \
of the way from the left side of the bar.") \
% {'fraction': fraction})
+
+ def __visibility_notify_cb(self, window, event):
+ ''' Callback method for when the activity's visibility changes. '''
+ _logger.debug('%s', str(event.state))
+ return
+
+ ''' The event is always be UNOBSCURED so commented out for now '''
+ if event.state == gtk.gdk.VISIBILITY_FULLY_OBSCURED:
+ _logger.debug('pause it')
+ self.bounce_window.pause()
+ elif event.state in \
+ [gtk.gdk.VISIBILITY_UNOBSCURED, gtk.gdk.VISIBILITY_PARTIAL]:
+ if not self.bounce_window.paused:
+ _logger.debug('unpause it')
+ self.bounce_window.paused = True
+ self.challenge.set_label(_("Click the ball to continue"))