Ahem, and here are the actual patches.

On Wed, Nov 5, 2008 at 3:08 PM, Tomeu Vizoso <[EMAIL PROTECTED]> wrote:
> Hi,
>
> here are two patches to XoIRC:
>
> 0001-Fix-windows.patch
>
> windows.py  and widgets.py references each other, so windows cannot
> use a constant from widgets in its method declaration.
>
> 0002-Emit-a-notification-when-someone-addresses-to-us-and.patch
>
> Send a (very simple) notification when a message addressed to us
> arrives and the activity is not visible.
>
> Thanks,
>
> Tomeu
>
From 75ff5b4d66f06633b2bb758168aee870695e7f82 Mon Sep 17 00:00:00 2001
From: Tomeu Vizoso <[EMAIL PROTECTED]>
Date: Wed, 5 Nov 2008 15:01:07 +0100
Subject: [PATCH] Fix windows

---
 purk/windows.py |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/purk/windows.py b/purk/windows.py
index 6223469..26064f9 100644
--- a/purk/windows.py
+++ b/purk/windows.py
@@ -65,7 +65,9 @@ class Window(gtk.VBox):
             self.input.set_position(-1)
             self.input.event(event)
         
-    def write(self, text, activity_type=widgets.EVENT, line_ending='\n', fg=None):
+    def write(self, text, activity_type=None, line_ending='\n', fg=None):
+        if activity_type is None:
+            activity_type = widgets.EVENT
         if self.manager.get_active() != self:
             self.activity = activity_type
         self.output.write(text, line_ending, fg)
-- 
1.5.6.3

From 0edadc1a9905e877ecd2e1c3a0b9ffeb611b2afd Mon Sep 17 00:00:00 2001
From: Tomeu Vizoso <[EMAIL PROTECTED]>
Date: Wed, 5 Nov 2008 15:02:21 +0100
Subject: [PATCH] Emit a notification when someone addresses to us and the activity is not visible

---
 .gitignore                   |    3 +++
 purk/scripts/notification.py |   26 ++++++++++++++++++++++++++
 xoircactivity.py             |   10 ++++++++++
 3 files changed, 39 insertions(+), 0 deletions(-)
 create mode 100644 .gitignore
 create mode 100644 purk/scripts/notification.py

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..95401e0
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,3 @@
+*.pyc
+*.pyo
+*~
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)
+
diff --git a/xoircactivity.py b/xoircactivity.py
index 2a4cce3..9afe900 100644
--- a/xoircactivity.py
+++ b/xoircactivity.py
@@ -32,6 +32,12 @@ class XoIRCActivity(activity.Activity):
         logging.debug('Starting the XoIRC Activity')
         self.set_title(_('Xo IRC Activity'))
 
+        self.add_events(gtk.gdk.VISIBILITY_NOTIFY_MASK)
+        self.connect('visibility-notify-event',
+                     self.__visibility_notify_event_cb)
+
+        self.is_visible = False
+
         client = purk.Client()
         client.add_channel('#olpc-help')
         client.join_server('irc.freenode.net')
@@ -45,3 +51,7 @@ class XoIRCActivity(activity.Activity):
         toolbox = activity.ActivityToolbox(self)
         self.set_toolbox(toolbox)
         self.show_all()
+
+    def __visibility_notify_event_cb(self, window, event):
+        self.is_visible = event.state != gtk.gdk.VISIBILITY_FULLY_OBSCURED
+
-- 
1.5.6.3

_______________________________________________
Sugar mailing list
Sugar@lists.laptop.org
http://lists.laptop.org/listinfo/sugar

Reply via email to