Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorEduardo Silva <edsiper@monotop.(none)>2007-07-06 14:51:18 (GMT)
committer Eduardo Silva <edsiper@monotop.(none)>2007-07-06 14:51:18 (GMT)
commitec929eb0ad5bb740f0eb5436ebc7a9e15a55f517 (patch)
treeea3b386e8c1249ada85a712e7c2e3463f687ad01 /sugar
parent739dbafa97525f3a92425fbaf0033d2d58a0a260 (diff)
New frameinvoker
Diffstat (limited to 'sugar')
-rw-r--r--sugar/graphics/canvasicon.py3
-rw-r--r--sugar/graphics/palette.py27
2 files changed, 24 insertions, 6 deletions
diff --git a/sugar/graphics/canvasicon.py b/sugar/graphics/canvasicon.py
index 9d9fc83..c7e318b 100644
--- a/sugar/graphics/canvasicon.py
+++ b/sugar/graphics/canvasicon.py
@@ -373,7 +373,8 @@ class CanvasIcon(hippo.CanvasBox, hippo.CanvasItem):
def set_palette(self, palette):
self._palette = palette
- self._palette.props.invoker = CanvasInvoker(self)
+ if not self._palette.props.invoker:
+ self._palette.props.invoker = CanvasInvoker(self)
def set_tooltip(self, text):
self.set_palette(Palette(text))
diff --git a/sugar/graphics/palette.py b/sugar/graphics/palette.py
index dc51fe5..1a019b8 100644
--- a/sugar/graphics/palette.py
+++ b/sugar/graphics/palette.py
@@ -62,6 +62,7 @@ class Palette(gobject.GObject):
def __init__(self, label, accel_path=None):
gobject.GObject.__init__(self)
+ self._invoker = None
self._group_id = None
self._up = False
self._position = self.AUTOMATIC
@@ -151,6 +152,14 @@ class Palette(gobject.GObject):
else:
raise AssertionError
+ def do_get_property(self, pspec):
+ if pspec.name == 'invoker':
+ return self._invoker
+ elif pspec.name == 'position':
+ return self._position
+ else:
+ raise AssertionError
+
def _get_position(self, alignment):
# Invoker: x, y, width and height
inv_rect = self._invoker.get_rect()
@@ -185,12 +194,12 @@ class Palette(gobject.GObject):
def _in_screen(self, x, y):
[width, height] = self._menu.size_request()
- screen_width = gtk.gdk.screen_width() - units.grid_to_pixels(1)
- screen_height = gtk.gdk.screen_height() - units.grid_to_pixels(1)
+ screen_area = self._invoker.get_screen_area()
- return x + width <= screen_width and \
- y + height <= screen_height and \
- x >= units.grid_to_pixels(1) and y >= units.grid_to_pixels(1)
+ return x >= screen_area.x and \
+ y >= screen_area.y and \
+ x + width <= screen_area.width and \
+ y + height <= screen_area.height
def _get_automatic_position(self):
alignments = [ _BOTTOM_LEFT, _BOTTOM_RIGHT,
@@ -203,6 +212,9 @@ class Palette(gobject.GObject):
if self._in_screen(x, y):
return x, y
+ # We fail
+ return (0, 0)
+
def _show(self):
x = y = 0
@@ -381,6 +393,11 @@ class Invoker(object):
for listener in self._listeners:
listener.invoker_mouse_leave()
+ def get_screen_area(self):
+ width = gtk.gdk.screen_width()
+ height = gtk.gdk.screen_height()
+ return gtk.gdk.Rectangle(0, 0, width, height)
+
class WidgetInvoker(Invoker):
def __init__(self, widget):
Invoker.__init__(self)