diff -Naur cgmail-9999/idir/cgmail.schemas cgmail_awn/idir/cgmail.schemas
--- cgmail-9999/idir/cgmail.schemas 2007-05-04 23:10:06.000000000 -0700
+++ cgmail_awn/idir/cgmail.schemas 2007-05-04 23:12:30.000000000 -0700
@@ -89,5 +89,34 @@
+
+ /schemas/apps/cgmail/awn_enabled
+ /apps/cgmail/awn_enabled
+ cgmail
+ bool
+ 0
+
+ Enable notifications to Avant Window Navigator
+
+ Enable notifications to be sent to Avant Window Navigator
+ Please set the name of the application on whose icon you
+ want to display the number of new mails in the key awn_application_name
+
+
+
+
+ /schemas/apps/cgmail/awn_application_name
+ /apps/cgmail/awn_application_name
+ cgmail
+ string
+ evolution
+
+ Application name for AWN notifications
+
+ Name of the application on whose icon you want to display
+ the number of new mails.
+
+
+
diff -Naur cgmail-9999/src/checker.py cgmail_awn/src/checker.py
--- cgmail-9999/src/checker.py 2007-05-04 23:10:06.000000000 -0700
+++ cgmail_awn/src/checker.py 2007-05-04 23:13:19.000000000 -0700
@@ -250,11 +250,14 @@
self.notifier = Notifier()
self.checkers = {} # checker, account_id
self.checking = False
- self.status_cb = None
+ self.status_cbs = []
- def set_status_cb(self, cb):
- self.status_cb = cb
+ def add_status_cb(self, cb):
+ self.status_cbs.append(cb)
+ def remove_status_cb(self,cb):
+ self.status_cbs.remove(cb)
+
def set_no_accounts_cb(self, cb):
self.no_accounts_cb = cb
@@ -410,12 +413,14 @@
if message != "":
self.notifier.notify(title, message, msec = 10000)
- if self.status_cb is not None:
- self.status_cb(total, title, message)
+ #if self.status_cb is not None:
+ for cb in self.status_cbs:
+ cb(total, title, message)
else:
# only update count
- if self.status_cb is not None:
- self.status_cb(total, None, None)
+ #if self.status_cb is not None:
+ for cb in self.status_cbs:
+ cb(total, None, None)
self.checking = False
diff -Naur cgmail-9999/src/mainloop.py cgmail_awn/src/mainloop.py
--- cgmail-9999/src/mainloop.py 2007-05-04 23:10:06.000000000 -0700
+++ cgmail_awn/src/mainloop.py 2007-05-04 23:13:19.000000000 -0700
@@ -13,6 +13,7 @@
import gobject
from statusicon import StatusIcon
+from statusawn import StatusAWN
from gconfhelper import GconfHelper
from dbusinterface import CgmailDbusService
@@ -26,6 +27,11 @@
statusicon = StatusIcon(self.checker, self.stop)
self.gconf_helper = GconfHelper()
+
+ if self.gconf_helper.get_key("awn_enabled") == True:
+ print "Enabling AWN notifications"
+ awn_app_name = self.gconf_helper.get_key("awn_application_name")
+ self.statusawn = StatusAWN(self.checker, awn_app_name)
# start dbus service
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
diff -Naur cgmail-9999/src/statusawn.py cgmail_awn/src/statusawn.py
--- cgmail-9999/src/statusawn.py 1969-12-31 16:00:00.000000000 -0800
+++ cgmail_awn/src/statusawn.py 2007-05-04 23:13:19.000000000 -0700
@@ -0,0 +1,37 @@
+#import gtk
+#import gtk.glade
+#import gobject
+
+#import os
+#import thread
+
+#from common import *
+#from accountswindow import AccountsWindow
+#from preferencesdialog import PreferencesDialog
+#from gconfhelper import GconfHelper
+#import utils
+
+import dbus
+
+class StatusAWN:
+ def __init__(self, checker, app_name):
+
+ self.checker = checker
+ self.app_name = app_name
+ self.checker.add_status_cb(self.set_status)
+
+ self.awn = None
+
+ def set_status(self, mcount, title, message):
+ if self.awn is None:
+ try:
+ bus = dbus.SessionBus()
+ obj = bus.get_object("com.google.code.Awn", "/com/google/code/Awn")
+ self.awn = dbus.Interface(obj, "com.google.code.Awn")
+ except dbus.DBusException:
+ print "DBUS error while trying to communicate with AWN. Is it running?"
+
+ if mcount > 0:
+ self.awn.SetInfoByName (self.app_name, "%s" % mcount)
+ else:
+ self.awn.UnsetInfoByName (self.app_name)
diff -Naur cgmail-9999/src/statusicon.py cgmail_awn/src/statusicon.py
--- cgmail-9999/src/statusicon.py 2007-05-04 23:10:06.000000000 -0700
+++ cgmail_awn/src/statusicon.py 2007-05-04 23:13:19.000000000 -0700
@@ -23,7 +23,7 @@
def __init__(self, checker, stop_cb):
self.checker = checker
- self.checker.set_status_cb(self.set_status)
+ self.checker.add_status_cb(self.set_status)
self.checker.init_checkers(self.no_config)
self.stop_main_loop = stop_cb