diff options
author | Simon Schampijer <simon@schampijer.de> | 2007-07-27 16:06:03 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@schampijer.de> | 2007-07-27 16:06:03 (GMT) |
commit | 2fea25d3d1233e56f92b0d0ca6eee51eee749270 (patch) | |
tree | 3e644bcc93042fc56aa2c1c9c352d5f0393b2579 | |
parent | ae8fd1350a9c6b90f3bf7c63f7822a2b9f728dff (diff) |
Free the audio device when not in focus
We free the audio device and stop the csound performance
when not visible and start it again when in focus. This
allows to have several instances on one machine.
Commented out to printouts in the svgcard.
-rwxr-xr-x | activity.py | 21 | ||||
-rwxr-xr-x | svgcard.py | 4 |
2 files changed, 22 insertions, 3 deletions
diff --git a/activity.py b/activity.py index bb8c101..849f87a 100755 --- a/activity.py +++ b/activity.py @@ -95,9 +95,13 @@ class MemorizeActivity(Activity): self.show_all() + # connect to the in/out events of the memorize activity + self.connect('focus_in_event', self._focus_in) + self.connect('focus_out_event', self._focus_out) + self.connect('destroy', self._cleanup_cb) + # Get the Presence Service self.pservice = presenceservice.get_instance() - bus = dbus.Bus() name, path = self.pservice.get_preferred_connection() self.tp_conn_name = name self.tp_conn_path = path @@ -270,3 +274,18 @@ class MemorizeActivity(Activity): else: _logger.debug("buddy left - _buddy_left_cb: %s", buddy.props.nick) self.game.rem_buddy(buddy) + + def _focus_in(self, event, data=None): + if self.game.sound == 1: + self.game.cs.start() + _logger.debug(" Memorize is visible: start csound server. ") + + def _focus_out(self, event, data=None): + if self.game.sound == 1: + self.game.cs.pause() + _logger.debug(" Memorize is invisible: pause csound server. ") + + def _cleanup_cb(self, data=None): + if self.game.sound == 1: + self.game.cs.quit() + _logger.debug(" Memorize closes: close csound server. ") @@ -86,7 +86,7 @@ class SvgCard(gtk.DrawingArea): self.back_layout = self.get_text_layout(self.props['back_text'].get('card_text',''), self.size-12) self.back_layout_position = (self.size -(self.back_layout.get_size()[1]/1000))/2 - print str(self.props['back_text']) + # print str(self.props['back_text']) if build_all or self.pprops.has_key('back_border') or self.pprops.has_key('back_text'): self.cache['back'] = self.build_face('back') @@ -238,7 +238,7 @@ class SvgCard(gtk.DrawingArea): self.flop() def get_text_layout(self, text, size): - _logger.error('Text: '+text) + #_logger.error('Text: '+text) if self.size == 184: font_sizes = [50,40,26,20,17,13,11,8] elif self.size == 145: |