From 2bbf4f654ab32b899f591475601d5d1a2571cc4f Mon Sep 17 00:00:00 2001 From: Sebastien Estienne Date: Sun, 2 Oct 2005 15:13:35 +0000 Subject: * make the event box behave like a menubar and handle gnome-panel position git-svn-id: file:///home/lennart/svn/public/service-discovery-applet/trunk@28 3be567f1-68ff-0310-b24a-ad7cc433fd2f --- src/service-discovery-applet.in | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) 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): -- cgit