diff options
author | Daniel Francis <francis@sugarlabs.org> | 2012-10-17 23:03:17 (GMT) |
---|---|---|
committer | Daniel Francis <francis@sugarlabs.org> | 2012-10-17 23:03:17 (GMT) |
commit | 3c00452b30c713f78e3c0279c4fbf9006e573f7c (patch) | |
tree | 6d511aea3a24fa9666bac522891f57926bcd0a90 | |
parent | 7f916a79cbf173d27d9f11c74eb2484beb5840e5 (diff) |
Display NotifyAlerts
Signed-off-by: Daniel Francis <francis@sugarlabs.org>
-rw-r--r-- | desktop/sweetener/alerts.py | 13 | ||||
-rw-r--r-- | options.py | 6 | ||||
-rw-r--r-- | sugar/sweetener/alerts.py | 19 |
3 files changed, 38 insertions, 0 deletions
diff --git a/desktop/sweetener/alerts.py b/desktop/sweetener/alerts.py index 809855c..7f90efb 100644 --- a/desktop/sweetener/alerts.py +++ b/desktop/sweetener/alerts.py @@ -17,6 +17,10 @@ import gtk +import pynotify +import info +pynotify.init(info.name) + class Alert(gtk.MessageDialog): def __init__(self, parent, title, content, mtype): @@ -29,3 +33,12 @@ class Alert(gtk.MessageDialog): def run(self): gtk.MessageDialog.run(self) gtk.MessageDialog.destroy(self) + + +class NotifyAlert(pynotify.Notification): + def __init__(self, parent, title, content, icon, timeout): + pynotify.Notification.__init__(self, title, message=content, icon=icon) + self.set_timeout(timeout) + + def run(self): + self.show() @@ -29,6 +29,7 @@ from sweetener.coloritem import ColorItem from sweetener.radioitem import RadioItem from sweetener.settingsitem import SettingsItem from sweetener.alerts import Alert +from sweetener.alerts import NotifyAlert class Options(ItemBox): @@ -55,6 +56,7 @@ class Options(ItemBox): notify_alert.show() content.show() simple_alert.connect('clicked', self.simple_alert) + notify_alert.connect('clicked', self.notify_alert) self.alerts.content = content self.canvas_ghost.append_item(self.alerts) self.canvas_ghost.append_separator(True) @@ -85,3 +87,7 @@ class Options(ItemBox): def simple_alert(self, widget): alert = Alert(self.activity, _('Simple Alert'), _('Message'), gtk.MESSAGE_INFO) self.activity.add_alert(alert) + + def notify_alert(self, widget): + alert = NotifyAlert(self.activity, _('Notify Alert'), _('Message'), None, 10) + self.activity.add_alert(alert) diff --git a/sugar/sweetener/alerts.py b/sugar/sweetener/alerts.py index 60de0c4..86d3351 100644 --- a/sugar/sweetener/alerts.py +++ b/sugar/sweetener/alerts.py @@ -19,9 +19,11 @@ from gettext import gettext as _ import gtk from sugar.graphics import style from sugar.graphics.alert import Alert as SugarAlert +from sugar.graphics.alert import NotifyAlert as SugarNotify from icon import Icon + class Alert(SugarAlert): def __init__(self, parent, title, content, mtype): SugarAlert.__init__(self) @@ -40,3 +42,20 @@ class Alert(SugarAlert): def remove_myself(self, widget=None, response=None): self._parent.remove_alert(self) + + +class NotifyAlert(SugarNotify): + def __init__(self, parent, title, content, icon, timeout): + SugarNotify.__init__(self, timeout) + self._parent = parent + self.props.title = title + self.props.msg = content + if icon != None: + icon = Icon(icon_name=icon) + icon.show() + self.props.icon = icon + icon.props.pixel_size = style.SMALL_ICON_SIZE * 2 + self.connect('response', self.remove_myself) + + def remove_myself(self, widget=None, response=None): + self._parent.remove_alert(self) |