From: anishmangal2002@gmail.com
To: sugar-devel@lists.sugarlabs.org
Cc: bernie@codewiz.org, anishmangal2002 <anishmangal2002@gmail.com>
Subject: [PATCH] Add NotifyRedAlert inherited from NotifyAlert
Date: Mon, 14 Jun 2010 02:51:23 +0530

Adds the NotifyRedAlert class which is an alert inherited from
 NotifyAlert. When the alert message is displayed, it glows the
alert bar Red before slowly fading out to black, thus resulting
in a more visible notification.

Signed-off-by: anishmangal2002 <anishmangal2002@gmail.com>
---
 src/sugar/graphics/alert.py |   46 +++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/sugar/graphics/alert.py b/src/sugar/graphics/alert.py
index 4441909..b4dfee1 100644
--- a/src/sugar/graphics/alert.py
+++ b/src/sugar/graphics/alert.py
@@ -432,3 +432,49 @@ class NotifyAlert(Alert):
             self._response(gtk.RESPONSE_OK)
             return False
         return True
+
+class NotifyRedAlert(NotifyAlert):
+    """
+    Timeout alert with only an "OK" button and a glowing Red border- just for notifications
+
+    Examples
+    --------
+
+    .. code-block:: python
+      from sugar.graphics.alert import NotifyRedAlert
+      ...
+        #### Method: _alert_notify, create a NotifyRed alert (with only an 'OK'
+                     button)
+        # and add it to the UI.
+        def _alert_notify(self):
+            #Notice that for a NotifyRedAlert, you pass the number of seconds in
+            #which to notify. By default, this is 5.
+            alert = NotifyRedAlert(10)
+            alert.props.title=_('Title of Alert Goes Here')
+            alert.props.msg = _('Text message of notify alert goes here')
+            alert.connect('response', self._alert_response_cb)
+            self.add_alert(alert)
+
+    """
+
+    def __init__(self, timeout=5, **kwargs):
+        NotifyAlert.__init__(self, timeout, **kwargs)
+        self.saturation = 255
+
+        gobject.timeout_add(20, self.__modify_color_timeout)
+
+    def __modify_color_timeout(self):
+        if self.saturation:
+            self.saturation -= 1
+
+            # Form the hex color representation
+            if self.saturation <= 15:
+                color = '#0%s0000' % hex(self.saturation)[2:]
+            else:
+                color = '#%s0000' % hex(self.saturation)[2:]
+        else:
+            return False
+
+        self.modify_bg( gtk.STATE_NORMAL,  gtk.gdk.Color(color))
+        self.show()
+        return True
-- 
1.7.0.4


