Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@tomeuvizoso.net>2008-12-03 18:15:05 (GMT)
committer Tomeu Vizoso <tomeu@tomeuvizoso.net>2008-12-03 18:15:05 (GMT)
commit9981107374a8e6e1b58225f91613ec09b2b491c7 (patch)
tree0836d452fa3aad40bdc2e6ad79644e4d9a605d77
parentac7a0c7be9699beccb32ef652af1353fb8a5de58 (diff)
Actually add the script that emits the notifications
-rw-r--r--purk/scripts/notification.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/purk/scripts/notification.py b/purk/scripts/notification.py
new file mode 100644
index 0000000..c4b7c8d
--- /dev/null
+++ b/purk/scripts/notification.py
@@ -0,0 +1,26 @@
+import logging
+import os
+
+import dbus
+
+from sugar.activity import activity
+
+session_bus = dbus.SessionBus()
+
+notifications_object = session_bus.get_object('org.freedesktop.Notifications', '/org/freedesktop/Notifications')
+notifications_interface = dbus.Interface(notifications_object, 'org.freedesktop.Notifications')
+
+_notification_id = 0
+
+def onText(e):
+ activity_instance = e.window.get_toplevel()
+ if activity_instance.is_visible:
+ return
+
+ if e.network.me in e.text:
+ global _notification_id
+ icon_path = os.path.join(activity.get_bundle_path(), 'activity',
+ 'activity-ircchat.svg')
+ _notification_id = notifications_interface.Notify('', _notification_id,
+ '', '', '', [], {'x-sugar-icon-file-name': icon_path}, -1)
+