Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/PascalTriangle.activity/pascaltriangle.py
diff options
context:
space:
mode:
authorPhilip Withnall <philip@tecnocode.co.uk>2013-08-19 18:01:31 (GMT)
committer Philip Withnall <philip@tecnocode.co.uk>2013-08-19 18:01:31 (GMT)
commit51bfe1d673d1d3aebaa618cdc1e6ea7f09717e0e (patch)
treedbea21b49b6032b0dccb62cd61df35e5395202bf /PascalTriangle.activity/pascaltriangle.py
parentdecd29f87b5f1ff8af585188988ef67d66ef0f0f (diff)
Fix the hint button to work with older versions of Sugar
The ‘help’ icon it used didn’t previously exist, and accelerator support for ToggleToolButtons also didn’t exist.
Diffstat (limited to 'PascalTriangle.activity/pascaltriangle.py')
-rwxr-xr-xPascalTriangle.activity/pascaltriangle.py15
1 files changed, 13 insertions, 2 deletions
diff --git a/PascalTriangle.activity/pascaltriangle.py b/PascalTriangle.activity/pascaltriangle.py
index 8a75d7e..d98ac73 100755
--- a/PascalTriangle.activity/pascaltriangle.py
+++ b/PascalTriangle.activity/pascaltriangle.py
@@ -443,10 +443,21 @@ class NewGameButton(ToolButton):
class HintButton(ToggleToolButton):
def __init__(self, activity, **kwargs):
- ToggleToolButton.__init__(self, 'toolbar-help', **kwargs)
+ ToggleToolButton.__init__(self, 'show-hints', **kwargs)
#self.props.tooltip = 'Show Hints'
self.set_tooltip(_('Show Hints'))
- self.props.accelerator = '<Ctrl>H'
+
+ # Add an accelerator. In later versions of Sugar, we can just set the
+ # 'accelerator' property instead.
+ #self.props.accelerator = '<Ctrl>H'
+ accel_group = activity.get_toplevel().sugar_accel_group
+ keyval, mask = Gtk.accelerator_parse('<Ctrl>H')
+ # the accelerator needs to be set at the child, so the Gtk.AccelLabel
+ # in the palette can pick it up.
+ accel_flags = Gtk.AccelFlags.LOCKED | Gtk.AccelFlags.VISIBLE
+ self.get_child().add_accelerator('clicked', accel_group,
+ keyval, mask, accel_flags)
+
self.connect('clicked', self.__hint_button_clicked_cb, activity)
def __hint_button_clicked_cb(self, button, activity):