Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/sugar/graphics/palette.py
diff options
context:
space:
mode:
Diffstat (limited to 'sugar/graphics/palette.py')
-rw-r--r--sugar/graphics/palette.py42
1 files changed, 29 insertions, 13 deletions
diff --git a/sugar/graphics/palette.py b/sugar/graphics/palette.py
index 6b1209a..d87b0f6 100644
--- a/sugar/graphics/palette.py
+++ b/sugar/graphics/palette.py
@@ -78,8 +78,8 @@ class Palette(gtk.Window):
RIGHT = 5
TOP = 6
- _PRIMARY = 0
- _SECONDARY = 1
+ PRIMARY = 0
+ SECONDARY = 1
__gtype_name__ = 'SugarPalette'
@@ -104,10 +104,12 @@ class Palette(gtk.Window):
self.set_resizable(False)
self.connect('realize', self._realize_cb)
+ self.palette_state = self.PRIMARY
+
+ self._old_alloc = None
self._full_request = [0, 0]
self._cursor_x = 0
self._cursor_y = 0
- self._state = self._PRIMARY
self._invoker = None
self._group_id = None
self._up = False
@@ -219,7 +221,20 @@ class Palette(gtk.Window):
def do_size_allocate(self, allocation):
gtk.Window.do_size_allocate(self, allocation)
- self.queue_draw()
+
+ if self._old_alloc is None or \
+ self._old_alloc.x != allocation.x or \
+ self._old_alloc.y != allocation.y or \
+ self._old_alloc.width != allocation.width or \
+ self._old_alloc.height != allocation.height:
+ self.queue_draw()
+
+ # We need to store old allocation because when size_allocate
+ # is called widget.allocation is already updated.
+ # gtk.Window resizing is different from normal containers:
+ # the X window is resized, widget.allocation is updated from
+ # the configure request handler and finally size_allocate is called.
+ self._old_alloc = allocation
def do_expose_event(self, event):
# We want to draw a border with a beautiful gap
@@ -334,11 +349,11 @@ class Palette(gtk.Window):
return x, y
def _update_full_request(self):
- state = self._state
+ state = self.palette_state
self.set_size_request(-1, -1)
- self._set_state(self._SECONDARY)
+ self._set_state(self.SECONDARY)
self._full_request = self.size_request()
self.set_size_request(self._full_request[0], -1)
@@ -434,27 +449,28 @@ class Palette(gtk.Window):
self._hide()
def _set_state(self, state):
- if self._state == state:
+ if self.palette_state == state:
return
- if state == self._PRIMARY:
+ if state == self.PRIMARY:
self.menu.unembed()
self._secondary_box.hide()
- elif state == self._SECONDARY:
+ elif state == self.SECONDARY:
self.menu.embed(self._menu_box)
self._secondary_box.show()
- self._state = state
+ self.palette_state = state
def _invoker_mouse_enter_cb(self, invoker):
immediate = False
if self._group_id:
group = palettegroup.get_group(self._group_id)
if group and group.is_up():
+ self._set_state(group.get_state())
+
immediate = True
group.popdown()
- print immediate
self.popup(immediate=immediate)
def _invoker_mouse_leave_cb(self, invoker):
@@ -516,7 +532,7 @@ class _PopupAnimation(animator.Animation):
def next_frame(self, current):
if current == 1.0:
- self._palette._set_state(Palette._PRIMARY)
+ self._palette._set_state(Palette.PRIMARY)
self._palette._show()
class _SecondaryAnimation(animator.Animation):
@@ -526,7 +542,7 @@ class _SecondaryAnimation(animator.Animation):
def next_frame(self, current):
if current == 1.0:
- self._palette._set_state(Palette._SECONDARY)
+ self._palette._set_state(Palette.SECONDARY)
self._palette._update_position()
class _PopdownAnimation(animator.Animation):