From 6174bddd1c36a8f637e2667a29987cdb71414991 Mon Sep 17 00:00:00 2001 From: Sebastien Estienne Date: Sun, 25 Feb 2007 13:30:32 +0000 Subject: now using pynotify git-svn-id: file:///home/lennart/svn/public/service-discovery-applet/trunk@129 3be567f1-68ff-0310-b24a-ad7cc433fd2f --- src/service-discovery-applet.in | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/service-discovery-applet.in b/src/service-discovery-applet.in index 65da2b0..e9b5955 100755 --- a/src/service-discovery-applet.in +++ b/src/service-discovery-applet.in @@ -45,6 +45,7 @@ try: import gnomeapplet import gnome.ui import gconf + import pynotify import avahi.ServiceTypeDatabase except ImportError, e: error_msg(_("A required python module is missing!\n%s") % (e)) @@ -137,22 +138,19 @@ class SDAGconf: # class Notifications: def __init__(self, applet): - try: - self.session_bus = dbus.SessionBus() - obj = self.session_bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") - self.notif = dbus.Interface(obj, "org.freedesktop.Notifications") - except dbus.DBusException, e: - error_msg(_("DBus Error:\nCan't contact the session bus.\n\nNotifications won't work!")) + if not pynotify.init(_("Zeroconf Service Discovery")): + print "Notification disable." self.applet.show_notifications = False - pprint.pprint(e) - pass self.applet = applet def display_service_notification(self, new, name, type): - iconfile = "file://@iconsdir@/48x48/%s.png" % (type) - if not os.path.exists(iconfile): + iconfile_path = "@iconsdir@/48x48/%s.png" % (type) + print iconfile_path + if not os.path.exists(iconfile_path): iconfile = "file://@iconsdir@/48x48/service-discovery-applet.png" + else: + iconfile ="file://%s" % iconfile_path stdb = ServiceTypeDatabase() h_type = stdb.get_human_type(type) @@ -162,18 +160,21 @@ class Notifications: title = _("New service found") else: title = _("Service disappeared") - + self.display_notification(title, message, iconfile) def display_notification(self, title, message, iconfile = "file://@iconsdir@/48x48/service-discovery-applet.png"): try: if self.applet.show_notifications == True: - self.notif.Notify(_("Zeroconf Service Discovery"), - dbus.UInt32(0), iconfile, title, message, - [], [], dbus.Int32(3000), dbus.UInt32(0)) + n = pynotify.Notification(title, message, iconfile) +# x, y = self.applet.window.get_origin() +# n.set_hint("x",x) +# n.set_hint("y",y) +# n.attach_to_widget(self.applet.window) + n.show() except: print "can't use notification daemon" - pass + raise ############################################################################### -- cgit