diff options
author | Daniel Francis <francis@sugarlabs.org> | 2012-10-09 14:04:31 (GMT) |
---|---|---|
committer | Daniel Francis <francis@sugarlabs.org> | 2012-10-09 14:04:31 (GMT) |
commit | 7f916a79cbf173d27d9f11c74eb2484beb5840e5 (patch) | |
tree | 85ef69c055e44195197b0c432d5a5468e8630698 | |
parent | d091144d4770c70a74a233890346daefa4f188b8 (diff) |
Show simple alerts
-rwxr-xr-x | application.py | 4 | ||||
-rw-r--r-- | desktop/sweetener/alerts.py | 6 | ||||
-rw-r--r-- | sugar/sweetener/alerts.py | 42 |
3 files changed, 48 insertions, 4 deletions
diff --git a/application.py b/application.py index 0b584ce..89961c9 100755 --- a/application.py +++ b/application.py @@ -159,9 +159,7 @@ class Application(gtk.Window): self._unfullscreen_button.hide() def add_alert(self, alert): - if type(alert) == Alert: - alert.run() - alert.destroy() + alert.run() def fullscreen(self): self.options.hide() diff --git a/desktop/sweetener/alerts.py b/desktop/sweetener/alerts.py index 0b0be66..809855c 100644 --- a/desktop/sweetener/alerts.py +++ b/desktop/sweetener/alerts.py @@ -23,5 +23,9 @@ class Alert(gtk.MessageDialog): gtk.MessageDialog.__init__(self, parent, gtk.DIALOG_MODAL, type=mtype, buttons=gtk.BUTTONS_OK) - self.set_markup('<b>Title</b>') + self.set_markup('<b>%s</b>' % title) self.format_secondary_markup(content) + + def run(self): + gtk.MessageDialog.run(self) + gtk.MessageDialog.destroy(self) diff --git a/sugar/sweetener/alerts.py b/sugar/sweetener/alerts.py new file mode 100644 index 0000000..60de0c4 --- /dev/null +++ b/sugar/sweetener/alerts.py @@ -0,0 +1,42 @@ +# Copyright (C) 2012 S. Daniel Francis <francis@sugarlabs.org> +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, +# MA 02110-1301, USA. + +from gettext import gettext as _ +import gtk +from sugar.graphics import style +from sugar.graphics.alert import Alert as SugarAlert + +from icon import Icon + +class Alert(SugarAlert): + def __init__(self, parent, title, content, mtype): + SugarAlert.__init__(self) + self._parent = parent + if mtype == gtk.MESSAGE_INFO: + icon = Icon(icon_name='emblem-notification') + icon.show() + self.props.icon = icon + icon.props.pixel_size = style.SMALL_ICON_SIZE * 2 + self.props.title = title + self.props.msg = content + ok_icon = Icon(icon_name='dialog-ok') + self.add_button(gtk.RESPONSE_OK, _('Ok'), ok_icon) + ok_icon.show() + self.connect('response', self.remove_myself) + + def remove_myself(self, widget=None, response=None): + self._parent.remove_alert(self) |