From b8e740b1eaf3058457b6f50e200e28d5beefa3de Mon Sep 17 00:00:00 2001 From: Sebastien Estienne Date: Sun, 25 Feb 2007 13:48:35 +0000 Subject: 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 --- CHANGELOG | 5 ++ configure.ac | 2 +- src/service-discovery-applet.in | 100 +++++++++++++++++++--------------------- 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 @@ -132,51 +132,6 @@ class SDAGconf: if len(status) != 0: self.applet.start_service_discovery(None,None,None) -############################################################################### -# -# 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 = _("Name : %s\nType : %s (%s)") % (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 @@ -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(_("Notification Daemon Error:\n Notifications won't work.")) + self.applet.show_notifications = False self.start_service_discovery(None, None, None) @@ -269,6 +226,43 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet): self.show_notifications = self.sdaGconf.get_option("show_notifications") +############################################################################### +# +# 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 = _("Name : %s\nType : %s (%s)") % (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 @@ -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"),"") ############################################################################### -- cgit