Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/alerts.py
diff options
context:
space:
mode:
authorDaniel Francis <francis@sugarlabs.org>2012-10-23 12:57:06 (GMT)
committer Daniel Francis <francis@sugarlabs.org>2012-10-23 12:57:06 (GMT)
commit9c7c915efa9d1815ea2e47f29ff549781d50c083 (patch)
tree12af6185de444135dc87573012f33afb6c8af7c9 /alerts.py
Initial commit
Moved from git.sl.org/sweetener/sweetener Signed-off-by: Daniel Francis <francis@sugarlabs.org>
Diffstat (limited to 'alerts.py')
-rw-r--r--alerts.py44
1 files changed, 44 insertions, 0 deletions
diff --git a/alerts.py b/alerts.py
new file mode 100644
index 0000000..7f90efb
--- /dev/null
+++ b/alerts.py
@@ -0,0 +1,44 @@
+# 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.
+
+import gtk
+
+import pynotify
+import info
+pynotify.init(info.name)
+
+
+class Alert(gtk.MessageDialog):
+ def __init__(self, parent, title, content, mtype):
+ gtk.MessageDialog.__init__(self, parent, gtk.DIALOG_MODAL,
+ type=mtype,
+ buttons=gtk.BUTTONS_OK)
+ self.set_markup('<b>%s</b>' % title)
+ self.format_secondary_markup(content)
+
+ 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()