Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAntoine van Gelder <antoine@g7.org.za>2007-10-29 12:07:52 (GMT)
committer Antoine van Gelder <antoine@g7.org.za>2007-10-29 12:07:52 (GMT)
commit9600c168b8b48676da556c63cd8597d71197ad43 (patch)
treeb061ff5333782f927656987f9ba12b5a70dbca19
parentd05cdf0bf5e3ecc57dbb8f91e1e47dc453d35741 (diff)
* Re-implemted fallback for sugar.graphics.alert so that it actually works :_p
-rw-r--r--JokeMachineActivity.py46
1 files changed, 28 insertions, 18 deletions
diff --git a/JokeMachineActivity.py b/JokeMachineActivity.py
index 1e509b1..b572931 100644
--- a/JokeMachineActivity.py
+++ b/JokeMachineActivity.py
@@ -13,7 +13,7 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
-import os
+import os,sys
import logging
import gtk
@@ -48,6 +48,13 @@ from mesh.activitysession import JokeMachineSession, MESH_IFACE, MESH_PATH, MESH
from persistence.jokemachinestate import JokeMachineState
+# TODO: Handle <= Build# 622 gracefully
+try:
+ from sugar.graphics.alert import NotifyAlert
+except ImportError:
+ import sys as NotifyAlert
+
+
class JokeMachineActivity(activity.Activity):
"""Sugar activity for jokes
@@ -59,23 +66,6 @@ class JokeMachineActivity(activity.Activity):
in our world collapse with giggles of helpless laughter!
"""
- # TODO: Handle <= Build# 622 gracefully
- try:
- def alert(self, title, text=None):
- '''Show an alert above the activity.'''
- from sugar.graphics.alert import NotifyAlert
- alert = NotifyAlert(timeout=10)
- alert.props.title = title
- alert.props.msg = text
- self.add_alert(alert)
- alert.connect('response', self.__alert_cancel_cb)
- alert.show()
- def __alert_cancel_cb(self, alert, response_id):
- '''Callback for alert events'''
- self.remove_alert(alert)
- except ImportError:
- def alert(self, title, text=None):
- pass
def __init__(self, handle):
activity.Activity.__init__(self, handle)
@@ -156,6 +146,26 @@ class JokeMachineActivity(activity.Activity):
self.set_page(pages.choose.Choose)
+
+
+ def alert(self, title, text=None):
+ '''Show an alert above the activity.'''
+ if NotifyAlert is not sys:
+ alert = NotifyAlert(timeout=10)
+ alert.props.title = title
+ alert.props.msg = text
+ self.add_alert(alert)
+ alert.connect('response', self.__alert_cancel_cb)
+ alert.show()
+ else:
+ logging.warning('sugar.graphics.alert.NotifyAlert not present for %r, %r', title, text)
+
+
+ def __alert_cancel_cb(self, alert, response_id):
+ '''Callback for alert events'''
+ self.remove_alert(alert)
+
+
# Mesh Callbacks #############################################################
def __setup(self):