From 16b5b482bd86e0bf11a0a9e1466ee0b148859fb6 Mon Sep 17 00:00:00 2001 From: Pootle daemon Date: Tue, 22 May 2012 04:32:48 +0000 Subject: Merge branch 'master' of git.sugarlabs.org:turtleart/mainline --- diff --git a/TurtleArt/talogo.py b/TurtleArt/talogo.py index 422d4f9..7e1361e 100644 --- a/TurtleArt/talogo.py +++ b/TurtleArt/talogo.py @@ -566,7 +566,7 @@ class LogoCode: self.tw.clear_plugins() if self.tw.gst_available: from tagplay import stop_media - # stop_media(self) # TODO: gplay variable + stop_media(self) self.tw.canvas.clearscreen() self.scale = DEFAULT_SCALE self.hidden_turtle = None diff --git a/TurtleArtActivity.py b/TurtleArtActivity.py index 5503482..24ed3f6 100644 --- a/TurtleArtActivity.py +++ b/TurtleArtActivity.py @@ -82,7 +82,7 @@ class TurtleArtActivity(activity.Activity): _logger.error(str(e)) self._check_ver_change(get_path(activity, 'data')) - self._setup_visibility_handler() + self.connect("notify::active", self._notify_active_cb) self.has_toolbarbox = HAS_TOOLBARBOX _logger.debug('_setup_toolbar') @@ -503,14 +503,6 @@ class TurtleArtActivity(activity.Activity): tmpfile = None return tmpfile - def __visibility_notify_cb(self, window, event): - ''' Callback method for when the activity's visibility changes. ''' - if event.state == gtk.gdk.VISIBILITY_FULLY_OBSCURED: - self.tw.background_plugins() - elif event.state in \ - [gtk.gdk.VISIBILITY_UNOBSCURED, gtk.gdk.VISIBILITY_PARTIAL]: - self.tw.foreground_plugins() - def _keep_clicked_cb(self, button): ''' Keep-button clicked. ''' self.jobject_new_patch() @@ -937,10 +929,18 @@ class TurtleArtActivity(activity.Activity): ''' Resync xy position (and orientation) of my turtle. ''' self._collaboration.send_my_xy() - def _setup_visibility_handler(self): - ''' Notify me when the visibility state changes. ''' - self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK) - self.connect('visibility-notify-event', self.__visibility_notify_cb) + def _notify_active_cb(self, widget, event): + ''' Sugar notify us that the activity is becoming active or + inactive. Notify plugins. ''' + if self.props.active: + _logger.debug('going to foreground') + self.tw.foreground_plugins() + else: + # If we go to background, stop media playing. + if self.tw.gst_available: + from TurtleArt.tagplay import stop_media + stop_media(self.tw.lc) + self.tw.background_plugins() def can_close(self): ''' Override activity class can_close inorder to notify plugins ''' -- cgit v0.9.1