Frame Device icons: Palette is not drawn at the correct position

We are adding the x value twice (from the allocation and from the origin)
in get_rect of the WidgetInvoker which we derive from in the FrameInvoker.
In the toolkit-gtk2 code [1] we did add the allocation.x value when
the widget does not provide its own gtk.gdk.Window (gtk.NO_WINDOW) [2]. This
is the same check we do above if the widget has a window and we set x and y
to 0 there which sounds sane enough to me.

[1] d1f68419e7/src/sugar/graphics/palettewindow.py (line716)
[2] http://www.pygtk.org/docs/pygtk/class-gtkobject.html#method-gtkobject--flags

Signed-off-by: Simon Schampijer <simon@laptop.org>
Acked-by: Manuel Quiñones <manuq@laptop.org>
This commit is contained in:
Simon Schampijer 2012-09-12 12:44:20 +02:00
parent 9b391fa3cf
commit 5ab2b80546

View File

@ -998,24 +998,18 @@ class WidgetInvoker(Invoker):
allocation = self._widget.get_allocation()
window = self._widget.get_window()
if window is not None:
res, x, y = window.get_origin()
res_, x, y = window.get_origin()
else:
logging.warning(
"Trying to position palette with invoker that's not realized.")
x = 0
y = 0
x += allocation.x
y += allocation.y
width = allocation.width
height = allocation.height
rect = Gdk.Rectangle()
rect.x = x
rect.y = y
rect.width = width
rect.height = height
rect.width = allocation.width
rect.height = allocation.height
return rect
def has_rectangle_gap(self):