diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2011-07-12 19:15:24 (GMT) |
---|---|---|
committer | Simon Schampijer <simon@schampijer.de> | 2011-07-15 16:54:29 (GMT) |
commit | 880e60bddaed0d5258afb4f53e135e55745245ac (patch) | |
tree | 4247dea9313ff6ec3330eaa80a943dad3f7931b8 | |
parent | 10580fc2a73aec1f828a3d8d43489e1d31a670c1 (diff) |
Sugar-toolkit: Pack page in ToolbarButton when is connected to the window - OLPC #10930
To add the accelerator to the ToolButton the activity must have set
the 'sugar-accel-group' before. The patch does make the ToolbarButton
listen to the 'hierarchy-changed' signal and repack itself accordingly.
Since the ToolButtons of the subtoolbar do listen to 'hierarchy-changed'
as well to set the accelerator they will set it accordingly.
This fixes the accelerators for new-style-toolbar activities
like Terminal, TurtleArt and Paint, more info in #10930.
Signed-by-off: Gonzalo Odiard <gonzalo@laptop.org>
Acked-by: Simon Schampijer <simon@laptop.org>
-rw-r--r-- | src/sugar/graphics/toolbarbox.py | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/sugar/graphics/toolbarbox.py b/src/sugar/graphics/toolbarbox.py index b674e8d..2f455f5 100644 --- a/src/sugar/graphics/toolbarbox.py +++ b/src/sugar/graphics/toolbarbox.py @@ -36,6 +36,15 @@ class ToolbarButton(ToolButton): self.connect('clicked', lambda widget: self.set_expanded(not self.is_expanded())) + self.connect('hierarchy-changed', self.__hierarchy_changed_cb) + + def __hierarchy_changed_cb(self, tool_button, previous_toplevel): + if hasattr(self.parent, 'owner'): + if self.page_widget: + self._unparent() + self.parent.owner.pack_start(self.page_widget) + self.set_expanded(False) + def get_toolbar_box(self): if not hasattr(self.parent, 'owner'): return None |