summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Estienne <sebastien.estienne@gmail.com>2007-02-25 13:30:32 +0000
committerSebastien Estienne <sebastien.estienne@gmail.com>2007-02-25 13:30:32 +0000
commit6174bddd1c36a8f637e2667a29987cdb71414991 (patch)
treecb65ec366de4c83f17f718128666de7f0a82f815
parent9e6147312711d30978b18961b44d8ec308f4c790 (diff)
now using pynotify
git-svn-id: file:///home/lennart/svn/public/service-discovery-applet/trunk@129 3be567f1-68ff-0310-b24a-ad7cc433fd2f
-rwxr-xr-xsrc/service-discovery-applet.in31
1 files 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(_("<b>DBus Error:</b>\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
###############################################################################