Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar
diff options
context:
space:
mode:
authorMarco Pesenti Gritti <mpg@redhat.com>2007-08-29 16:26:58 (GMT)
committer Marco Pesenti Gritti <mpg@redhat.com>2007-08-29 16:26:58 (GMT)
commit72b3a3e2e24c5a3ea70f2768de197e4ce442d13e (patch)
tree308da6081944cc8e885e377eccec89abbbacba6b /sugar
parent722b9d01e7bb724cf86df919c69043d1b751c37f (diff)
Cleanup a bit the positioning logic. Drop specific
positioning, we can readd it later if it proves to be necessary.
Diffstat (limited to 'sugar')
-rw-r--r--sugar/graphics/palette.py59
1 files changed, 15 insertions, 44 deletions
diff --git a/sugar/graphics/palette.py b/sugar/graphics/palette.py
index d87b0f6..eb84cdf 100644
--- a/sugar/graphics/palette.py
+++ b/sugar/graphics/palette.py
@@ -73,10 +73,6 @@ class Palette(gtk.Window):
DEFAULT = 0
AT_CURSOR = 1
AROUND = 2
- BOTTOM = 3
- LEFT = 4
- RIGHT = 5
- TOP = 6
PRIMARY = 0
SECONDARY = 1
@@ -302,38 +298,21 @@ class Palette(gtk.Window):
return int(x), int(y)
- def _get_left_position(self, inv_rect=None):
- x, y = self._get_position(-1.0, 0.0, 0.0, 0.0, inv_rect)
- if not self._in_screen(x, y):
- x, y = self._get_position(-1.0, -1.0, 0.0, 1.0, inv_rect)
- return x, y
-
- def _get_right_position(self, inv_rect=None):
- x, y = self._get_position(0.0, 0.0, 1.0, 0.0, inv_rect)
- if not self._in_screen(x, y):
- x, y = self._get_position(0.0, -1.0, 1.0, 1.0, inv_rect)
- return x, y
-
- def _get_top_position(self, inv_rect=None):
- x, y = self._get_position(0.0, -1.0, 0.0, 0.0, inv_rect)
- if not self._in_screen(x, y):
- x, y = self._get_position(-1.0, -1.0, 1.0, 0.0, inv_rect)
- return x, y
-
- def _get_bottom_position(self, inv_rect=None):
- x, y = self._get_position(0.0, 0.0, 0.0, 1.0, inv_rect)
- if not self._in_screen(x, y):
- x, y = self._get_position(-1.0, 0.0, 1.0, 1.0, inv_rect)
- return x, y
-
- def _get_around_position(self, inv_rect=None):
- x, y = self._get_bottom_position(inv_rect)
- if not self._in_screen(x, y):
- x, y = self._get_right_position(inv_rect)
- if not self._in_screen(x, y):
- x, y = self._get_top_position(inv_rect)
- if not self._in_screen(x, y):
- x, y = self._get_left_position(inv_rect)
+ def _get_around_alignments(self):
+ return ((0.0, 0.0, 0.0, 1.0),
+ (-1.0, 0.0, 1.0, 1.0),
+ (0.0, 0.0, 1.0, 0.0),
+ (0.0, -1.0, 1.0, 1.0),
+ (0.0, -1.0, 0.0, 0.0),
+ (-1.0, -1.0, 1.0, 0.0),
+ (-1.0, 0.0, 0.0, 0.0),
+ (-1.0, -1.0, 0.0, 1.0))
+
+ def _get_around_position(self):
+ for align in self._get_around_alignments():
+ x, y = self._get_position(*align)
+ if self._in_screen(x, y):
+ return x, y
return x, y
@@ -383,14 +362,6 @@ class Palette(gtk.Window):
x, y = self._get_at_cursor_position(rect)
elif position == self.AROUND:
x, y = self._get_around_position()
- elif position == self.BOTTOM:
- x, y = self._get_bottom_position()
- elif position == self.LEFT:
- x, y = self._get_left_position()
- elif position == self.RIGHT:
- x, y = self._get_right_position()
- elif position == self.TOP:
- x, y = self._get_top_position()
self.move(x, y)