From f825c108da2250981e46ae3d62709ef570a51d49 Mon Sep 17 00:00:00 2001 From: Marco Pesenti Gritti Date: Fri, 29 Jun 2007 12:56:12 +0000 Subject: Use size request to position the palette. --- diff --git a/sugar/graphics/palette.py b/sugar/graphics/palette.py index 380e1ec..8ec3f4b 100644 --- a/sugar/graphics/palette.py +++ b/sugar/graphics/palette.py @@ -122,40 +122,40 @@ class Palette(gobject.GObject): def _get_position(self, alignment): # Invoker: x, y, width and height inv_rect = self._invoker.get_rect() - palette_rect = self._menu.get_allocation() + palette_width, palette_height = self._menu.size_request() if alignment == _BOTTOM_LEFT: x = inv_rect.x y = inv_rect.y + inv_rect.height elif alignment == _BOTTOM_RIGHT: - x = (inv_rect.x + inv_rect.width) - palette_rect.width + x = (inv_rect.x + inv_rect.width) - palette_width y = inv_rect.y + inv_rect.height elif alignment == _LEFT_BOTTOM: - x = inv_rect.x - palette_rect.width + x = inv_rect.x - palette_width y = inv_rect.y elif alignment == _LEFT_TOP: - x = inv_rect.x - palette_rect.width - y = (inv_rect.y + inv_rect.height) - palette_rect.height + x = inv_rect.x - palette_width + y = (inv_rect.y + inv_rect.height) - palette_height elif alignment == _RIGHT_BOTTOM: x = inv_rect.x + inv_rect.width y = inv_rect.y elif alignment == _RIGHT_TOP: x = inv_rect.x + inv_rect.width - y = (inv_rect.y + inv_rect.height) - palette_rect.height + y = (inv_rect.y + inv_rect.height) - palette_height elif alignment == _TOP_LEFT: x = inv_rect.x - y = inv_rect.y - palette_rect.height + y = inv_rect.y - palette_height elif alignment == _TOP_RIGHT: - x = (inv_rect.x + inv_rect.width) - palette_rect.width - y = inv_rect.y - palette_rect.height + x = (inv_rect.x + inv_rect.width) - palette_width + y = inv_rect.y - palette_height return x, y def _in_screen(self, x, y): - allocation = self._menu.get_allocation() + [width, height] = self._menu.get_size_request() - return x + allocation.width < gtk.gdk.screen_width() and \ - y + allocation.height < gtk.gdk.screen_height() and \ + return x + width < gtk.gdk.screen_width() and \ + y + height < gtk.gdk.screen_height() and \ x >= 0 and y >= 0 def _get_automatic_position(self): -- cgit v0.9.1