Bert Freudenberg wrote:
Hi folks,

is there a notification of activation / deactivation for an activity? Or do I have to watch X11 events when matchbox shuffles windows back and forth?


Activity is a GtkWindow so you can listen of focus-in/focus-out. See the attached patch for an example. This way you will get activated/deactivated also when switching to the home page or the zoom view temporarily though. And I'm not sure if that's what we actually want. I need to talk with Eben about it.

I noticed etoys is happily animating and playing sounds even if it is not the top activity, which is most likely not desired.

Is there a general policy of background activity? I guess the chat, for example, would continue to receive messages even when not at top. An animation should be stopped if nobody sees it. But what about a longer-running simulation? Or some time-lapse data measuring from the analogue input?

We should probably have a policy for this in our (planned) activity guidelines. Can you open a ticket about this and assign it to me please?

Thanks,
Marco
diff --git a/activities/groupchat/GroupChatActivity.py b/activities/groupchat/GroupChatActivity.py
index 32cfac5..0cb3e66 100644
--- a/activities/groupchat/GroupChatActivity.py
+++ b/activities/groupchat/GroupChatActivity.py
@@ -1,3 +1,5 @@
+import sys
+
 from gettext import gettext as _
 
 from sugar.activity.Activity import Activity
@@ -6,3 +8,12 @@ class GroupChatActivity(Activity):
 	def __init__(self):
 		Activity.__init__(self)
 		self.set_title(_('Group chat'))
+
+		self.connect('focus-in-event', self._focus_in_cb)
+		self.connect('focus-out-event', self._focus_out_cb)
+
+	def _focus_in_cb(self, window, event):
+		print >> sys.stderr, 'Activated'
+
+	def _focus_out_cb(self, window, event):
+		print >> sys.stderr, 'Deactivated'
_______________________________________________
Sugar mailing list
[email protected]
http://mailman.laptop.org/mailman/listinfo/sugar

Reply via email to