Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorSimon Schampijer <simon@schampijer.de>2007-10-25 12:04:04 (GMT)
committer Simon Schampijer <simon@schampijer.de>2007-10-25 12:04:04 (GMT)
commit176262f2e9357c08735bbd4476327fc92d8d5827 (patch)
treeb2c4d6c58f8729ec21cda4170c579da72bcda767 /lib
parentf60f77d471a2b919d2f4071e7e3d7e9a9e4ff805 (diff)
Added morgs NotifyAlert (timed one button alert) to the alert api
Diffstat (limited to 'lib')
-rw-r--r--lib/sugar/graphics/alert.py33
1 files changed, 30 insertions, 3 deletions
diff --git a/lib/sugar/graphics/alert.py b/lib/sugar/graphics/alert.py
index dd1bcec..ef649b2 100644
--- a/lib/sugar/graphics/alert.py
+++ b/lib/sugar/graphics/alert.py
@@ -32,9 +32,8 @@ class Alert(gtk.EventBox, gobject.GObject):
Alerts are used inside the activity window instead of being a
separate popup window. They do not hide canvas content. You can
use add_alert(widget) and remove_alert(widget) inside your activity
- to add and remove the alert. You can set the position (bottom=-1,
- top=0,1) for alerts global for the window by changing alert_position,
- default is bottom.
+ to add and remove the alert. The position of the alert is below the
+ toolbox or top in fullscreen mode.
Properties:
'title': the title of the alert,
@@ -225,3 +224,31 @@ class TimeoutAlert(Alert):
self._response(gtk.RESPONSE_OK)
return False
return True
+
+
+class NotifyAlert(Alert):
+ """Timeout alert with only an "OK" button - just for notifications"""
+
+ def __init__(self, timeout=5, **kwargs):
+ Alert.__init__(self, **kwargs)
+
+ self._timeout = timeout
+
+ self._timeout_text = _TimeoutIcon(
+ text=self._timeout,
+ color=style.COLOR_BUTTON_GREY.get_int(),
+ background_color=style.COLOR_WHITE.get_int())
+ canvas = hippo.Canvas()
+ canvas.set_root(self._timeout_text)
+ canvas.show()
+ self.add_button(gtk.RESPONSE_OK, _('OK'), canvas)
+
+ gobject.timeout_add(1000, self.__timeout)
+
+ def __timeout(self):
+ self._timeout -= 1
+ self._timeout_text.props.text = self._timeout
+ if self._timeout == 0:
+ self._response(gtk.RESPONSE_OK)
+ return False
+ return True