diff options
author | Sebastien Estienne <sebastien.estienne@gmail.com> | 2005-08-30 22:55:02 +0000 |
---|---|---|
committer | Sebastien Estienne <sebastien.estienne@gmail.com> | 2005-08-30 22:55:02 +0000 |
commit | 06e3c9cd349fbeb0ab9be97146bd8498feacdc26 (patch) | |
tree | 03a6a67eb51d788f722c2da809da2ce93330528d | |
parent | de1b7aaa445ceb712b1a1b7a6d79ec9225ef74d9 (diff) |
* added support for libnotify
* add 24x24 and 48x48 icons
git-svn-id: file:///home/lennart/svn/public/service-discovery-applet/trunk@6 3be567f1-68ff-0310-b24a-ad7cc433fd2f
-rw-r--r-- | configure.ac | 4 | ||||
-rw-r--r-- | icons/24x24/Makefile.am | 9 | ||||
-rw-r--r-- | icons/24x24/_ftp._tcp.png (renamed from icons/_ftp._tcp.png) | bin | 1283 -> 1283 bytes | |||
-rw-r--r-- | icons/24x24/_http._tcp.png (renamed from icons/_http._tcp.png) | bin | 1580 -> 1580 bytes | |||
-rw-r--r-- | icons/24x24/_ipp._tcp.png (renamed from icons/_ipp._tcp.png) | bin | 1015 -> 1015 bytes | |||
-rw-r--r-- | icons/24x24/_ssh._tcp.png (renamed from icons/_ssh._tcp.png) | bin | 1077 -> 1077 bytes | |||
-rw-r--r-- | icons/24x24/_workstation._tcp.png (renamed from icons/_workstation._tcp.png) | bin | 887 -> 887 bytes | |||
-rw-r--r-- | icons/24x24/service-discovery-applet.png (renamed from icons/service-discovery-applet-mini.png) | bin | 1615 -> 1615 bytes | |||
-rw-r--r-- | icons/48x48/Makefile.am | 8 | ||||
-rw-r--r-- | icons/48x48/_ftp._tcp.png | bin | 0 -> 3252 bytes | |||
-rw-r--r-- | icons/48x48/_http._tcp.png | bin | 0 -> 2647 bytes | |||
-rw-r--r-- | icons/48x48/_ssh._tcp.png | bin | 0 -> 2847 bytes | |||
-rw-r--r-- | icons/48x48/service-discovery-applet.png (renamed from icons/service-discovery-applet.png) | bin | 4314 -> 4314 bytes | |||
-rw-r--r-- | icons/Makefile.am | 12 | ||||
-rwxr-xr-x | src/service-discovery-applet.in | 92 |
15 files changed, 88 insertions, 37 deletions
diff --git a/configure.ac b/configure.ac index 859badc..3d9ad87 100644 --- a/configure.ac +++ b/configure.ac @@ -22,8 +22,10 @@ AC_CONFIG_FILES([ Makefile common/Makefile src/Makefile - icons/Makefile scripts/Makefile servers/Makefile + icons/Makefile + icons/24x24/Makefile + icons/48x48/Makefile ]) AC_OUTPUT diff --git a/icons/24x24/Makefile.am b/icons/24x24/Makefile.am new file mode 100644 index 0000000..ba674c8 --- /dev/null +++ b/icons/24x24/Makefile.am @@ -0,0 +1,9 @@ +iconsdir = $(ICONSDIR)/24x24 +icons_DATA = \ + _http._tcp.png \ + _ftp._tcp.png \ + _ssh._tcp.png \ + service-discovery-applet.png + + +EXTRA_DIST = $(icons_DATA) diff --git a/icons/_ftp._tcp.png b/icons/24x24/_ftp._tcp.png Binary files differindex 05dbdd2..05dbdd2 100644 --- a/icons/_ftp._tcp.png +++ b/icons/24x24/_ftp._tcp.png diff --git a/icons/_http._tcp.png b/icons/24x24/_http._tcp.png Binary files differindex a16d002..a16d002 100644 --- a/icons/_http._tcp.png +++ b/icons/24x24/_http._tcp.png diff --git a/icons/_ipp._tcp.png b/icons/24x24/_ipp._tcp.png Binary files differindex dd814d6..dd814d6 100644 --- a/icons/_ipp._tcp.png +++ b/icons/24x24/_ipp._tcp.png diff --git a/icons/_ssh._tcp.png b/icons/24x24/_ssh._tcp.png Binary files differindex 2fe2d14..2fe2d14 100644 --- a/icons/_ssh._tcp.png +++ b/icons/24x24/_ssh._tcp.png diff --git a/icons/_workstation._tcp.png b/icons/24x24/_workstation._tcp.png Binary files differindex da2896e..da2896e 100644 --- a/icons/_workstation._tcp.png +++ b/icons/24x24/_workstation._tcp.png diff --git a/icons/service-discovery-applet-mini.png b/icons/24x24/service-discovery-applet.png Binary files differindex bbda895..bbda895 100644 --- a/icons/service-discovery-applet-mini.png +++ b/icons/24x24/service-discovery-applet.png diff --git a/icons/48x48/Makefile.am b/icons/48x48/Makefile.am new file mode 100644 index 0000000..35a9583 --- /dev/null +++ b/icons/48x48/Makefile.am @@ -0,0 +1,8 @@ +iconsdir = $(ICONSDIR)/48x48 +icons_DATA = \ + _http._tcp.png \ + _ftp._tcp.png \ + _ssh._tcp.png \ + service-discovery-applet.png + +EXTRA_DIST = $(icons_DATA) diff --git a/icons/48x48/_ftp._tcp.png b/icons/48x48/_ftp._tcp.png Binary files differnew file mode 100644 index 0000000..dfce09a --- /dev/null +++ b/icons/48x48/_ftp._tcp.png diff --git a/icons/48x48/_http._tcp.png b/icons/48x48/_http._tcp.png Binary files differnew file mode 100644 index 0000000..a2e157a --- /dev/null +++ b/icons/48x48/_http._tcp.png diff --git a/icons/48x48/_ssh._tcp.png b/icons/48x48/_ssh._tcp.png Binary files differnew file mode 100644 index 0000000..e56fa2e --- /dev/null +++ b/icons/48x48/_ssh._tcp.png diff --git a/icons/service-discovery-applet.png b/icons/48x48/service-discovery-applet.png Binary files differindex 2876b96..2876b96 100644 --- a/icons/service-discovery-applet.png +++ b/icons/48x48/service-discovery-applet.png diff --git a/icons/Makefile.am b/icons/Makefile.am index 3ee98ee..17b6cb6 100644 --- a/icons/Makefile.am +++ b/icons/Makefile.am @@ -1,9 +1,3 @@ -iconsdir = $(ICONSDIR) -icons_DATA = \ - _http._tcp.png \ - _ftp._tcp.png \ - _ssh._tcp.png \ - service-discovery-applet.png \ - service-discovery-applet-mini.png - -EXTRA_DIST = $(icons_DATA) +SUBDIRS = \ + 24x24 \ + 48x48 diff --git a/src/service-discovery-applet.in b/src/service-discovery-applet.in index 8270c08..bb71b9d 100755 --- a/src/service-discovery-applet.in +++ b/src/service-discovery-applet.in @@ -87,16 +87,16 @@ def menuitem_response(widget, interface, protocol, name, type, domain): server.ResolveService(interface, protocol, name, type, domain, avahi.PROTO_UNSPEC, reply_handler=service_resolved, error_handler=print_error) def new_service(interface, protocol, name, type, domain): - global server, service_menu, zc_types, zc_pretty_name, zc_services + global server, service_menu, zc_types, zc_pretty_name, zc_services, notif print "Found service '%s' of type '%s' in domain '%s' on %s.%i." % (name, type, domain, siocgifname(interface), protocol) - + if zc_types.has_key(type) == False: menuitem = gtk.ImageMenuItem() if zc_pretty_name.has_key(type): menuitem.add(gtk.Label(zc_pretty_name[type])) img = gtk.Image() - iconfile = "@iconsdir@/%s.png" % (type) + iconfile = "@iconsdir@/24x24/%s.png" % (type) img.set_from_file(iconfile) menuitem.set_image(img) else: @@ -113,11 +113,20 @@ def new_service(interface, protocol, name, type, domain): menuitem.connect("activate", menuitem_response,interface, protocol, name, type, domain) menuitem.show_all() - # Asynchronous resolving - #server.ResolveService(interface, protocol, name, type, domain, avahi.PROTO_UNSPEC, reply_handler=service_resolved, error_handler=print_error) + iconfile = "@iconsdir@/48x48/%s.png" % (type) + message = "<b>Name :</b> %s\n<b>Type : </b> %s <i>(%s)</i>" % (name,zc_pretty_name[type], type) + try: + notif.Notify("Service Discovery Applet", + iconfile, dbus.UInt32(0),"",dbus.Byte(0), + "New Service found",message, + [iconfile],[""],[""],True,dbus.UInt32(3)) + except: + print "can't use notification daemon" + pass + def remove_service(interface, protocol, name, type, domain): - global zc_services + global zc_services,notif print "Service '%s' of type '%s' in domain '%s' on %s.%i disappeared." % (name, type, domain, siocgifname(interface), protocol) @@ -126,9 +135,20 @@ def remove_service(interface, protocol, name, type, domain): if zc_types[type].get_children() == []: service_menu.remove(zc_types[type].get_attach_widget()) del zc_types[type] + + iconfile = "@iconsdir@/48x48/%s.png" % (type) + message = "<b>Name :</b> %s\n<b>Type : </b> %s <i>(%s)</i>" % (name,zc_pretty_name[type], type) + try: + notif.Notify("Service Discovery Applet", + iconfile, dbus.UInt32(0),"",dbus.Byte(0), + "Service disappeared",message, + [iconfile],[""],[""],True,dbus.UInt32(3)) + except: + print "can't use notification daemon" + pass def new_service_type(interface, protocol, type, domain): - global server, service_browsers + global server, service_browsers, system_bus # Are we already browsing this domain for this type? if service_browsers.has_key((interface, protocol, type, domain)): @@ -136,7 +156,7 @@ def new_service_type(interface, protocol, type, domain): print "Browsing for services of type '%s' in domain '%s' on %s.%i ..." % (type, domain, siocgifname(interface), protocol) - b = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.ServiceBrowserNew(interface, protocol, type, domain)), avahi.DBUS_INTERFACE_SERVICE_BROWSER) + b = dbus.Interface(system_bus.get_object(avahi.DBUS_NAME, server.ServiceBrowserNew(interface, protocol, type, domain)), avahi.DBUS_INTERFACE_SERVICE_BROWSER) b.connect_to_signal('ItemNew', new_service) b.connect_to_signal('ItemRemove', remove_service) @@ -155,21 +175,6 @@ def new_domain(interface, protocol, domain): browse_domain(interface, protocol, domain) -bus = dbus.SystemBus() -server = dbus.Interface(bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), avahi.DBUS_INTERFACE_SERVER) - -if domain is None: - # Explicitly browse .local - browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "local") - - # Browse for other browsable domains - db = dbus.Interface(bus.get_object(avahi.DBUS_NAME, server.DomainBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "", avahi.DOMAIN_BROWSER_BROWSE)), avahi.DBUS_INTERFACE_DOMAIN_BROWSER) - db.connect_to_signal('ItemNew', new_domain) - -else: - # Just browse the domain the user wants us to browse - browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, domain) - def on_menubar_click(widget, event): # allow Middle- and Right-Mouse-Button to go through to the applet window if event.button != 1: @@ -179,7 +184,8 @@ def on_menubar_click(widget, event): def ServiceDiscoveryApplet_factory(applet, iid): - global menuZC + global menuZC, system_bus, server, session_bus, domain, notif + print "Creating new applet instance" menubar = gtk.MenuBar() menubar.connect("button-press-event", on_menubar_click) @@ -187,7 +193,7 @@ def ServiceDiscoveryApplet_factory(applet, iid): menuZC = gtk.ImageMenuItem() menuZC.add(gtk.Label('ZeroConf')) img = gtk.Image() - img.set_from_file("@iconsdir@/service-discovery-applet-mini.png") + img.set_from_file("@iconsdir@/24x24/service-discovery-applet.png") menuZC.set_image(img) menuZC.set_right_justified(True) menubar.add(menuZC) @@ -197,11 +203,43 @@ def ServiceDiscoveryApplet_factory(applet, iid): applet.add(menubar) applet.show_all() + + + system_bus = dbus.SystemBus() + server = dbus.Interface(system_bus.get_object(avahi.DBUS_NAME, avahi.DBUS_PATH_SERVER), + avahi.DBUS_INTERFACE_SERVER) + + if domain is None: + # Explicitly browse .local + try: + browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "local") + except: + print "Can't connect to Avahi." + sys.exit(0) + + # Browse for other browsable domains + sdb = server.DomainBrowserNew(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, "", avahi.DOMAIN_BROWSER_BROWSE) + obj = system_bus.get_object(avahi.DBUS_NAME, sdb) + db = dbus.Interface(obj, avahi.DBUS_INTERFACE_DOMAIN_BROWSER) + db.connect_to_signal('ItemNew', new_domain) + + else: + # Just browse the domain the user wants us to browse + try: + browse_domain(avahi.IF_UNSPEC, avahi.PROTO_UNSPEC, domain) + except: + print "Can't connect to Avahi." + sys.exit(0) + + session_bus = dbus.SessionBus() + obj = session_bus.get_object("org.freedesktop.Notifications", "/org/freedesktop/Notifications") + notif = dbus.Interface(obj, "org.freedesktop.Notifications") return True -print "Starting factory" +print "Starting Service Discovery Applet" + if __name__ == '__main__': if len(sys.argv) == 2 and sys.argv[1] == "-window": main_window = gtk.Window(gtk.WINDOW_TOPLEVEL) @@ -218,4 +256,4 @@ if __name__ == '__main__': gnomeapplet.Applet.__gtype__, "Service discovery applet", "0", ServiceDiscoveryApplet_factory) -print "Factory ended" +print "Service Discovery Applet ended" |