diff options
-rwxr-xr-x | src/service-discovery-applet.in | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/src/service-discovery-applet.in b/src/service-discovery-applet.in index 75efdbe..7160e73 100755 --- a/src/service-discovery-applet.in +++ b/src/service-discovery-applet.in @@ -269,12 +269,29 @@ class ServiceDiscoveryApplet(gnomeapplet.Applet): self.service_menu.remove(self.zc_types[type].get_attach_widget()) del self.zc_types[type] + def position_popup_cb(self, widget): + x, y = self.applet.window.get_origin() + applet_width = self.applet.allocation.width + applet_height = self.applet.allocation.height + widget_width ,widget_height = widget.size_request() + print x, y,applet_width, applet_height,widget_height, widget_width + orientation = self.applet.get_orient() + if orientation == gnomeapplet.ORIENT_UP: + y -= widget_height + elif orientation == gnomeapplet.ORIENT_DOWN: + y += applet_height + elif orientation == gnomeapplet.ORIENT_LEFT: + x -= widget_width + elif orientation == gnomeapplet.ORIENT_RIGHT: + x += applet_width + return (x, y, True) + 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) + self.service_menu.popup(None, None, self.position_popup_cb, event.button, event.time) return True def on_eventbox_size_allocate(self, eventbox, rect): |