summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastien Estienne <sebastien.estienne@gmail.com>2007-02-25 13:48:35 +0000
committerSebastien Estienne <sebastien.estienne@gmail.com>2007-02-25 13:48:35 +0000
commitb8e740b1eaf3058457b6f50e200e28d5beefa3de (patch)
tree9c0df32fe91ccfb80aad26bb11a153fa3b9f5f78
parent6174bddd1c36a8f637e2667a29987cdb71414991 (diff)
bump version / refactor some part of the code
git-svn-id: file:///home/lennart/svn/public/service-discovery-applet/trunk@130 3be567f1-68ff-0310-b24a-ad7cc433fd2f
-rw-r--r--CHANGELOG5
-rw-r--r--configure.ac2
-rwxr-xr-xsrc/service-discovery-applet.in100
3 files changed, 53 insertions, 54 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 1ecfb26..b9fab40 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+* 0.4.4
+- fixed issues with python 2.5
+- display visual error message when dbus is unavailable
+- use pynotify (apt-get install python-notify)
+
* 0.4.3
- fixed zombie with gconf-terminal
- fixed sftp with gconf-terminal
diff --git a/configure.ac b/configure.ac
index f8ce0ca..73155ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
AC_PREREQ(2.59)
-AC_INIT([service-discovery-applet],[0.4.3],[sebastien (dot) estienne (at) gmail (dot) com])
+AC_INIT([service-discovery-applet],[0.4.4],[sebastien (dot) estienne (at) gmail (dot) com])
AC_CONFIG_SRCDIR([src/service-discovery-applet.in])
AM_INIT_AUTOMAKE([foreign 1.9 -Wall])
AC_CONFIG_MACRO_DIR([common])
diff --git a/src/service-discovery-applet.in b/src/service-discovery-applet.in
index e9b5955..55655c1 100755
--- a/src/service-discovery-applet.in
+++ b/src/service-discovery-applet.in
@@ -134,51 +134,6 @@ class SDAGconf:
###############################################################################
#
-# NOTIFICATIONS
-#
-class Notifications:
- def __init__(self, applet):
- if not pynotify.init(_("Zeroconf Service Discovery")):
- print "Notification disable."
- self.applet.show_notifications = False
- self.applet = applet
-
-
- def display_service_notification(self, new, name, type):
- 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)
- message = _("<b>Name :</b> %s\n<b>Type : </b> %s <i>(%s)</i>") % (name, h_type, type)
-
- if new == True:
- 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:
- 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"
- raise
-
-
-###############################################################################
-#
# SERVIDE DISCOVERY APPLET MAIN CLASS
#
class ServiceDiscoveryApplet(gnomeapplet.Applet):
@@ -249,7 +204,9 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
except:
self.use_host_names = False
- self.sdaNotifications = Notifications(self)
+ if not pynotify.init(_("Zeroconf Service Discovery")):
+ error_msg(_("<b>Notification Daemon Error:</b>\n Notifications won't work."))
+ self.applet.show_notifications = False
self.start_service_discovery(None, None, None)
@@ -271,6 +228,43 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
###############################################################################
#
+# NOTIFICATIONS
+#
+ def display_service_notification(self, new, name, type):
+ 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)
+ message = _("<b>Name :</b> %s\n<b>Type : </b> %s <i>(%s)</i>") % (name, h_type, type)
+
+ if new == True:
+ 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.show_notifications == True:
+ 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
+
+
+###############################################################################
+#
# AVAHI
#
def siocgifname(self, interface):
@@ -333,14 +327,14 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
menuitem.connect("activate", self.menuitem_response,interface, protocol, name, type, domain)
menuitem.show_all()
- self.sdaNotifications.display_service_notification(True, name, type)
+ self.display_service_notification(True, name, type)
def remove_service(self, interface, protocol, name, type, domain, flags):
print "Service '%s' of type '%s' in domain '%s' on %s.%i disappeared." % (name, type, domain, self.siocgifname(interface), protocol)
if self.zc_services.has_key((interface, protocol, name, type, domain)):
self.zc_types[type].remove(self.zc_services[(interface, protocol, name, type, domain)])
- self.sdaNotifications.display_service_notification(False, name, type)
+ self.display_service_notification(False, name, type)
if self.zc_types[type].get_children() == []:
self.service_menu.remove(self.zc_types[type].get_attach_widget())
@@ -416,15 +410,15 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
def start_service_discovery(self, component, verb, applet):
if len(self.domain) != 0:
print "domain not null %s" % (self.domain)
- self.sdaNotifications.display_notification(_("Already Discovering"),"")
+ self.display_notification(_("Already Discovering"),"")
return
try:
self.domain = self.server.GetDomainName()
except:
- self.sdaNotifications.display_notification(_("Error Detected!"),_("Check that the Avahi daemon is running!"))
+ self.display_notification(_("Error Detected!"),_("Check that the Avahi daemon is running!"))
return
- self.sdaNotifications.display_notification(_("Starting discovery"),"")
+ self.display_notification(_("Starting discovery"),"")
self.interface = avahi.IF_UNSPEC
self.protocol = avahi.PROTO_INET
@@ -439,13 +433,13 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
def stop_service_discovery(self, component, verb, applet):
if len(self.domain) == 0:
- self.sdaNotifications.display_notification(_("Discovery already stopped"),"")
+ self.display_notification(_("Discovery already stopped"),"")
return
for service in self.service_browsers.copy():
self.del_service_type(service[0],service[1],service[2],service[3])
self.domain = ""
- self.sdaNotifications.display_notification(_("Discovery stopped"),"")
+ self.display_notification(_("Discovery stopped"),"")
###############################################################################