From 3f782a1454664a5f8c4f76fab1af1e0bb87b96bd Mon Sep 17 00:00:00 2001
From: anishmangal2002 <anishmangal2002@gmail.com>
Date: Mon, 14 Jun 2010 02:21:23 +0000
Subject: [PATCH] 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>
---
 src/sugar/graphics/alert.py |   44 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 44 insertions(+), 0 deletions(-)

diff --git a/src/sugar/graphics/alert.py b/src/sugar/graphics/alert.py
index 4441909..4dfa515 100644
--- a/src/sugar/graphics/alert.py
+++ b/src/sugar/graphics/alert.py
@@ -290,6 +290,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"""
-- 
1.7.0.1

