Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoranishmangal2002 <anishmangal2002@gmail.com>2010-06-14 02:21:23 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2010-08-10 17:46:38 (GMT)
commit3f68813dd667a3da4064072b4adac15ca1ad5b57 (patch)
treee62aa18351fd74f1322be85c18f0f565e21793f8
parent4fdf632c1864d8b108520f1a2eda48f42deed942 (diff)
Add ErrorAlert inherited from Alert
Adds the ErrorAlert class which is an alert inherited from the base Alert class. This is very similar to the ConfirmationAlert class with the difference being that it only displays an 'Ok' button in the Alert popup. Signed-off-by: anishmangal2002 <anishmangal2002@gmail.com>
-rw-r--r--src/sugar/graphics/alert.py45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/sugar/graphics/alert.py b/src/sugar/graphics/alert.py
index 4441909..a4dd017 100644
--- a/src/sugar/graphics/alert.py
+++ b/src/sugar/graphics/alert.py
@@ -28,6 +28,7 @@ create a simple alert message.
STABLE.
"""
# Copyright (C) 2007, One Laptop Per Child
+# Copyright (C) 2010, Anish Mangal <anishmangal2002@gmail.com>
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
@@ -290,6 +291,50 @@ class ConfirmationAlert(Alert):
self.add_button(gtk.RESPONSE_OK, _('Ok'), icon)
icon.show()
+class ErrorAlert(Alert):
+ """
+ This is a ready-made one button (Ok) alert.
+
+ An error alert is a nice shortcut from a standard Alert because it
+ comes with the 'OK' button already built-in. When clicked, the
+ 'OK' button will emit a response with a response_id of gtk.RESPONSE_OK.
+
+ Examples
+ --------
+
+ .. code-block:: python
+ from sugar.graphics.alert import ErrorAlert
+ ...
+ #### Method: _alert_error, create a Error alert (with ok
+ button standard)
+ # and add it to the UI.
+ def _alert_error(self):
+ alert = ErrorAlert()
+ alert.props.title=_('Title of Alert Goes Here')
+ alert.props.msg = _('Text message of alert goes here')
+ alert.connect('response', self._alert_response_cb)
+ self.add_alert(alert)
+
+
+ #### Method: _alert_response_cb, called when an alert object throws a
+ response event.
+ def _alert_response_cb(self, alert, response_id):
+ #remove the alert from the screen, since either a response button
+ #was clicked or there was a timeout
+ self.remove_alert(alert)
+
+ #Do any work that is specific to the response_id.
+ if response_id is gtk.RESPONSE_OK:
+ print 'Ok Button was clicked. Do any work upon ok here ...'
+
+ """
+
+ def __init__(self, **kwargs):
+ Alert.__init__(self, **kwargs)
+
+ icon = Icon(icon_name='dialog-ok')
+ self.add_button(gtk.RESPONSE_OK, _('Ok'), icon)
+ icon.show()
class _TimeoutIcon(hippo.CanvasText, hippo.CanvasItem):
"""An icon with a round border"""