summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--schemas/service-discovery-applet.schemas12
-rwxr-xr-xsrc/service-discovery-applet.in137
-rw-r--r--src/service-discovery-config.glade22
3 files changed, 48 insertions, 123 deletions
diff --git a/schemas/service-discovery-applet.schemas b/schemas/service-discovery-applet.schemas
index cc23770..f6afac6 100644
--- a/schemas/service-discovery-applet.schemas
+++ b/schemas/service-discovery-applet.schemas
@@ -14,18 +14,6 @@
</locale>
</schema>
<schema>
- <key>/schemas/apps/service-discovery-applet/options/show_applet_name</key>
- <applyto>/apps/service-discovery-applet/options/show_applet_name</applyto>
- <owner>service-discovery-applet</owner>
- <type>bool</type>
- <default>FALSE</default>
- <locale name="C">
- <short>Display the name of the applet.</short>
- <long>
- </long>
- </locale>
- </schema>
- <schema>
<key>/schemas/apps/service-discovery-applet/services/_ssh._tcp</key>
<applyto>/apps/service-discovery-applet/services/_ssh._tcp</applyto>
<owner>service-discovery-applet</owner>
diff --git a/src/service-discovery-applet.in b/src/service-discovery-applet.in
index 5b77225..ad74f70 100755
--- a/src/service-discovery-applet.in
+++ b/src/service-discovery-applet.in
@@ -15,6 +15,7 @@
# * dict([el.split('=',1) for el in l ])
import os
+import subprocess
import sys
import pygtk
pygtk.require('2.0')
@@ -76,56 +77,28 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
self.show_local_services = self.gc_client.get_bool ("%s/%s" % (self.gc_options,"show_local_services"))
self.show_notifications = self.gc_client.get_bool ("%s/%s" % (self.gc_options,"show_notifications"))
- self.show_applet_name = self.gc_client.get_bool ("%s/%s" % (self.gc_options,"show_applet_name"))
-
self.gc_client.add_dir (self.gc_services, gconf.CLIENT_PRELOAD_NONE)
self.gc_client.notify_add (self.gc_services, self.gc_services_cb,None)
+ self.gc_client.notify_add (self.gc_options, self.gc_options_cb, None)
- # Applet MenuItem
- image = gtk.Image()
- image.set_from_file("@iconsdir@/24x24/service-discovery-applet.png")
- menuZC = gtk.ImageMenuItem()
- zc_label = gtk.Label('ZeroConf')
- if self.show_applet_name == False:
- zc_label.set_no_show_all(True)
- menuZC.add(zc_label)
- menuZC.set_image(image)
- menuZC.set_right_justified(True)
- menuZC.set_submenu(self.service_menu);
-
- self.gc_client.notify_add (self.gc_options, self.gc_options_cb, zc_label)
-
- # Applet MenuBar
- gtk.rc_parse_string('''
- style "service-discovery-applet-menubar-style"
- {
- GtkMenuBar::shadow-type = none
- GtkMenuBar::internal-padding = 0
- }
- widget "*.service-discovery-applet" style "service-discovery-applet-menubar-style"''')
-
- menubar = gtk.MenuBar()
- menubar.set_name("service-discovery-applet")
- menubar.connect("button-press-event", self.on_menubar_click)
- menubar.connect("size-allocate", self.on_menubar_size_allocate)
- menubar.add(menuZC)
-
- #self.eb = gtk.EventBox()
- #self.eb.set_events(gtk.gdk.POINTER_MOTION_MASK)
- #self.eb.connect("button-press-event", self.on_button_press)
- ##self.eb.connect('motion-notify-event', self.on_applet_motion_notify_event)
- ##self.eb.connect('leave-notify-event', self.on_applet_leave_notify_event)
- #self.applet.add(self.eb)
-
- #zclabel = gtk.Label('ZeroConf')
- #self.eb.add(zclabel)
+ self.eb = gtk.EventBox()
+ self.eb.set_events(gtk.gdk.POINTER_MOTION_MASK)
+ self.eb.connect("button-press-event", self.on_button_press)
+ #self.eb.connect('motion-notify-event', self.on_applet_motion_notify_event)
+ #self.eb.connect('leave-notify-event', self.on_applet_leave_notify_event)
+
+ self.eb.connect("size-allocate", self.on_eventbox_size_allocate)
+
+ self.applet.add(self.eb)
+
+ self.image = gtk.Image()
+ self.image.set_from_file("/usr/share/service-discovery-applet/icons//24x24/service-discovery-applet.png")
+ self.eb.add(self.image)
- #expand the applet with the panel
- self.applet.connect("change_background", self.on_change_background, menubar)
- self.applet.set_applet_flags(gnomeapplet.EXPAND_MINOR)
- self.applet.add(menubar)
-
+ applet.connect("change_background", self.on_change_background)
+ applet.set_applet_flags(gnomeapplet.EXPAND_MINOR)
+
# funky right-click menu
menuXml = """
<popup name="button3">
@@ -158,14 +131,6 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
self.applet.show_all()
-
- def on_button_press(self, widget, event):
- if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
- return False
- elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
- #self.echelon.toggle_window_visible()
- print "on_button_press"
-
def siocgifname(self, interface):
if interface <= 0:
return "any"
@@ -176,8 +141,15 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
print "Service data for service '%s' of type '%s' in domain '%s' on %s.%i:" % (name, type, domain, self.siocgifname(interface), protocol)
print "\tHost %s (%s), port %i, TXT data: %s" % (host, address, port, avahi.txt_array_to_string_array(txt))
if os.path.exists("@scriptsdir@/%s.sh" % type):
- cmd = '@scriptsdir@/%s.sh "%s" %s %s %i "%s"' % (type, name, host, address, port," ".join(avahi.txt_array_to_string_array(txt)))
- os.system(cmd)
+ cmd = []
+ cmd.append("@scriptsdir@/%s.sh" % type)
+ cmd.append("%s" % name)
+ cmd.append("%s" % host)
+ cmd.append("%s" % address)
+ cmd.append("%i" % port)
+ cmd.append('%s' % " ".join(avahi.txt_array_to_string_array(txt)))
+ print cmd
+ pid = subprocess.Popen(cmd).pid
def print_error(self, err):
print "Error:", str(err)
@@ -289,42 +261,31 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
self.service_menu.remove(self.zc_types[type].get_attach_widget())
del self.zc_types[type]
+ def on_button_press(self, widget, event):
+ if event.type == gtk.gdk.BUTTON_PRESS and event.button == 3:
+ return False
+ elif event.type == gtk.gdk.BUTTON_PRESS and event.button == 1:
+ self.service_menu.show_all()
+ self.service_menu.popup(None, None, None, event.button, event.time)
+ return True
- # Callback: panel background changed
- def on_change_background(self, panelapplet, backgroundtype, color, pixmap, menubar):
- menubar.modify_bg(gtk.STATE_NORMAL, color)
-
- if backgroundtype == gnomeapplet.PIXMAP_BACKGROUND:
- print "PIXMAP_BACKGROUND"
- s3 = menubar.get_style()
- s3.bg_pixmap[gtk.STATE_NORMAL] = pixmap
-
- if backgroundtype == gnomeapplet.COLOR_BACKGROUND:
- print "COLOR_BACKGROUND"
-
- if backgroundtype == gnomeapplet.NO_BACKGROUND:
- print "NO_BACKGROUND"
-
-
-
- def on_menubar_click(self, widget, event):
- # allow Middle- and Right-Mouse-Button to go through to the applet window
- if event.button != 1:
- widget.emit_stop_by_name("button-press-event")
- return False
-
- # This little hack is required to get Fitt's Law compliance -
- # i.e. to get the Menubar to be the full height of the panel.
- def on_menubar_size_allocate(self, menubar, rect):
+ def on_eventbox_size_allocate(self, eventbox, rect):
if (rect.x <= 0) or (rect.y <= 0):
- return False
+ return False
rect.x -= 1
rect.y -= 1
rect.width += 2
rect.height += 2
- gtk.Widget.size_allocate(menubar, rect)
+ gtk.Widget.size_allocate(eventbox, rect)
return False
+ def on_change_background(self, panelapplet, backgroundtype, color, pixmap):
+ self.eb.modify_bg(gtk.STATE_NORMAL, color)
+
+ if backgroundtype == gnomeapplet.PIXMAP_BACKGROUND:
+ s = self.eb.get_style()
+ s.bg_pixmap[gtk.STATE_NORMAL] = pixmap
+
def on_about(self, component, verb, applet):
icon = gtk.Image()
icon.set_from_file("@iconsdir@/48x48/service-discovery-applet.png")
@@ -339,7 +300,7 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
about.show()
def on_config(self, component, verb, applet):
- os.system("service-discovery-config")
+ pid = subprocess.Popen(["service-discovery-config", ""]).pid
#FIXME replace with gconf key
def start_service_discovery(self, component, verb, applet):
@@ -382,14 +343,8 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet):
print "remove %s" % (service_type)
del_service_type(self.interface, self.protocol, service_type, self.domain)
- def gc_options_cb (self, client, cnxn_id, gc_entry, zc_label):
+ def gc_options_cb (self, client, cnxn_id, gc_entry):
key = os.path.basename(gc_entry.key)
- if key == "show_applet_name":
- self.show_applet_name = client.get_bool(gc_entry.key)
- if self.show_applet_name == False:
- zc_label.hide()
- else:
- zc_label.show()
if key == "show_notifications":
self.show_notifications = client.get_bool(gc_entry.key)
if key == "show_local_services":
diff --git a/src/service-discovery-config.glade b/src/service-discovery-config.glade
index 3724490..72f5c5b 100644
--- a/src/service-discovery-config.glade
+++ b/src/service-discovery-config.glade
@@ -18,6 +18,7 @@
<property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property>
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
<property name="focus_on_map">True</property>
+ <property name="urgency_hint">False</property>
<property name="has_separator">True</property>
<signal name="destroy" handler="gtk_main_quit"/>
@@ -265,6 +266,7 @@
<child>
<widget class="GtkCheckButton" id="checkbutton_local">
+ <property name="visible">True</property>
<property name="can_focus">True</property>
<property name="label">Browse for my own services.</property>
<property name="use_underline">True</property>
@@ -310,26 +312,6 @@
<property name="y_options"></property>
</packing>
</child>
-
- <child>
- <widget class="GtkCheckButton" id="checkbutton_applet_name">
- <property name="can_focus">True</property>
- <property name="label">Display applet name in the panel.</property>
- <property name="use_underline">True</property>
- <property name="relief">GTK_RELIEF_NORMAL</property>
- <property name="focus_on_click">True</property>
- <property name="active">False</property>
- <property name="inconsistent">False</property>
- <property name="draw_indicator">True</property>
- </widget>
- <packing>
- <property name="left_attach">1</property>
- <property name="right_attach">2</property>
- <property name="top_attach">3</property>
- <property name="bottom_attach">4</property>
- <property name="y_options">fill</property>
- </packing>
- </child>
</widget>
<packing>
<property name="tab_expand">False</property>